Skip to content

fix(metadata): derive schema and cast from enum nativeType - #8871

Merged
soyuka merged 1 commit into
api-platform:5.0from
soyuka:fix/parameter-enum-native-type
Nov 24, 2026
Merged

soyuka merged 1 commit into
api-platform:5.0from
soyuka:fix/parameter-enum-native-type

Conversation

@soyuka

@soyuka soyuka commented Nov 24, 2026

Copy link
Copy Markdown
Member
Q A
Branch? 5.0
Tickets Closes #8686, closes #8816, supersedes #8858
License MIT
Doc PR

BackedEnumFilter is deprecated in favor of ExactFilter declared with a backed-enum nativeType, but that nativeType did nothing: no enum in the schema, no validation, no cast.

new QueryParameter(filter: new ExactFilter(), property: 'status', nativeType: new BackedEnumType(Status::class, new BuiltinType(TypeIdentifier::STRING)))

now gives {type, enum} in the schema (array of it for a list of enums), casts the value to the enum, and an unknown case is a 422. A hand-written schema still wins over the derived one. Pure enums throw at build time.

The upgrade command now emits that BackedEnumType for BackedEnumFilter instead of a scalar BuiltinType.

We went with nativeType instead of a new enumClass argument (#8858): it already carries the backing type and list-ness, and it's what the deprecation message points to.

BackedEnumFilter is deprecated in favor of ExactFilter with a
backed-enum nativeType, but that nativeType produced no enum schema,
no validation and no cast. The upgrade command also emitted a scalar
BuiltinType for BackedEnumFilter, losing the enum.

Fixes api-platform#8686
Fixes api-platform#8816
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.

1 participant