swagger-api / swagger-api/swagger-codegen
[java/scala] ClassCastException: RefParameter cannot be cast to BodyParameter
Open
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
Caused by: java.lang.ClassCastException: io.swagger.models.parameters.RefParameter cannot be cast to io.swagger.models.parameters.BodyParameter
at io.swagger.codegen.DefaultCodegen.fromParameter(DefaultCodegen.java:2574)
at io.swagger.codegen.DefaultCodegen.fromOperation(DefaultCodegen.java:2213)
at io.swagger.codegen.languages.AbstractJavaCodegen.fromOperation(AbstractJavaCodegen.java:1057)
at io.swagger.codegen.DefaultGenerator.processOperation(DefaultGenerator.java:881)
at io.swagger.codegen.DefaultGenerator.processPaths(DefaultGenerator.java:811)
at io.swagger.codegen.DefaultGenerator.generateApis(DefaultGenerator.java:431)
at io.swagger.codegen.DefaultGenerator.generate(DefaultGenerator.java:746)

Swagger-codegen version
2.3.1-SNAPSHOT
Swagger declaration file content or url
Like open API 2.0 demo, my open API defination below:
...
"parameters": [
{
"$ref": "#/definitions/xxxx"
},
}
...
"definitions": {
"xxxx": {
"name": "X-Id",
"example": "586e56f8ed0542d7a1521786a9d6c456",
"in": "path",
"required": true,
"type": "string"
}
}
Command line used for generation
Steps to reproduce
Related issues/PRs
Suggest a fix/enhancement
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 at DefaultCodegen.java:2574 in the stack trace and compare how the referenced parameter from the OpenAPI 2.0 demo is handled with the BodyParameter cast. Review the related calls in DefaultCodegen.java, AbstractJavaCodegen.java, and DefaultGenerator.java; done means generation completes without the ClassCastException for the referenced path parameter.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, scala
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100