MCPcopy Index your code
hub / github.com/APIParkLab/APIPark / updateAPIDoc

Method updateAPIDoc

module/ai-api/iml.go:64–95  ·  view source on GitHub ↗
(ctx context.Context, serviceId, serviceName, orgPath, path, summary, description string, aiPrompt *ai_api_dto.AiPrompt)

Source from the content-addressed store, hash-verified

62}
63
64func (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
97func (i *imlAPIModule) deleteAPIDoc(ctx context.Context, serviceId string, path string) error {
98 doc, err := i.getAPIDoc(ctx, serviceId)

Callers 2

CreateMethod · 0.95
EditMethod · 0.95

Calls 7

getAPIDocMethod · 0.95
genOperationFunction · 0.85
DeleteMethod · 0.65
UpdateDocMethod · 0.65
UpdateMethod · 0.65
MarshalJSONMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected