I'm trying to generate some model objects to use in my Java/Spring Boot application using the following JSON file:
I've included the following in my POM.xml:
<version.swagger.codegen>3.0.10</version.swagger.codegen>
<version.swagger.annotations>2.0.8</version.swagger.annotations>
<plugin>
<groupId>io.swagger.codegen.v3</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>${version.swagger.codegen}</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>src/main/resources/swagger/tmf622/product_ordering_management.json</inputSpec>
<modelPackage>tmf622.v1.model</modelPackage>
<apiPackage>tmf622.v1.api</apiPackage>
<generateModels>true</generateModels>
<generateApis>true</generateApis>
<generateApiTests>true</generateApiTests>
<generateApiDocumentation>true</generateApiDocumentation>
<generateSupportingFiles>true</generateSupportingFiles>
<language>spring</language>
<output>${project.build.directory}/generated-sources/swagger</output>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId>
<version>${version.swagger.annotations}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources/swagger</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
and when i build the application i get the following StackOverflowError:
constituent[47]: file:/C:/Software/apache-maven-3.6.1/lib/wagon-provider-api-3.3.2.jar
---------------------------------------------------
Exception in thread "main" java.lang.StackOverflowError
at org.slf4j.impl.SimpleLogger.debug(SimpleLogger.java:438)
at io.swagger.codegen.v3.generators.examples.ExampleGenerator.resolveSchemaToExample(ExampleGenerator.java:165)
at io.swagger.codegen.v3.generators.examples.ExampleGenerator.resolveSchemaToExample(ExampleGenerator.java:247)
at io.swagger.codegen.v3.generators.examples.ExampleGenerator.resolveSchemaToExample(ExampleGenerator.java:240)
at io.swagger.codegen.v3.generators.examples.ExampleGenerator.resolveSchemaToExample(ExampleGenerator.java:247)
at io.swagger.codegen.v3.generators.examples.ExampleGenerator.resolveSchemaToExample(ExampleGenerator.java:240)
at io.swagger.codegen.v3.generators.examples.ExampleGenerator.resolveSchemaToExample(ExampleGenerator.java:194)
at io.swagger.codegen.v3.generators.examples.ExampleGenerator.resolveSchemaToExample(ExampleGenerator.java:247)
at io.swagger.codegen.v3.generators.examples.ExampleGenerator.resolveSchemaToExample(ExampleGenerator.java:240)
at io.swagger.codegen.v3.generators.examples.ExampleGenerator.resolveSchemaToExample(ExampleGenerator.java:247)
at io.swagger.codegen.v3.generators.examples.ExampleGenerator.resolveSchemaToExample(ExampleGenerator.java:240)
at io.swagger.codegen.v3.generators.examples.ExampleGenerator.resolveSchemaToExample(ExampleGenerator.java:194)
at io.swagger.codegen.v3.generators.examples.ExampleGenerator.resolveSchemaToExample(ExampleGenerator.java:247)
at io.swagger.codegen.v3.generators.examples.ExampleGenerator.resolveSchemaToExample(ExampleGenerator.java:240)
at io.swagger.codegen.v3.generators.examples.ExampleGenerator.resolveSchemaToExample(ExampleGenerator.java:247)
at io.swagger.codegen.v3.generators.examples.ExampleGenerator.resolveSchemaToExample(ExampleGenerator.java:240)
Any ideas on how to fix this?
The issue is caused by recursive schemas in the API definition. It was fixed in Swagger Codegen 3.0.11.