swagger-api / swagger-api/swagger-codegen
Incorrect operation parameter nesting for body parameter with type array
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
When the body parameter is an array (of primitives or objects, does not matter), template variables receive 2-level array instead of 1-level (operations.operation[0].allParams[0].items.items).
When the parameter is in query, this does not happen.
When the parameter is not array, this does not happen.
"swagger" JSON output is correct, debugOperations output is incorrect.
Swagger-codegen version
2.2.3, 2.3.0-SNAPSHOT
Swagger declaration file content or url
swagger: '2.0'
paths:
/primitive:
post:
parameters:
- name: body
in: body
schema:
type: array
items:
type: string
responses:
'200':
description: ''
Command line used for generation
java -DdebugOperations -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -l swagger -i source.yaml -o out-swagger/ >debugOperations.json
Steps to reproduce
generate, see debugOperations.json, path operations.operation[0].allParams[0].items.items
Related issues/PRs
Probably, #6098 #6190
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
Run the shown swagger-codegen CLI command with source.yaml and inspect debugOperations.json at operations.operation[0].allParams[0].items.items. Compare this structure with the correct swagger JSON output and the query/non-array cases; done means a body array exposes one items level rather than two in debugOperations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, yaml
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100