fix(plugin): fix delete last request body parameter
This commit is contained in:
parent
9b3814e2c5
commit
6e7372f12c
|
|
@ -22,6 +22,8 @@ import (
|
|||
|
||||
"github.com/getkin/kin-openapi/openapi3"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/entity"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
common "github.com/coze-dev/coze-studio/backend/api/model/plugin_develop_common"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||
|
|
@ -31,6 +33,14 @@ 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
|
||||
|
||||
|
|
|
|||
|
|
@ -165,6 +165,9 @@ func (p *pluginServiceImpl) UpdateBotDefaultParams(ctx context.Context, req *Upd
|
|||
if !ok {
|
||||
return fmt.Errorf("the '%s' media type is not defined in request body", model.MediaTypeJson)
|
||||
}
|
||||
if op.RequestBody == nil || op.RequestBody.Value == nil {
|
||||
op.RequestBody = entity.DefaultOpenapi3RequestBody()
|
||||
}
|
||||
if op.RequestBody.Value.Content == nil {
|
||||
op.RequestBody.Value.Content = map[string]*openapi3.MediaType{}
|
||||
}
|
||||
|
|
@ -182,16 +185,12 @@ func (p *pluginServiceImpl) UpdateBotDefaultParams(ctx context.Context, req *Upd
|
|||
}
|
||||
|
||||
if op.Responses == nil {
|
||||
op.Responses = map[string]*openapi3.ResponseRef{}
|
||||
op.Responses = entity.DefaultOpenapi3Responses()
|
||||
}
|
||||
|
||||
oldRespRef, ok := op.Responses[strconv.Itoa(http.StatusOK)]
|
||||
if !ok {
|
||||
oldRespRef = &openapi3.ResponseRef{
|
||||
Value: &openapi3.Response{
|
||||
Content: map[string]*openapi3.MediaType{},
|
||||
},
|
||||
}
|
||||
oldRespRef = entity.DefaultOpenapi3Responses()[strconv.Itoa(http.StatusOK)]
|
||||
op.Responses[strconv.Itoa(http.StatusOK)] = oldRespRef
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -354,7 +354,16 @@ func needResetDebugStatusTool(_ context.Context, nt, ot *model.Openapi3Operation
|
|||
}
|
||||
}
|
||||
|
||||
if nt.RequestBody == nil && ot.RequestBody == nil {
|
||||
return false
|
||||
}
|
||||
if (nt.RequestBody == nil && ot.RequestBody != nil) ||
|
||||
(nt.RequestBody != nil && ot.RequestBody == nil) {
|
||||
return true
|
||||
}
|
||||
|
||||
nReqBody, oReqBody := nt.RequestBody.Value, ot.RequestBody.Value
|
||||
|
||||
if len(nReqBody.Content) != len(oReqBody.Content) {
|
||||
return true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,28 +3,6 @@
|
|||
-- 当主键或唯一键冲突时,不会插入新记录,而是更新指定字段
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
-- email: developer@coze-studio.com, password: 123456
|
||||
INSERT INTO user (id, name, unique_name, email, password, description, icon_uri, user_verified, locale, session_key, created_at, updated_at)
|
||||
VALUES (888, 'developer', 'developer@coze-studio.com', 'developer@coze-studio.com',
|
||||
'$argon2id$v=19$m=65536,t=3,p=4$NuzvhNc89RHjGkwmfItHkg$hWXhVXjQFTP/Pa637AqtcHXs84evoDUzeQsTKTElau4',
|
||||
'', 'default_icon/user_default_icon.png', 0, 'en-US', '', 1746698238701, 1746698238701)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
id = VALUES(id);
|
||||
|
||||
-- 初始化空间表数据
|
||||
INSERT INTO space (id, owner_id, name, description, icon_uri, creator_id, created_at, updated_at, deleted_at)
|
||||
VALUES (666, 888, 'Personal Space', 'This is your personal space', 'default_icon/team_default_icon.png',
|
||||
888, 1747043468643, 1747043468643, NULL)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
id = VALUES(id);
|
||||
|
||||
-- 初始化空间成员表数据
|
||||
INSERT INTO space_user (id, space_id, user_id, role_type, created_at, updated_at)
|
||||
VALUES (1, 666, 888, 1, 1747043468643, 1747043468643)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
id = VALUES(id);
|
||||
|
||||
|
||||
-- mock chat mode config for self-test, if publish should remove
|
||||
|
||||
INSERT INTO single_agent_draft (
|
||||
|
|
|
|||
|
|
@ -3,28 +3,6 @@
|
|||
-- 当主键或唯一键冲突时,不会插入新记录,而是更新指定字段
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
-- email: developer@coze-studio.com, password: 123456
|
||||
INSERT INTO user (id, name, unique_name, email, password, description, icon_uri, user_verified, locale, session_key, created_at, updated_at)
|
||||
VALUES (888, 'developer', 'developer@coze-studio.com', 'developer@coze-studio.com',
|
||||
'$argon2id$v=19$m=65536,t=3,p=4$NuzvhNc89RHjGkwmfItHkg$hWXhVXjQFTP/Pa637AqtcHXs84evoDUzeQsTKTElau4',
|
||||
'', 'default_icon/user_default_icon.png', 0, 'en-US', '', 1746698238701, 1746698238701)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
id = VALUES(id);
|
||||
|
||||
-- 初始化空间表数据
|
||||
INSERT INTO space (id, owner_id, name, description, icon_uri, creator_id, created_at, updated_at, deleted_at)
|
||||
VALUES (666, 888, 'Personal Space', 'This is your personal space', 'default_icon/team_default_icon.png',
|
||||
888, 1747043468643, 1747043468643, NULL)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
id = VALUES(id);
|
||||
|
||||
-- 初始化空间成员表数据
|
||||
INSERT INTO space_user (id, space_id, user_id, role_type, created_at, updated_at)
|
||||
VALUES (1, 666, 888, 1, 1747043468643, 1747043468643)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
id = VALUES(id);
|
||||
|
||||
|
||||
-- mock chat mode config for self-test, if publish should remove
|
||||
|
||||
INSERT INTO single_agent_draft (
|
||||
|
|
|
|||
Loading…
Reference in New Issue