Skip to content

Instantly share code, notes, and snippets.

@atlance
Last active February 19, 2024 13:43
Show Gist options
  • Save atlance/7b03a1cb117de10c7fd2cf829e9cce89 to your computer and use it in GitHub Desktop.
Save atlance/7b03a1cb117de10c7fd2cf829e9cce89 to your computer and use it in GitHub Desktop.

Revisions

  1. atlance renamed this gist May 27, 2022. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. atlance revised this gist May 27, 2022. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions attributes for nelmio api doc
    Original file line number Diff line number Diff line change
    @@ -26,10 +26,9 @@ use Symfony\Component\Routing\Annotation\Route;
    description: 'code 201, example single object.',
    content: new OA\JsonContent(ref: new Model(type: UserIdentity::class, groups: ['full']))
    ),
    // example custom object.
    new OA\Response(
    response: Response::HTTP_ACCEPTED,
    description: 'code 202, object without model.',
    description: 'code 202, example custom object without model.',
    content: new OA\JsonContent(
    type: 'object',
    properties: [
  3. atlance revised this gist May 27, 2022. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion attributes for nelmio api doc
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,6 @@
    declare(strict_types=1);
    // ...
    use OpenApi\Attributes as OA;
    use Symfony\Component\HttpFoundation\Request;
    use Symfony\Component\HttpFoundation\Response;
    use Symfony\Component\Routing\Annotation\Route;

  4. atlance revised this gist May 27, 2022. 1 changed file with 16 additions and 6 deletions.
    22 changes: 16 additions & 6 deletions attributes for nelmio api doc
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,12 @@
    <?php

    declare(strict_types=1);
    // ...
    use OpenApi\Attributes as OA;
    use Symfony\Component\HttpFoundation\Request;
    use Symfony\Component\HttpFoundation\Response;
    use Symfony\Component\Routing\Annotation\Route;

    #[OA\Get(
    tags: ['foo-bar'],
    description: 'Oh Yeah!!!',
    @@ -6,21 +15,22 @@
    ],
    responses: [
    new OA\Response(
    response: 200,
    response: Response::HTTP_OK,
    description: 'code 200, example array of objects.',
    content: new OA\JsonContent(
    type: 'array',
    items: new OA\Items(ref: new Model(type: UserIdentity::class, groups: ['full']))
    )
    ),
    new OA\Response(
    response: 201,
    response: Response::HTTP_CREATED,
    description: 'code 201, example single object.',
    content: new OA\JsonContent(ref: new Model(type: UserIdentity::class, groups: ['full']))
    ),
    // example custom object.
    new OA\Response(
    response: 202,
    description: 'code 202, example custom object without model.',
    response: Response::HTTP_ACCEPTED,
    description: 'code 202, object without model.',
    content: new OA\JsonContent(
    type: 'object',
    properties: [
    @@ -34,8 +44,8 @@
    ]
    )
    ),
    new OA\Response(response: 400, description: 'code 400, sorry =('),
    new OA\Response(response: 500, description: 'code 500, ooops!'),
    new OA\Response(response: Response::HTTP_BAD_REQUEST, description: 'code 400, sorry =('),
    new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: 'code 500, ooops!'),
    ]
    )]
    #[Route(path: '/get/endpoint', name: 'get_endpoint', methods: ['GET'])]
  5. atlance revised this gist May 27, 2022. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions attributes for nelmio api doc
    Original file line number Diff line number Diff line change
    @@ -18,10 +18,9 @@
    description: 'code 201, example single object.',
    content: new OA\JsonContent(ref: new Model(type: UserIdentity::class, groups: ['full']))
    ),
    // example custom object.
    new OA\Response(
    response: 202,
    description: 'code 202, object without model.',
    description: 'code 202, example custom object without model.',
    content: new OA\JsonContent(
    type: 'object',
    properties: [
  6. atlance created this gist May 27, 2022.
    42 changes: 42 additions & 0 deletions attributes for nelmio api doc
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,42 @@
    #[OA\Get(
    tags: ['foo-bar'],
    description: 'Oh Yeah!!!',
    parameters: [
    new OA\Parameter(ref: '#/components/parameters/version'),
    ],
    responses: [
    new OA\Response(
    response: 200,
    description: 'code 200, example array of objects.',
    content: new OA\JsonContent(
    type: 'array',
    items: new OA\Items(ref: new Model(type: UserIdentity::class, groups: ['full']))
    )
    ),
    new OA\Response(
    response: 201,
    description: 'code 201, example single object.',
    content: new OA\JsonContent(ref: new Model(type: UserIdentity::class, groups: ['full']))
    ),
    // example custom object.
    new OA\Response(
    response: 202,
    description: 'code 202, object without model.',
    content: new OA\JsonContent(
    type: 'object',
    properties: [
    new OA\Property(property: 'foo', type: 'string'),
    new OA\Property(property: 'bar', type: 'integer'),
    new OA\Property(
    property: 'baz',
    type: 'array',
    items: new OA\Items(ref: new Model(type: UserIdentity::class, groups: ['full']))
    ),
    ]
    )
    ),
    new OA\Response(response: 400, description: 'code 400, sorry =('),
    new OA\Response(response: 500, description: 'code 500, ooops!'),
    ]
    )]
    #[Route(path: '/get/endpoint', name: 'get_endpoint', methods: ['GET'])]