laravel-openapi
laravel-openapi copied to clipboard
Suggestion for Responses generated off Laravel Resources
I'm trying to define Responses for my Open API Schema.
In my API, all of my controllers use Laravel Resources to define how models are transformed into responses, and which fields are included. So I have, say, 39 Controllers and 18 Resources.
Currently, I now need to define 18 Responses in Laravel OpenAPI.
However, it seems that if I could alter my UserResource
class, and simply add a trait, use OpenApiResponse
, then I could keep information about my response in the same place.
This would seem to simplify my project, in the same way that every endpoint is defined by a #[OpenApi\Operation(tags: ['User'])]
annotation on the controller, I could simply add some annotations and a trait on my resources.
P.S.: Love this tool, it's helping us out a lot.