How to create a Model / Example section for a GET request in Swagger

I am interested in creating a Model / Example section for my GET request using Swagger. The link in the official example shows that the section is excellent.

In official documents, it is created using the existing model:

     *     @SWG\Schema(ref="#/definitions/User")

I do not have such an option, because my properties are generated by REST.

I tried as follows:

/**
 * @SWG\Get(
...
 *     @SWG\Response(
 *         response="200",
 *         description="Ok",
 *         @SWG\Schema(
 *             type="array",
 *             @SWG\Property(property="firstname", type="string", example="Steven")
 *         ),
 *     ),
 * )
 */

It does not work and answers:

fetching resource list: http://localhost/dist/swagger.json; Please wait.

Any help is greatly appreciated. Thanks in advance.

+4
source share
1 answer

GET /pet/findByStatusgenerated in one example:
github.com/zircote/swagger-php/.../Examples/petstore.swagger.io/controllers/PetController.php

, , , array, .

, @SWG\Items:

...
 *         @SWG\Schema(
 *             type="array",
 *             @SWG\Items(
 *                 type="object",
 *                 @SWG\Property(property="firstname", type="string", example="Steven")
 *             )
 *         ),
...
+4

All Articles