Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Yur-ok opened this issue Aug 2, 2023 · 1 comment
Open

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

Yur-ok opened this issue Aug 2, 2023 · 1 comment

Comments

@Yur-ok
Copy link

Yur-ok commented Aug 2, 2023

Hi!
I'm trying to get behavior like in pure swagger-php (zircote/swagger-php#788).

What I did:

  • create dir 'refs' in project structure
  • inside this folder I create class OpenApiSpec.php with next content
<?php

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 it should work.
What am I doing wrong?

PS:
Symfony 6.2
NelmioApiDocBundle 4.11

@DjordyKoert
Copy link
Collaborator

I think this is related to #2139

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants