mirror of
https://github.com/APIParkLab/APIPark.git
synced 2026-06-14 20:41:15 +08:00
fix:bug
This commit is contained in:
@@ -54,7 +54,7 @@ func (i *imlAPIModule) getAPIDoc(ctx context.Context, serviceId string) (*openap
|
||||
return openapi3Loader.LoadFromData([]byte(doc.Content))
|
||||
}
|
||||
|
||||
func (i *imlAPIModule) updateAPIDoc(ctx context.Context, serviceId string, serviceName string, path string, summary string, description string, aiPrompt *ai_api_dto.AiPrompt) error {
|
||||
func (i *imlAPIModule) updateAPIDoc(ctx context.Context, serviceId, serviceName, orgPath, path, summary, description string, aiPrompt *ai_api_dto.AiPrompt) error {
|
||||
doc, err := i.getAPIDoc(ctx, serviceId)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -64,6 +64,10 @@ func (i *imlAPIModule) updateAPIDoc(ctx context.Context, serviceId string, servi
|
||||
if aiPrompt != nil {
|
||||
variables = aiPrompt.Variables
|
||||
}
|
||||
if doc.Paths != nil {
|
||||
doc.Paths.Delete(orgPath)
|
||||
}
|
||||
|
||||
doc.AddOperation(path, http.MethodPost, genOperation(summary, description, variables))
|
||||
result, err := doc.MarshalJSON()
|
||||
if err != nil {
|
||||
@@ -103,7 +107,7 @@ func (i *imlAPIModule) Create(ctx context.Context, serviceId string, input *ai_a
|
||||
input.Id = uuid.New().String()
|
||||
}
|
||||
return i.transaction.Transaction(ctx, func(txCtx context.Context) error {
|
||||
err = i.updateAPIDoc(ctx, serviceId, info.Name, input.Path, input.Name, input.Description, input.AiPrompt)
|
||||
err = i.updateAPIDoc(ctx, serviceId, info.Name, "", input.Path, input.Name, input.Description, input.AiPrompt)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -143,13 +147,14 @@ func (i *imlAPIModule) Edit(ctx context.Context, serviceId string, apiId string,
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
orgPath := apiInfo.Path
|
||||
if input.Path != nil {
|
||||
apiInfo.Path = *input.Path
|
||||
}
|
||||
if input.Description != nil {
|
||||
apiInfo.Description = *input.Description
|
||||
}
|
||||
err = i.updateAPIDoc(ctx, serviceId, info.Name, apiInfo.Path, apiInfo.Name, apiInfo.Description, input.AiPrompt)
|
||||
err = i.updateAPIDoc(ctx, serviceId, info.Name, orgPath, apiInfo.Path, apiInfo.Name, apiInfo.Description, input.AiPrompt)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ func genOpenAPI3Template(title string, description string) *openapi3.T {
|
||||
|
||||
func genOperation(summary string, description string, variables []*ai_api_dto.AiPromptVariable) *openapi3.Operation {
|
||||
operation := openapi3.NewOperation()
|
||||
//operation.Parameters = genRequestParameters(variables)
|
||||
operation.Summary = summary
|
||||
operation.Description = description
|
||||
operation.RequestBody = genRequestBody(variables)
|
||||
|
||||
Reference in New Issue
Block a user