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
Hey! It would be awesome if dedoc/scramble could add first-class support for Laravel's JSON:API Resource (added in 12.45, see laravel/framework#57571).
What this changes for users
Instead of extending JsonResource, you now extend JsonApiResource (use Illuminate\Http\Resources\JsonApi\JsonApiResource;).
Docs still generate (since JsonApiResource extends JsonResource), but scramble treats it and collections as classic Laravel resources, not JSON:API.
Relationships aren't included by default in responses; you must specify ?include=... as in /users/11?include=posts,teams and expose the relationships manually in your resource.
What's needed
Detect when a JsonApiResource (and its AnonymousResourceCollection) is being used, not just treating it as a JsonResource.
Generate OpenAPI/schema output per the JSON:API spec (including type, id, attributes, relationships, included, and jsonapi object support, not just classic resource fields).
Prefer outputting the correct Content-Type:application/vnd.api+json for endpoints that use these resources.
Include docs notes about the lack of lazy relationship loading and how to add included resources, since devs have to opt in with ?include=.
Bonus: If a user globally configures JsonApiResource::configure(version: ...), reflect the correct version and config in generated docs.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hey! It would be awesome if dedoc/scramble could add first-class support for Laravel's JSON:API Resource (added in 12.45, see laravel/framework#57571).
What this changes for users
JsonResource, you now extendJsonApiResource(use Illuminate\Http\Resources\JsonApi\JsonApiResource;).?include=...as in/users/11?include=posts,teamsand expose the relationships manually in your resource.What's needed
type,id,attributes,relationships,included, andjsonapiobject support, not just classic resource fields).application/vnd.api+jsonfor endpoints that use these resources.?include=.JsonApiResource::configure(version: ...), reflect the correct version and config in generated docs.References
Thanks for considering!
Beta Was this translation helpful? Give feedback.
All reactions