swagger-api / swagger-api/swagger-codegen
Petstore swagger example uses "default" incorrectly
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
"default" is used incorrectly in the petstore swagger example. An array schema has a default inside the "items" definition, when it should be the default of the array parameter itself.
Swagger declaration file content or url
"parameters": [
{
"name": "status",
"in": "query",
"description": "Status values that need to be considered for filter",
"required": true,
"type": "array",
"items": {
"type": "string",
"enum": [
"available",
"pending",
"sold"
],
"default": "available"
},
"collectionFormat": "multi"
}
]
Found: https://petstore.swagger.io/v2/swagger.json
Related issues/PRs
https://github.com/OAI/OpenAPI-Specification/issues/1629
This is an issue in the openapi spec which notes that the example is wrong.
Suggest a fix/enhancement
"parameters": [
{
"name": "status",
"in": "query",
"description": "Status values that need to be considered for filter",
"required": true,
"type": "array",
"items": {
"type": "string",
"enum": [
"available",
"pending",
"sold"
]
},
"default": ["available"],
"collectionFormat": "multi"
}
]
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
Start by locating the source for the Petstore swagger.json example at petstore.swagger.io/v2/swagger.json and compare it with the declaration shown in this issue. Check the related OpenAPI Specification issue for context; done means the published example uses the corrected array-parameter default placement.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100