From c4e0e27702fa527e9def9af30cdfc4932f852f05 Mon Sep 17 00:00:00 2001 From: mrh997 Date: Thu, 31 Jul 2025 11:07:57 +0800 Subject: [PATCH] feat(plugin): remove schema retriction for plugin server url (#278) --- backend/api/model/crossdomain/plugin/openai.go | 5 +---- .../domain/plugin/internal/openapi/convert_protocol.go | 8 ++------ 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/backend/api/model/crossdomain/plugin/openai.go b/backend/api/model/crossdomain/plugin/openai.go index fbb98752..2f491011 100644 --- a/backend/api/model/crossdomain/plugin/openai.go +++ b/backend/api/model/crossdomain/plugin/openai.go @@ -30,6 +30,7 @@ import ( "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/types/errno" + "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, "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 == "" { return errorx.New(errno.ErrPluginInvalidOpenapi3Doc, errorx.KVf(errno.PluginMsgKey, "invalid server url '%s'", serverURL)) diff --git a/backend/domain/plugin/internal/openapi/convert_protocol.go b/backend/domain/plugin/internal/openapi/convert_protocol.go index 297fc031..f1ba5a13 100644 --- a/backend/domain/plugin/internal/openapi/convert_protocol.go +++ b/backend/domain/plugin/internal/openapi/convert_protocol.go @@ -946,14 +946,10 @@ func fillManifestWithOpenapiDoc(mf *entity.PluginManifest, doc *model.Openapi3T) } func addHTTPProtocolHeadIfNeed(url string) string { - if strings.HasPrefix(url, "https://") { + if strings.HasPrefix(url, "https://") || strings.HasPrefix(url, "http://") { return url } - if strings.HasPrefix(url, "http://") { - url = strings.Replace(url, "http://", "https://", 1) - return url - } - return "https://" + url + return "http://" + url } func fillNecessaryInfoForOpenapi3Doc(doc *model.Openapi3T) {