Im using Open Api 3 (exactly NelmioApiDocBundle) in Symfony to document APIs and I have the following code:
* @Route("/login", name="user_login", methods={"POST"})
*
* @OA\Response(
* response=200,
* @OA\JsonContent(
* type="object",
* @OA\Property(property="code", type="number"),
* @OA\Property(property="error", type="boolean"),
* @OA\Property(property="message", type="string")
* )
* )
This works and shows me the following:
What I want to know is if there is an easier way to define these responses so I don't have to write so many lines at each endpoint.
I wish there was a way to define a JSON file as an interface and have it read from there. I've tried a thousand things but nothing works for me and I don't know how to do it and I've already given up.
Thanks a lot!
I have tried to use @Model, @Schema, modify YAML files... etc... I have read the documentation, but I have not seen any valid example for my case in this version of Open Api.