OpenAPITools / OpenAPITools/openapi-generator
[BUG][JAVA][RUBY] Stack overflow hit when parsing swagger
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
I've a swagger that I would like to translate to ruby code. When I run the following command:
java -jar openapi-generator-cli-7.3.0.jar generate -i openapi.json -g ruby -p useAutoload=true --additional-properties=moduleName=OpenApiClientVersioned --skip-validate-spec
it gives me the following error message:
[main] INFO o.o.codegen.DefaultGenerator - Generating with dryRun=false
[main] INFO o.o.c.ignore.CodegenIgnoreProcessor - No .openapi-generator-ignore file found.
[main] INFO o.o.codegen.DefaultGenerator - OpenAPI Generator: ruby (client)
[main] INFO o.o.codegen.DefaultGenerator - Generator 'ruby' is considered stable.
[main] INFO o.o.c.languages.AbstractRubyCodegen - Hint: Environment variable 'RUBY_POST_PROCESS_FILE' (optional) not defined. E.g. to format the source code, please try 'export RUBY_POST_PROCESS_FILE="/usr/local/bin/rubocop -a"' (Linux/Mac)
[main] WARN o.o.codegen.InlineModelResolver - allOf schema `null` containing multiple types (not model) is not supported at the moment.
[main] INFO o.o.codegen.InlineModelResolver - Inline schema created as authenticationCommand_request. To have complete control of the model name, set the `title` field or use the modelNameMapping option (e.g. --model-name-mappings authenticationCommand_request=NewModel,ModelA=NewModelA in CLI) or inlineSchemaNameMapping option (--inline-schema-name-mappings authenticationCommand_request=NewModel,ModelA=NewModelA in CLI).
[main] INFO o.o.codegen.utils.URLPathUtils - 'host' (OAS 2.0) or 'servers' (OAS 3.0) not defined in the spec. Default to [http://localhost] for server URL [http://localhost/]
[main] INFO o.o.codegen.utils.URLPathUtils - 'host' (OAS 2.0) or 'servers' (OAS 3.0) not defined in the spec. Default to [http://localhost] for server URL [http://localhost/]
Exception in thread "main" java.lang.RuntimeException: Could not process model 'CqSerializable'.Please make sure that your schema is correct!
at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:546)
at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:974)
at org.openapitools.codegen.cmd.Generate.execute(Generate.java:511)
at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:66)
Caused by: java.lang.RuntimeException: Stack overflow hit when looking for CqSerializable an infinite loop starting and ending at authenticationCommand_request was seen
at org.openapitools.codegen.DefaultCodegen.getAllOfDescendants(DefaultCodegen.java:3539)
at org.openapitools.codegen.DefaultCodegen.createDiscriminator(DefaultCodegen.java:3621)
at org.openapitools.codegen.DefaultCodegen.fromModel(DefaultCodegen.java:3086)
at org.openapitools.codegen.DefaultGenerator.processModels(DefaultGenerator.java:1358)
at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:541)
... 4 more
openapi-generator version
openapi-generator-cli-7.3.0.jar
openapi-generator-cli-8.0.0-20231011.125706-1.jar
OpenAPI declaration file content or url
https://gist.github.com/Ruubb/0724a4d471f4363ebedde7ff6006fce9
Generation Details
It does not work for ruby, java
Steps to reproduce
Run the following command:
java -jar openapi-generator-cli-7.3.0.jar generate -i openapi.json -g ruby -p useAutoload=true --additional-properties=moduleName=OpenApiClientVersioned --skip-validate-spec
Where opanpi.json has the content provided previously.
Related issues/PRs
Suggest a fix
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
Reproduce the failure with the Java command and the OpenAPI document linked in the issue. Start with DefaultCodegen.getAllOfDescendants and createDiscriminator, then verify that model generation for the Ruby and Java generators completes without the reported recursive stack overflow.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, ruby
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100