Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debugSupportingFiles causes Infinite recursion #241

Closed
matteomazza91 opened this issue Jun 7, 2018 · 3 comments · Fixed by #903
Closed

debugSupportingFiles causes Infinite recursion #241

matteomazza91 opened this issue Jun 7, 2018 · 3 comments · Fixed by #903

Comments

@matteomazza91
Copy link
Contributor

Description

the option debugSupportingFiles causes a com.fasterxml.jackson.databind.JsonMappingException: Infinite recursion (StackOverflowError) exception.
This only occurs if a Model-schema reference another model-schema

As (part of) the stack trace point out, the CodegenModel has a "parentModel" property that cause the infinite recursion:

[main] INFO org.openapitools.codegen.DefaultGenerator - ############ Supporting file info ############
com.fasterxml.jackson.databind.JsonMappingException: Infinite recursion (StackOverflowError) (through reference chain:      org.openapitools.codegen.CodegenModel["parentModel"]->org.openapitools.codegen.CodegenModel["children"]->java.util.ArrayList[0]->org.openapitools.codegen.CodegenModel["parentModel"]->org.openapitools.codegen.CodegenModel["children"]->java.util.ArrayList[0]->org.openapitools.codegen.CodegenModel["parentModel"]->org.openapitools.codegen.CodegenModel["children"]->java.util.ArrayList[0]->org.openapitools.codegen.CodegenModel["parentModel"]->org.openapitools.codegen.CodegenModel["children"]->java.util.ArrayList[0]->org.openapitools.codegen.CodegenModel["parentModel"]
openapi-generator version
OpenAPI declaration file content or url

This is the OpenAPI that generates the issue: https://pastebin.com/c5tQgWQ9

Note: if the line - $ref: "#/components/schemas/UserDetail" is removed from the User schema, the exception is not raised.

Command line used for generation

java -jar openapi-generator-cli.jar generate -i /path/to/input.yaml -g java -o test/client/petsore/java -DdebugSupportingFiles=true

Steps to reproduce
  • create the file /path/to/input.yaml with the content of https://pastebin.com/c5tQgWQ9
  • run java -jar openapi-generator-cli.jar generate -i /path/to/input.yaml -g java -o test/client/petsore/java -DdebugSupportingFiles=true
Suggest a fix/enhancement

the call to the debugging method is present in the buildSupportFileBundle method of org.openapitools.codegen.DefaultGenerator class

if (System.getProperty("debugSupportingFiles") != null) {
        LOGGER.info("############ Supporting file info ############");
        Json.prettyPrint(bundle);
 }
@wing328
Copy link
Member

wing328 commented Aug 27, 2018

UPDATE: I've filed #903 to fix the issue.

Please take a look when you've time.

@wing328
Copy link
Member

wing328 commented Aug 27, 2018

#903 has been merged into master. Please try the latest (SNAPSHOT, docker images, etc) when you've time

Thanks again for reporting the issue.

@matteomazza91
Copy link
Contributor Author

I tested it too, it works also for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants