nelmio / NelmioApiDocBundle

Generates documentation for your REST API from annotations
MIT License
2.23k stars 833 forks source link

How possible use '#/components/.../' section ? #2123

Open Yur-ok opened 1 year ago

Yur-ok commented 1 year ago

Hi! I'm trying to get behavior like in pure swagger-php (https://github.com/zircote/swagger-php/issues/788).

What I did:

namespace App\Openapi;

use OpenApi\Attributes as OA; use Symfony\Component\PropertyInfo\Type;

class OpenApiSpec {

}

[OA\Response(

response: 'create',
description: 'Info about Rule',
content: new OA\JsonContent(
    .....some description here.....
    type: Type::BUILTIN_TYPE_OBJECT
)

)] class RuleResponse{}


Then I use it in controller like this

[OA\Response(ref: '#/components/responses/create', response: 201]


But I always get errors like 

User Warning: $ref "#/components/responses/create" not found for @OA\Response() in \App\Controller\RuleController->create() in /var/www/app/src/Controller/RuleController.php



But according to swagger-php [examples](https://github.com/zircote/swagger-php/tree/master/Examples/using-refs) it should work.
What am I doing wrong?

PS:
Symfony 6.2
NelmioApiDocBundle 4.11
DjordyKoert commented 11 months ago

I think this is related to https://github.com/nelmio/NelmioApiDocBundle/issues/2139