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
  • #2966
Closed
Open
Issue created May 21, 2019 by Administrator@rootContributor5 of 5 checklist items completed5/5 checklist items

[BUG][Swift4] StackOverflow when generating example for recursive structures

Created by: lemoinem

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used? master/4.0.0
  • Have you search for related issues/PRs? None found
  • What's the actual output vs expected output? crash vs no crash
Description

If a POST-call gets a recursive structure (e.g., a Tree) as one of its parameter, the swift4 generator crashes when trying to generate example.

openapi-generator version

master/4.0.0 introduced by #2666

OpenAPI declaration file content or url

https://gist.github.com/lemoinem/0b3d7d065d9337a898d5ee2bc49654a2

Command line used for generation

./bin/swift4-petstore.sh while the yaml is stored at modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml

Steps to reproduce
  1. Store yaml attached in gist at modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml
  2. run command ./bin/swift4-petstore.sh => Crash with java.lang.StackOverflowError
Related issues/PRs

This was probably introduced by #2666 which doesn't check for recursive structure when creating an example.

Suggest a fix

At the very least, generating example/self-documentation should be optional and should fail gracefully. At the most, the constructExampleCode method should check for recursive structures (circular references) and fail gracefully in this case.

Assignee
Assign to
Time tracking