swagger-api / swagger-api/swagger-codegen
Invalid java client code is generated when body parameter is a map.
Open
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
When body parameter is a map, generated code is not correct.
Currently "Object" is generated. It should have been Map<String, Object>
Swagger-codegen version 2.2.3
Swagger declaration file content or url
{
"in": "body",
"name": "body",
"description": "description",
"required": true,
"schema": {
"type": "object",
"additionalProperties": {
"type": "object"
}
}
}
Command line used for generation
generate -i swagger.json -l java -o output
Suggest a fix/enhancement
Generated Code:
public ApiResponse<RefLinkDto> methodName( Object body) throws ApiException {
}
Correct Code:
public ApiResponse<RefLinkDto> methodName(Map<String, Object> body) throws ApiException {
}
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 reproducing the issue with the generate command, the supplied Swagger body-parameter schema, and the Java target. Trace how Java client method parameters are selected for object schemas with additionalProperties; done means the generated method uses Map<String, Object> instead of Object for this input.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100