You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 949b014
Browse filesBrowse the repository at this point in the historyBrowse files
fix(metadata): derive schema and cast from enum nativeType (#8871)
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#8686Fixes#8816
if (!($nativeType = $parameter->getNativeType()) || !($enumType = ValueCaster::resolveEnumType($nativeType))) {
410
+
return$parameter;
411
+
}
412
+
413
+
if (!$enumTypeinstanceof BackedEnumType) {
414
+
thrownewRuntimeException(\sprintf('The parameter "%s" declares the enum "%s" as native type, only backed enums are supported.', $parameter->getKey(), $enumType->getClassName()));
use ApiPlatform\Tests\Fixtures\TestBundle\Entity\Issue7126\StringBackedEnum;
129
+
use Symfony\Component\TypeInfo\TypeIdentifier;
130
+
use Symfony\Component\TypeInfo\Type\BackedEnumType;
131
+
use Symfony\Component\TypeInfo\Type\BuiltinType;
132
+
use ApiPlatform\Metadata\ApiResource;
133
+
134
+
#[ApiResource(parameters: ['status' => new QueryParameter(filter: new ExactFilter(), nativeType: new BackedEnumType(StringBackedEnum::class, new BuiltinType(TypeIdentifier::STRING)), castToNativeType: true)])]
0 commit comments