Skip to content

feat(openapi): add openapi.include_null_in_nullable_enum option to control null in nullable enum schemas - #8467

Closed
j-bak-web-sl wants to merge 1 commit into
api-platform:mainfrom
j-bak-web-sl:feat(openapi)-add-openapi.include_null_in_nullable_enum-configuration-option
Closed

feat(openapi): add openapi.include_null_in_nullable_enum option to control null in nullable enum schemas#8467
j-bak-web-sl wants to merge 1 commit into
api-platform:mainfrom
j-bak-web-sl:feat(openapi)-add-openapi.include_null_in_nullable_enum-configuration-option

Conversation

@j-bak-web-sl

@j-bak-web-sl j-bak-web-sl commented Aug 18, 2026

Copy link
Copy Markdown

Add a new boolean configuration option api_platform.openapi.include_null_in_nullable_enum (default: true) that controls whether null is appended to the enum array for nullable enum properties in the generated JSON Schema.

Previously, for a property typed ?BackedEnum, the schema always produced:
{ "type": ["integer", "null"], "enum": [1, 2, null] }

With include_null_in_nullable_enum: false, null is omitted from the enum values:
{ "type": ["integer", "null"], "enum": [1, 2] }

This is useful when targeting validators or tools that treat enum as an exhaustive allowlist and do not expect null to appear there explicitly, even though the type already expresses nullability.

Q A
Branch? 4.3.17, 3.1.29
Tickets Closes #8466
License MIT
Doc PR TODO

…control null in nullable enum schemas

Add a new boolean configuration option `api_platform.openapi.include_null_in_nullable_enum`
(default: `true`) that controls whether `null` is appended to the `enum` array for nullable
enum properties in the generated JSON Schema.

Previously, for a property typed `?BackedEnum`, the schema always produced:
  { "type": ["integer", "null"], "enum": [1, 2, null] }

With `include_null_in_nullable_enum: false`, null is omitted from the enum values:
  { "type": ["integer", "null"], "enum": [1, 2] }

This is useful when targeting validators or tools that treat `enum` as an exhaustive
allowlist and do not expect `null` to appear there explicitly, even though the type
already expresses nullability.
@j-bak-web-sl

Copy link
Copy Markdown
Author

closing the PR, as it is was a misunderstanding with openapi3.1 documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Openapi: Nullable enum adds null value in the enum cases

1 participant