(ctx context.Context, serviceId, serviceName, orgPath, path, summary, description string, aiPrompt *ai_api_dto.AiPrompt)
| 62 | } |
| 63 | |
| 64 | func (i *imlAPIModule) updateAPIDoc(ctx context.Context, serviceId, serviceName, orgPath, path, summary, description string, aiPrompt *ai_api_dto.AiPrompt) error { |
| 65 | doc, err := i.getAPIDoc(ctx, serviceId) |
| 66 | if err != nil { |
| 67 | return err |
| 68 | } |
| 69 | |
| 70 | var variables []*ai_api_dto.AiPromptVariable |
| 71 | if aiPrompt != nil { |
| 72 | variables = aiPrompt.Variables |
| 73 | } |
| 74 | if doc.Paths != nil { |
| 75 | doc.Paths.Delete(orgPath) |
| 76 | } |
| 77 | |
| 78 | doc.AddOperation(path, http.MethodPost, genOperation(summary, description, variables)) |
| 79 | result, err := doc.MarshalJSON() |
| 80 | if err != nil { |
| 81 | return err |
| 82 | } |
| 83 | return i.transaction.Transaction(ctx, func(ctx context.Context) error { |
| 84 | count, err := i.apiDocService.UpdateDoc(ctx, serviceId, &api_doc.UpdateDoc{ |
| 85 | ID: uuid.New().String(), |
| 86 | Content: string(result), |
| 87 | }) |
| 88 | if err != nil { |
| 89 | return fmt.Errorf("update api doc error:%v", err) |
| 90 | } |
| 91 | return i.serviceOverviewService.Update(ctx, serviceId, &service_overview.Update{ |
| 92 | ApiCount: &count, |
| 93 | }) |
| 94 | }) |
| 95 | } |
| 96 | |
| 97 | func (i *imlAPIModule) deleteAPIDoc(ctx context.Context, serviceId string, path string) error { |
| 98 | doc, err := i.getAPIDoc(ctx, serviceId) |
no test coverage detected