OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
[ ] [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
Bug Report Checklist
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
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
https://github.com/OpenAPITools/openapi-generator/pull/18796
Suggest a fix
Add better support for default values for Python with respect to enums
https://github.com/OpenAPITools/openapi-generator/pull/18796