OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
[ ] [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Generating java code (applies to another languages too) based on a model with recursivly build components ends in a StackOverflowError if the option is used for generating only noted components and the children of these components:
Exception in thread "main" java.lang.StackOverflowError
at com.fasterxml.jackson.databind.JsonMappingException.prependPath(JsonMappingException.java:455)
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:788)
at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:183)
at io.swagger.v3.core.jackson.SchemaSerializer.serialize(SchemaSerializer.java:41)
at io.swagger.v3.core.jackson.SchemaSerializer.serialize(SchemaSerializer.java:13)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(DefaultSerializerProvider.java:502)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:341)
at com.fasterxml.jackson.databind.ObjectWriter$Prefetch.serialize(ObjectWriter.java:1574)
at com.fasterxml.jackson.databind.ObjectWriter._writeValueAndClose(ObjectWriter.java:1275)
at com.fasterxml.jackson.databind.ObjectWriter.writeValueAsString(ObjectWriter.java:1140)
at io.swagger.v3.core.util.Json.pretty(Json.java:24)
at org.openapitools.codegen.DefaultCodegen.fromModel(DefaultCodegen.java:3007)
at org.openapitools.codegen.languages.AbstractJavaCodegen.fromModel(AbstractJavaCodegen.java:1651)
at org.openapitools.codegen.languages.SpringCodegen.fromModel(SpringCodegen.java:959)
at org.openapitools.codegen.DefaultGenerator.processModels(DefaultGenerator.java:1757)
at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:525)
at org.openapitools.codegen.DefaultGenerator.generateModelsForVariable(DefaultGenerator.java:614)
at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:546)
at org.openapitools.codegen.DefaultGenerator.generateModelsForVariable(DefaultGenerator.java:614)
at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:546)
at org.openapitools.codegen.DefaultGenerator.generateModelsForVariable(DefaultGenerator.java:614)
Steps to reproduce
Related issues/PRs
Suggest a fix
The DefaultGenerator is to fix to suppress the endless recursion
after line 468 should the "name" be added to the list of processedModells, so the check for in the line 546 will works and doesn't exceute recursion.
Bug Report Checklist
Description
Generating java code (applies to another languages too) based on a model with recursivly build components ends in a StackOverflowError if the option is used for generating only noted components and the children of these components:
openapi-generator version
the bug is since version 7.6.0
OpenAPI declaration file content or url
example.json pom.xml
Generation Details
mvn clean install
Steps to reproduce
Related issues/PRs
Suggest a fix
The DefaultGenerator is to fix to suppress the endless recursion after line 468 should the "name" be added to the list of processedModells, so the check for in the line 546 will works and doesn't exceute recursion.
I provide the bugfix in the next day(s).