Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #4650
Closed
Open
Issue created Nov 29, 2019 by Administrator@rootContributor0 of 3 checklist items completed0/3 checklist items

[BUG] StackOverflowError in DefaultCodegen.addProperties when a schemas with same name are referenced directly and indirectly

Created by: ivo500

Bug Report Checklist

  • [Y ] Have you provided a full/minimal spec to reproduce the issue?
  • [ Y] Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used? 4.2.1
  • [Y ] Have you search for related issues/PRs?
  • What's the actual output vs expected output? java.lang.StackOverflowError, expected Sring generated project
  • [Optional] Bounty to sponsor the fix (example)
Description

When trying to generate spring project from a complex .yaml file setup a java.lang.StackOverflowError is thrown.

The setup is the following:

Base.yaml contains a definition of Test Blue.yaml contains a definition of Test which inherits with Allof from Base.yaml->Test Green.yaml also contains a definition of Test which inherits with Allof from Base.yaml->Test and also it has a reference to Blue.yaml->Test

When generation is started for Green.yaml , DefaultCodegen.addProperties causes stack overflow.

Generator first loads the Base.yaml->Test reference in its cache. The problem happens when the generator starts processing the Blue.yaml->Test reference in Green.yaml. It loads the Blue.yaml->Test but wrongly overrides the Base.yaml->Test in its cache. Blue.yaml->Test is inheriting from Base.yaml->Test but now after the override Blue.yaml->Test inherits from itself and becomes corrupt!!!!!!!!!. After this when DefaultCodegen.addProperties starts its work it goes into endless recursion trying to process the corrupted self referencing Blue.yaml->Test .

See the stack trace below:

[main] INFO o.o.codegen.DefaultGenerator - OpenAPI Generator: spring (server) [main] INFO o.o.codegen.DefaultGenerator - Generator 'spring' is considered stable. [main] INFO o.o.codegen.languages.SpringCodegen - ---------------------------------- [main] INFO o.o.c.languages.AbstractJavaCodegen - Environment variable JAVA_POST_PROCESS_FILE not defined so the Java code may not be properly formatted. To define it, try 'export JAVA_POST_PROCESS_FILE="/usr/local/bin/clang-format -i"' (Linux/Mac) [main] INFO o.o.c.languages.AbstractJavaCodegen - NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to true (--enable-post-process-file for CLI). [main] INFO o.o.c.languages.AbstractJavaCodegen - Processing operation test [main] INFO o.o.c.languages.AbstractJavaCodegen - Processing operation inbox_storeTaskResponse Exception in thread "main" java.lang.StackOverflowError at org.apache.commons.lang3.StringUtils.isNotBlank(StringUtils.java:327) at org.openapitools.codegen.DefaultCodegen.addProperties(DefaultCodegen.java:2020) at org.openapitools.codegen.DefaultCodegen.addProperties(DefaultCodegen.java:2002) at org.openapitools.codegen.DefaultCodegen.addProperties(DefaultCodegen.java:2022) at org.openapitools.codegen.DefaultCodegen.addProperties(DefaultCodegen.java:2002) at org.openapitools.codegen.DefaultCodegen.addProperties(DefaultCodegen.java:2022) at org.openapitools.codegen.DefaultCodegen.addProperties(DefaultCodegen.java:2002) at org.openapitools.codegen.DefaultCodegen.addProperties(DefaultCodegen.java:2022) at org.openapitools.codegen.DefaultCodegen.addProperties(DefaultCodegen.java:2002) at org.openapitools.codegen.DefaultCodegen.addProperties(DefaultCodegen.java:2022) at org.openapitools.codegen.DefaultCodegen.addProperties(DefaultCodegen.java:2002)

openapi-generator version

4.2.1

OpenAPI declaration file content or url
Command line used for generation

openapi-generator generate -i task-test.yaml -g spring -o test

Steps to reproduce
Related issues/PRs
Suggest a fix

The problem seem to be that when loading a second ref .yaml file which contains schemas with the same name as a component from the other first ref.yaml file. The second component overrides the first component.

Assignee
Assign to
Time tracking