diff --git a/.changeset/dull-peaches-press.md b/.changeset/dull-peaches-press.md new file mode 100644 index 00000000..326e1102 --- /dev/null +++ b/.changeset/dull-peaches-press.md @@ -0,0 +1,5 @@ +--- +"wormajs": patch +--- + +fix: 生成的aidocs不包含Query Parameters diff --git a/packages/worma/src/template/presets/ai-doc/references/{tag}/{api}.md.handlebars b/packages/worma/src/template/presets/ai-doc/references/{tag}/{api}.md.handlebars index a1e550bb..ba8197ce 100644 --- a/packages/worma/src/template/presets/ai-doc/references/{tag}/{api}.md.handlebars +++ b/packages/worma/src/template/presets/ai-doc/references/{tag}/{api}.md.handlebars @@ -27,6 +27,16 @@ Pass the required parameters in `pathParams`: ``` {{/if}} +{{#if currentApi.queryParametersComment}} +## Query Parameters + +Pass the required query parameters in `params`: + +```typescript +{{{stripStarPrefix currentApi.queryParametersComment}}} +``` +{{/if}} + {{#if currentApi.requestBodyComment}} ## Request Body diff --git a/packages/worma/test/plugins/aiDoc.spec.ts b/packages/worma/test/plugins/aiDoc.spec.ts index cfa18e6b..ac6f4d03 100644 --- a/packages/worma/test/plugins/aiDoc.spec.ts +++ b/packages/worma/test/plugins/aiDoc.spec.ts @@ -247,6 +247,9 @@ describe('plugins/aiDoc', () => { expect(listPetsContent).toContain('/pets') // Should show file location, not import statement expect(listPetsContent).toContain('is located at') + // Query parameters should be documented in their own section + expect(listPetsContent).toContain('Query Parameters') + expect(listPetsContent).toContain('limit: number of items') const createPetContent = readVolFile( resolve(aidocsDir, 'references', 'pets', 'createPet.md'), @@ -254,6 +257,8 @@ describe('plugins/aiDoc', () => { ) expect(createPetContent).toContain('Create a pet') expect(createPetContent).toContain('[POST]') + // APIs without query parameters must not render the section + expect(createPetContent).not.toContain('Query Parameters') }) it('should respect custom outputDir option', async () => {