Conversation
| * @see https://schema.org/Review | ||
| */ | ||
| #[ApiResource( | ||
| uriTemplate: '/admin/reviews{._format}', |
There was a problem hiding this comment.
Not sure it's useful as uriTemplate option is overriden in every operation of this ApiResource.
| ] | ||
| )] | ||
| #[ApiResource( | ||
| shortName: 'Book', |
There was a problem hiding this comment.
I would remove this option to let API Platform specify it automatically by default, and see if it works (or not)!
| ] | ||
| )] | ||
| #[ApiResource( | ||
| shortName: 'Review', |
There was a problem hiding this comment.
Same: I would remove it to let API Platform automatically specify it and see if it works or breaks anything
| ] | ||
| )] | ||
| #[ApiResource( | ||
| shortName: 'User', |
There was a problem hiding this comment.
Same: I would remove this option to let API Platform define it automatically, and see if it works or breaks
| "readOnly": true, | ||
| "type": "string", | ||
| "pattern": "^/contexts/Book$" | ||
| "pattern": "^/contexts/AdminBook$" |
There was a problem hiding this comment.
Should be Book as it's not related to the admin
| "readOnly": true, | ||
| "type": "string", | ||
| "pattern": "^/contexts/Book$" | ||
| "pattern": "^/contexts/AdminBook$" |
There was a problem hiding this comment.
Should be Book as it's not related to the admin
| "readOnly": true, | ||
| "type": "string", | ||
| "pattern": "^/contexts/Review$" | ||
| "pattern": "^/contexts/AdminReview$" |
There was a problem hiding this comment.
Should be Review as it's not related to the admin
| "readOnly": true, | ||
| "type": "string", | ||
| "pattern": "^/contexts/Review$" | ||
| "pattern": "^/contexts/AdminReview$" |
There was a problem hiding this comment.
Should be Review as it's not related to the admin
|
|
||
| ###> nelmio/cors-bundle ### | ||
| CORS_ALLOW_ORIGIN='^https?://(localhost|127\.0\.0\.1)(:[0-9]+)?$' | ||
| CORS_ALLOW_ORIGIN='^https?://(localhost|127\.0\.0\.1)(:[0-9]+)?$|^https://api-platform\.github\.io$' |
There was a problem hiding this comment.
Should be in your .env.local file insead 😉
This PR demonstrates an issue and potential solution when using multiple
#[ApiResource]attributes on a single entity with different URI templates.When a resource class has multiple
#[ApiResource]declarations with different URI templates (e.g.,/admin/multi_route_booksand/multi_route_books), the client generator only generates types for the resource that appears in the JSON-LD entrypoint, typically missing the other routes.Example:
Using 2 different shortName will do the trick, api-platform/core#7746 will fix the behavior (as without the patch this won't work).
We'll also add an automatic way of handling this inside API Platform so this PR may not be needed in the end (for now its just a showcase).
We also need to test that @api-platform/admin is still working.