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
  • #4885
Closed
Open
Issue created Dec 29, 2019 by Administrator@rootContributor

[Python] Recursive/Cyclic definitions cause import error in Python-experimental

Created by: eak24

The problem is that with the changes to have the class property types used directly, circular type referencing or recursive definitions doesn't seem to work anymore:

OpenAPI declaration file content or url
components:
  schemas:
    Dog:
      properties:
        enemy:
          type: object
          $ref: '#/components/schemas/Dog'

This should be a valid spec, but the generated python attempts to reference the Dog class in the definition of the Dog class - which clearly doesn't work. This causes a circular import. This looks to be a regression from just the plain python generator - which uses strings to define openApi types. What are your thoughts on this?

Command line used for generation

Normal generation for python-experimental using any spec which has a circular reference.

Steps to reproduce

Make a spec with a circular reference, run the python-experimental generator, attempt to use the client, and you'll get an import error.

Related issues/PRs

This started happening with #4446 .

Suggest a fix

@spacether suggested simply storing a model's parameter types as a class method rather than a dict. Then they will not be loaded at module load time.

Assignee
Assign to
Time tracking