OpenAPITools / OpenAPITools/openapi-generator

[BUG] [JAVA] Description

Open
#4,179 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: Java Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Description

Api generation with config option models=true or models=false throws:

Exception in thread "main" java.lang.ClassCastException: java.lang.Boolean cannot be cast to java.util.List
        at org.openapitools.codegen.DefaultCodegen.updateAllModels(DefaultCodegen.java:273)
        at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:477)
        at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:923)
        at org.openapitools.codegen.cmd.Generate.run(Generate.java:416)
        at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:60)
openapi-generator version

4.1.3

OpenAPI declaration file content or url

Petstore example file

Command line used for generation

openapi-generator generate -i /tmp/petstore.json -o /tmp/petstore -g java --library=resttemplate -c /tmp/config.json

Steps to reproduce

Create file /tmp/config.json with contents:

{
  "models": true
}

Download petstore.json to /tmp

Run command:
openapi-generator generate -i /tmp/petstore.json -o /tmp/petstore -g java --library=resttemplate -c /tmp/config.json

Related issues/PRs

Didn't found any

Suggest a fix

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at DefaultCodegen.java:273, where the stack trace shows the ClassCastException during updateAllModels, and trace how the models config value is read from /tmp/config.json. Reproduce with the petstore.json example and the provided Java RestTemplate command; done means generation completes without the exception for models=true and models=false.

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
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.