I am writing an OpenAPI spec and trying to generate my possible query parameters automatically (using swagger-php) from the annotations for a request route/path. I know that I can just type out all possible parameter options for each route, but I really need to be able to generate the possible parameters from the properties of a class automatically using annotations like I can do for the request body. (We will have tons of classes/paths and keeping it up to date most likely won't happen unless they are generated like the request body/JsonContent can be. Is this possible with swagger-php or even OpenAPI in general?
I got this to work with the put and the request body, but how do I do it for a get request that still uses the properties of the class?
I can do this for the request body:
/**
* @return Response
*
* * @OA\Put(
* path="/persons",
* tags={"Person"},
* @OA\RequestBody(
* request="person",
* required=false,
* description="Optional Request Parameters for Querying",
* @OA\JsonContent(ref="#/components/schemas/Person")
* ),
* @OA\Response(
* response="200",
* description="Returns matching Person Object",
* @OA\JsonContent(
* type="array",
* @OA\Items(ref="#/components/schemas/Person")
* )
* )
* )
*/
Writing out each parameter for 30+ classes will not be maintainable:
/** @OA\Get(
* path="/events",
* tags={"Events"},
* @OA\Parameter(
* name="eventID",
* in="query",
* required=false,
* description="The event ID specific to this event",
* @OA\Schema(
* type="string"
* ),
* ),
*
* ....etc