feat(plugin): remove schema retriction for plugin server url (#278)
This commit is contained in:
parent
30fd1b3e27
commit
c4e0e27702
|
|
@ -30,6 +30,7 @@ import (
|
||||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/slices"
|
"github.com/coze-dev/coze-studio/backend/pkg/lang/slices"
|
||||||
"github.com/coze-dev/coze-studio/backend/pkg/logs"
|
"github.com/coze-dev/coze-studio/backend/pkg/logs"
|
||||||
"github.com/coze-dev/coze-studio/backend/types/errno"
|
"github.com/coze-dev/coze-studio/backend/types/errno"
|
||||||
|
|
||||||
"github.com/cloudwego/eino/schema"
|
"github.com/cloudwego/eino/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -65,10 +66,6 @@ func (ot Openapi3T) Validate(ctx context.Context) (err error) {
|
||||||
return errorx.New(errno.ErrPluginInvalidOpenapi3Doc, errorx.KVf(errno.PluginMsgKey,
|
return errorx.New(errno.ErrPluginInvalidOpenapi3Doc, errorx.KVf(errno.PluginMsgKey,
|
||||||
"invalid server url '%s'", serverURL))
|
"invalid server url '%s'", serverURL))
|
||||||
}
|
}
|
||||||
if urlSchema.Scheme != "https" {
|
|
||||||
return errorx.New(errno.ErrPluginInvalidOpenapi3Doc, errorx.KV(errno.PluginMsgKey,
|
|
||||||
"server url must start with 'https://'"))
|
|
||||||
}
|
|
||||||
if urlSchema.Host == "" {
|
if urlSchema.Host == "" {
|
||||||
return errorx.New(errno.ErrPluginInvalidOpenapi3Doc, errorx.KVf(errno.PluginMsgKey,
|
return errorx.New(errno.ErrPluginInvalidOpenapi3Doc, errorx.KVf(errno.PluginMsgKey,
|
||||||
"invalid server url '%s'", serverURL))
|
"invalid server url '%s'", serverURL))
|
||||||
|
|
|
||||||
|
|
@ -946,14 +946,10 @@ func fillManifestWithOpenapiDoc(mf *entity.PluginManifest, doc *model.Openapi3T)
|
||||||
}
|
}
|
||||||
|
|
||||||
func addHTTPProtocolHeadIfNeed(url string) string {
|
func addHTTPProtocolHeadIfNeed(url string) string {
|
||||||
if strings.HasPrefix(url, "https://") {
|
if strings.HasPrefix(url, "https://") || strings.HasPrefix(url, "http://") {
|
||||||
return url
|
return url
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(url, "http://") {
|
return "http://" + url
|
||||||
url = strings.Replace(url, "http://", "https://", 1)
|
|
||||||
return url
|
|
||||||
}
|
|
||||||
return "https://" + url
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func fillNecessaryInfoForOpenapi3Doc(doc *model.Openapi3T) {
|
func fillNecessaryInfoForOpenapi3Doc(doc *model.Openapi3T) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue