fix(backend_plugin): plugin common header and parameter default value (#181)

This commit is contained in:
mrh997
2025-07-29 19:29:36 +08:00
committed by GitHub
parent 8137b0aee5
commit 53345f58c2
7 changed files with 204 additions and 80 deletions

View File

@@ -20,9 +20,8 @@ import (
"net/http"
"strconv"
"github.com/getkin/kin-openapi/openapi3"
"github.com/coze-dev/coze-studio/backend/domain/plugin/entity"
"github.com/getkin/kin-openapi/openapi3"
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
common "github.com/coze-dev/coze-studio/backend/api/model/plugin_develop_common"
@@ -33,14 +32,6 @@ import (
func APIParamsToOpenapiOperation(reqParams, respParams []*common.APIParameter) (*openapi3.Operation, error) {
op := &openapi3.Operation{}
if reqParams != nil && len(reqParams) == 0 {
op.Parameters = []*openapi3.ParameterRef{}
op.RequestBody = entity.DefaultOpenapi3RequestBody()
}
if respParams != nil && len(respParams) == 0 {
op.Responses = entity.DefaultOpenapi3Responses()
}
hasSetReqBody := false
hasSetParams := false
@@ -136,6 +127,16 @@ func APIParamsToOpenapiOperation(reqParams, respParams []*common.APIParameter) (
}
}
if op.Parameters == nil {
op.Parameters = []*openapi3.ParameterRef{}
}
if op.RequestBody == nil {
op.RequestBody = entity.DefaultOpenapi3RequestBody()
}
if op.Responses == nil {
op.Responses = entity.DefaultOpenapi3Responses()
}
return op, nil
}