openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

[BUG] AllOf in openapi file causing generator stackoverflow

Open jzendle opened this issue 4 years ago • 3 comments

Bug Report Checklist

  • [ yes] Have you provided a full/minimal spec to reproduce the issue?

attached test.yaml.txt

openapi-generator generate -g java -i test.yaml

  • [ yes] Have you validated the input using an OpenAPI validator (example)?

validated but with circular reference

yes $ openapi-generator --version openapi-generator-cli 6.1.0-SNAPSHOT commit : 5fb40e5 built : 2022-07-15T17:39:40Z source : https://github.com/openapitools/openapi-generator docs : https://openapi-generator.tech/

  • [ ] Have you searched for related issues/PRs?

yes

  • [ ] What's the actual output vs expected output?

actual: stackoverflow

expected: generated code

  • [ ] [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
openapi-generator version

6.0.1 - don't know if its a regression

OpenAPI declaration file content or url

attached

Generation Details

openapi-generator generate -g java -i test.yaml

test.yaml.txt

jzendle avatar Jul 19 '22 15:07 jzendle

The same for: API spec: https://api.hubapi.com/api-catalog-public/v1/apis/marketing/v3/forms Validator: This API is valid, but it cannot be shown because it contains circular references Configuration:

			<plugin>
				<groupId>org.openapitools</groupId>
				<artifactId>openapi-generator-maven-plugin</artifactId>
				<!-- RELEASE_VERSION -->
				<version>6.0.1</version>
				<!-- /RELEASE_VERSION -->
				<executions>
					<execution>
						<goals>
							<goal>generate</goal>
						</goals>
						<configuration>
							<inputSpec>https://api.hubapi.com/api-catalog-public/v1/apis/marketing/v3/forms</inputSpec>
							<generatorName>java</generatorName>
							<configOptions>
								<sourceFolder>src/gen/java/main</sourceFolder>
							</configOptions>
						</configuration>
					</execution>
				</executions>
			</plugin>

Build log:

[...]
constituent[40]: file:/C:/Users/jacek/dev/apache-maven-3.8.6/lib/wagon-provider-api-3.5.1.jar
---------------------------------------------------
Exception in thread "main" java.lang.StackOverflowError
        at java.base/java.lang.StringLatin1.replace(StringLatin1.java:344)
        at java.base/java.lang.String.replace(String.java:2970)
        at org.openapitools.codegen.utils.ModelUtils.getSimpleRef(ModelUtils.java:406)
        at org.openapitools.codegen.utils.ModelUtils.getReferencedSchema(ModelUtils.java:867)
        at org.openapitools.codegen.DefaultCodegen.recursiveGetDiscriminator(DefaultCodegen.java:3074)
        at org.openapitools.codegen.DefaultCodegen.recursiveGetDiscriminator(DefaultCodegen.java:3108)
        at org.openapitools.codegen.DefaultCodegen.recursiveGetDiscriminator(DefaultCodegen.java:3089)
        at org.openapitools.codegen.DefaultCodegen.recursiveGetDiscriminator(DefaultCodegen.java:3108)
        at org.openapitools.codegen.DefaultCodegen.recursiveGetDiscriminator(DefaultCodegen.java:3089)
        at org.openapitools.codegen.DefaultCodegen.recursiveGetDiscriminator(DefaultCodegen.java:3108)
        at org.openapitools.codegen.DefaultCodegen.recursiveGetDiscriminator(DefaultCodegen.java:3089)
[...]

programista-zacny avatar Jul 27 '22 22:07 programista-zacny

I'm having this same issue, is there any workaround to make this work?

dfjmax avatar Jun 29 '23 11:06 dfjmax

Filed https://github.com/OpenAPITools/openapi-generator/pull/16008 to fix it. Added tests

wing328 avatar Jul 05 '23 08:07 wing328