core
core copied to clipboard
Redundant @context field in OpenAPI for embedded JSON+LD resources
API Platform version(s) affected: 3.2.20
Description
When generating OpenAPI documentation for APIs that include embedded resources, the generated file includes a @context field also for embeded resources. However, in practice, it seems that this field is redundant for embedded resources. Response does not contain this field, so there is a mismatch between OpenAPI documentation and returned response.
How to reproduce
Create a resource with embedded subresource and compare the returned response with OpenAPI documentation response declaration.
Possible Solution
Remove @context field from embedded resources from OpenApi documentation.
Example OpenAPI documentation for response:
{
"@context": "string",
"@id": "string",
"@type": "string",
"code": "FOO",
"name": "string",
"attributes": [
{
"@context": "string",
"@id": "string",
"@type": "string",
"code": "BAR",
"name": "string"
}
]
}
Returned response:
{
"@context": "/api/contexts/Item",
"@id": "/api/v1/items/FOO",
"@type": "Item",
"code": "FOO",
"name": "Lorem ipsum",
"attributes": [
{
"@id": "/api/v1/attributes/BAR",
"@type": "Attribute",
"code": "BAR",
"name": "Lorem ipsum"
}
]
}