fix(plugin): update tool may reset request or response parameters (#302)
This commit is contained in:
@@ -88,6 +88,15 @@ func APIParamsToOpenapiOperation(reqParams, respParams []*common.APIParameter) (
|
||||
}
|
||||
}
|
||||
|
||||
if reqParams != nil {
|
||||
if !hasSetParams {
|
||||
op.Parameters = []*openapi3.ParameterRef{}
|
||||
}
|
||||
if !hasSetReqBody {
|
||||
op.RequestBody = entity.DefaultOpenapi3RequestBody()
|
||||
}
|
||||
}
|
||||
|
||||
hasSetRespBody := false
|
||||
|
||||
for _, apiParam := range respParams {
|
||||
@@ -127,13 +136,7 @@ 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 {
|
||||
if respParams != nil && !hasSetRespBody {
|
||||
op.Responses = entity.DefaultOpenapi3Responses()
|
||||
}
|
||||
|
||||
|
||||
@@ -822,7 +822,7 @@ func (p *PluginApplicationService) UpdateAPI(ctx context.Context, req *pluginAPI
|
||||
method = &m
|
||||
}
|
||||
|
||||
updateReq := &service.UpdateToolDraftRequest{
|
||||
updateReq := &service.UpdateDraftToolRequest{
|
||||
PluginID: req.PluginID,
|
||||
ToolID: req.APIID,
|
||||
Name: req.Name,
|
||||
|
||||
Reference in New Issue
Block a user