Skip to content
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.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Enum default values do not work in Python when enum is a $ref #18843

Closed
4 of 6 tasks
welshm opened this issue Jun 3, 2024 · 1 comment
Closed
4 of 6 tasks

[BUG] Enum default values do not work in Python when enum is a $ref #18843

welshm opened this issue Jun 3, 2024 · 1 comment

Comments

@welshm
Copy link
Contributor

welshm commented Jun 3, 2024

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
    • Default types should be supported
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

Then using a $ref to refer to an enum (with a default value) the default value is not applied for the Python generators. The default value is applied if it is an inline enum.

openapi-generator version

7.6.0

OpenAPI declaration file content or url
components:
  schemas:
    TestEnum:
      type: string
      enum:
        - ONE
        - TWO
        - THREE
        - foUr
    TestEnumWithDefault:
      type: string
      enum:
        - EIN
        - ZWEI
        - DREI
      default: ZWEI
    TestModel:
      type: object
      required:
        - test_enum
      properties:
        test_enum:
          $ref: "#/components/schemas/TestEnum"
        test_string:
          type: string
          example: "Just some string"
        test_enum_with_default:
          $ref: "#/components/schemas/TestEnumWithDefault"
        test_string_with_default:
          type: string
          example: "More string"
          default: "ahoy matey"
        test_inline_defined_enum_with_default:
          type: string
          enum:
            - A
            - B
            - C
          default: B
Generation Details
Steps to reproduce

Generate Python client or server and look at the generated test_model.py and test_enum_with_default.py

Related issues/PRs

#18796

Suggest a fix

Add better support for default values for Python with respect to enums

#18796

@welshm
Copy link
Contributor Author

welshm commented Jun 11, 2024

Closed by #18796

@welshm welshm closed this as completed Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant