Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redundant @context field in OpenAPI for embedded JSON+LD resources #6321

Open
radoslawmaleckigwd opened this issue Apr 17, 2024 · 0 comments

Comments

@radoslawmaleckigwd
Copy link

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"
    }
  ]
}
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

No branches or pull requests

1 participant