swagger-api / swagger-api/swagger-codegen
[ALL] Boolean cannot be cast to Schema
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
I'm running into an issue where swagger-codegen fails to generate files for any generation target when referencing an external schema, with a variant of the following error
Exception in thread "Thread-0" java.lang.RuntimeException: Could not process model 'VRI.RegistrationHelper'.Please make sure that your schema is correct!
at io.swagger.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:363)
at io.swagger.codegen.DefaultGenerator.generate(DefaultGenerator.java:724)
at io.swagger.codegen.cmd.Generate.run(Generate.java:331)
at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassCastException: java.base/java.lang.Boolean cannot be cast to io.swagger.v3.oas.models.media.Schema
I have no concerns that my external schemas are valid, swagger-editor is able to parse and generate documentation for them, they pass JSON schema validation tools, etc.
This schema is quite complex, and I wish I had a simpler example to give you, but I do not. However, I've linked the schemas and OpenAPI file to this issue.
Swagger-codegen version
3.0.0-SNAPSHOT. Regression status unknown. Has always been a 3.0.0 target.
Swagger declaration file content or url
gist
linked schema 1
linked schema 2
Command line used for generation
java -jar swagger-codegen-cli.jar generate -i vri.yaml -l java -o ./
Steps to reproduce
Run command found in Command line used for generation
Related issues/PRs
None.
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 with the linked OpenAPI and schema gists, then trace the reported failure through DefaultGenerator.java and Generate.run. Reproduce the command shown with the supplied external schemas and identify where the Boolean is treated as a Schema; done means generation completes without the ClassCastException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100