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
  • #1991
Closed
Open
Issue created Jan 26, 2019 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[BUG] [Python] $ref references to non-object types not working correctly

Created by: spacether

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?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

When looking at the swagger2.0 sample spec, the #/definitions/OuterEnum defines a string with enum examples. When it is used in other models, the parameters that refer to OuterEnum with $ref incorrectly list themselves as model parameters and do not include the correct enum options.

openapi-generator version

4.0.0-SNAPSHOT

OpenAPI declaration file content or url

https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml

definitions:
  OuterEnum:
    type: string
    enum:
    - "placed"
    - "approved"
    - "delivered"
  Enum_Test:
    type: object
    required:
      - enum_string_required
    properties:
      enum_string:
        type: string
        enum:
          - UPPER
          - lower
          - ''
      enum_string_required:
        type: string
        enum:
          - UPPER
          - lower
          - ''
      enum_integer:
        type: integer
        format: int32
        enum:
          - 1
          - -1
      enum_number:
        type: number
        format: double
        enum:
          - 1.1
          - -1.2
      outerEnum:
        $ref: '#/definitions/OuterEnum'
Command line used for generation

java -DdebugModels -jar /Users/justin/programming/openapi/fork_mine/openapi-generator/modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -t modules/openapi-generator/src/main/resources/python -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g python -o samples/client/petstore/python -DpackageName=petstore_api

Steps to reproduce
  1. Run the above debugging for the models
  2. Inspect the OuterEnum model result, its dataType='str'
  3. Inspect the Enum_Test OuterEnum parameter, isModel is true and none of the enum values have been connected in
Related issues/PRs
  • https://github.com/OpenAPITools/openapi-generator/issues/1627
  • https://github.com/OpenAPITools/openapi-generator/issues/1990
  • https://github.com/OpenAPITools/openapi-generator/issues/1981
  • https://github.com/OpenAPITools/openapi-generator/issues/1927
Suggest a fix

For models where datatype is not object, we should:

  • Convert them to codegen parameters
  • Put them where they belong
  • Remove the source models from the final models list
Assignee
Assign to
Time tracking