OpenAPI auto generated path params not merged correctly
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 11.2k
- Forks
- 899
- Avg merge
- 2d 24m
- Merged PRs (30d)
- 40
Description
Environment
Nitro 2.12.4
Node v22.13.1
Reproduction
Step 1:
use definePageMeta in any route.
Step 2:
make sure that openAPI object contains parameters array, even if empty.
/api/{projectId}/index.get.ts
openAPI: {
description: 'Get a specific project by ID',
tags: ['projects'],
summary: 'Get project by ID',
operationId: 'getProjectById',
parameters: [],
}
Step 3:
Open swagger docs and notice that path variable is not auto-populated.
Describe the bug
Nitro has this feature of auto detecting API path variables and populating them as path parameters in Open API spec. However, this feature is not working as intended.
Additional context
This can be easily fixed. Just use DEFU!!!
Logs
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with /api/{projectId}/index.get.ts, definePageMeta, and an OpenAPI parameters: [] array, then inspect the generated Swagger documentation. Compare the generated path parameters with the route variable. Done means projectId appears as an automatically generated path parameter even when the parameters array is empty.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100