-
-
Notifications
You must be signed in to change notification settings - Fork 969
Open
Description
API Platform version(s) affected: 2.6.8
Description
Entity fields typed with PHP 8.1 enums are incorrectly displayed on swagger.
Default display:
public FooEnum $bar;
"bar": { "@context": "string", "@id": "string", "@type": "string" },
Display with ApiProperty attribute:
Attribute:
#[ApiProperty(
attributes: [
'openapi_context' => [
'type' => 'string',
'enum' => [
FooEnum::FOO,
FooEnum::BAR,
],
],
],
)]
schema:
[ OrderedMap { "name": "FOO", "value": "FOO" }, OrderedMap { "name": "BAR", "value": "BAR" }]
This approach with the ApiProperty attribute is much better than the first.
5BB5
It gives some information at least. But it's really confusing. Is there a better approach or am I missing something? According to OpenAPI specification enums should display as array:
https://swagger.io/docs/specification/data-models/enums/
How to reproduce
- Make entity with field type of enum.
- Add API platform attributes, serialization groups etc.
- Add serialization group to field type of enum.
- Check swagger schema and example value on resource you just created.
Possible Solution
I don't know.
stvnwrgs
Metadata
Metadata
Assignees
Labels
No labels