You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[BUG][JAVA (potentially all langs)] StackOverflowException with combination of allOf oneOf without explicit declaration of discriminator property in "properties"
#15298
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.
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Previously related issue #8468 is actually fixed since version 6.0.0 but only if discriminator property is defined in "properties" explicitly. If the discriminator property definition is provided only in "discriminator"."propertyName" without any other information in "properties" then it leads to StackOverflowException during schemas introspection. The information should contain values of discriminator property or, at least, just an explicit declaration of the property. An example YAML in #8468 is completely covered the correct case without StackOverflowException.
But YAML without values of a discriminator property or even without declaration of discriminator property in "properties" is a valid OpenAPI specification (according to https://apitools.dev/swagger-parser/online/).
StackTrace without values of discriminator property or without declaration of discriminator property:
java.lang.StackOverflowError
at java.util.regex.Pattern.error(Pattern.java:1969)
at java.util.regex.Pattern.<init>(Pattern.java:1354)
at java.util.regex.Pattern.compile(Pattern.java:1054)
at java.lang.String.replace(String.java:2239)
at org.openapitools.codegen.utils.ModelUtils.getSimpleRef(ModelUtils.java:401)
at org.openapitools.codegen.utils.ModelUtils.getReferencedSchema(ModelUtils.java:802)
at org.openapitools.codegen.DefaultCodegen.discriminatorFound(DefaultCodegen.java:3173)
at org.openapitools.codegen.DefaultCodegen.discriminatorFound(DefaultCodegen.java:3206)
at org.openapitools.codegen.DefaultCodegen.discriminatorFound(DefaultCodegen.java:3195)
at org.openapitools.codegen.DefaultCodegen.discriminatorFound(DefaultCodegen.java:3206)
at org.openapitools.codegen.DefaultCodegen.discriminatorFound(DefaultCodegen.java:3195)
at org.openapitools.codegen.DefaultCodegen.discriminatorFound(DefaultCodegen.java:3206)
at org.openapitools.codegen.DefaultCodegen.discriminatorFound(DefaultCodegen.java:3195)
openapi-generator version
Using generator versions from 6.0.0 to 6.5.0. Also the master branch version.
Either remember visited schemas in disciminatorFound recursive method or add the demand of declaration discriminator property in "properties" with error log level.
bear43
changed the title
[BUG][JAVA (potentially all langs)]
[BUG][JAVA (potentially all langs)] StackOverflowException with combination of allOf oneOf without explicit declaration of discriminator property in "properties"
Apr 24, 2023
bear43
added a commit
to bear43/openapi-generator
that referenced
this issue
May 16, 2023
Bug Report Checklist
Description
Previously related issue #8468 is actually fixed since version 6.0.0 but only if discriminator property is defined in "properties" explicitly. If the discriminator property definition is provided only in "discriminator"."propertyName" without any other information in "properties" then it leads to StackOverflowException during schemas introspection. The information should contain values of discriminator property or, at least, just an explicit declaration of the property. An example YAML in #8468 is completely covered the correct case without StackOverflowException.
But YAML without values of a discriminator property or even without declaration of discriminator property in "properties" is a valid OpenAPI specification (according to https://apitools.dev/swagger-parser/online/).
StackTrace without values of discriminator property or without declaration of discriminator property:
openapi-generator version
Using generator versions from 6.0.0 to 6.5.0. Also the master branch version.
OpenAPI declaration file content or url
Generation Details
Steps to reproduce
calling "mvn clean compile" will cause the generation failure.
Related issues/PRs
Bug issue #8468
Suggest a fix
Either remember visited schemas in disciminatorFound recursive method or add the demand of declaration discriminator property in "properties" with error log level.
The text was updated successfully, but these errors were encountered: