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
API Platform version(s) affected: 2.5.6 and master
Description
API Platform has great handling of different normalization contexts per operation, able to handle complex combinations of serialization groups across many nested objects, and still produce a perfect set of OpenAPI schemas (which can then be used to e.g. generate client-side scaffolding). However, this breaks down on Subresources (annotated with @ApiSubresource).
If I have a subresource with its own normalization context:
...then I would expect it (Review:Subresource) to be used for the OpenAPI docs. But unfortunately it's completely ignored, and the OpenAPI docs just use the default normalization context (in this case Review:Default, but would just be Symfony's default if that wasn't specified), even if that's completely different from what the endpoint actually returns.
The /books/{id}/reviews endpoint returns the correct data when called (just the id and rating, as specified by Review:Subresource), but the OpenAPI docs are completely overpromising every field from Review:Default.
Additional Context
I've tried this on 2.5.6, and on master with OpenApi v3 refactor #3407 merged, but the problem seems present on both.
In this example, no schema for Review:Subresource is generated at all, so it's not just a case of just the wrong schema being assigned to the operation - makes it very difficult to work around as potentially the fields from Review:Subresource are never exposed anywhere.
API Platform version(s) affected: 2.5.6 and master
Description
API Platform has great handling of different normalization contexts per operation, able to handle complex combinations of serialization groups across many nested objects, and still produce a perfect set of OpenAPI schemas (which can then be used to e.g. generate client-side scaffolding). However, this breaks down on Subresources (annotated with
@ApiSubresource).If I have a subresource with its own normalization context:
...then I would expect it (
Review:Subresource) to be used for the OpenAPI docs. But unfortunately it's completely ignored, and the OpenAPI docs just use the default normalization context (in this caseReview:Default, but would just be Symfony's default if that wasn't specified), even if that's completely different from what the endpoint actually returns.How to reproduce
I've created a reproduction here:
https://github.com/jamesisaac/openapi-bugs
Once running, OpenAPI docs are visible at http://localhost:8000 or http://localhost:8000/docs.json
The
/books/{id}/reviewsendpoint returns the correct data when called (just theidandrating, as specified byReview:Subresource), but the OpenAPI docs are completely overpromising every field fromReview:Default.Additional Context
Review:Subresourceis generated at all, so it's not just a case of just the wrong schema being assigned to the operation - makes it very difficult to work around as potentially the fields fromReview:Subresourceare never exposed anywhere.cc @soyuka