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

Incompatibility with NelmioApiDocBundle #6

Open
kilobyte2007 opened this issue Nov 16, 2020 · 6 comments
Open

Incompatibility with NelmioApiDocBundle #6

kilobyte2007 opened this issue Nov 16, 2020 · 6 comments

Comments

@kilobyte2007
Copy link

Hello, I have an issue when trying to use this package while also using the NelmioApiDocBundle.
I have this configuration:

     * @SWG\Get(
     *     path="/account",
     *     summary="Gets account",
     *     @SWG\Response(
     *         response="200",
     *         description="Returned when successful",
     *         @SWG\Schema(@SWG\Items(ref=@Model(type="App\Entity\Common\Account", groups={"account"})))
     *     )
     * )

and it gives me the following error:

User Warning: [Syntax Error] Expected Doctrine\Common\Annotations\DocLexer::T_CLOSE_PARENTHESIS, got '(' in \App\Controller\Api\AccountController->getAccountAction() in src/Controller/A  
  pi/AccountController.php on line 42:49  

If I understand it correctly, the annotations loader is not understanding the @ Model (which is a NelmioApiDocBundle class) definition. Is there a way to fix this?

@Tobion
Copy link
Owner

Tobion commented Nov 26, 2020

Not sure where the error is coming from. But just based on the swagger spec and annotation library using ref=@Model(type="App\Entity\Common\Account", groups={"account"}) seems invalid. ref must be a string, not an object.
See https://github.com/zircote/swagger-php/blob/fa686e0463203b68d4f497def2a5b3dde4abc8fd/src/Annotations/Schema.php#L23-L27

So this looks like an invalid extension from NelmioApiDocBundle if it's supposed to be like that.
Not sure what OpenAPI-Symfony-Routing library can do here as annotation parsing happens in https://github.com/zircote/swagger-php. Maybe NelmioApiDocBundle uses some custom annotation parsing?

@Tobion
Copy link
Owner

Tobion commented Nov 26, 2020

Seems like it's this class https://github.com/nelmio/NelmioApiDocBundle/blob/master/OpenApiPhp/ModelRegister.php that is handling the ref=@Model annotation. So to be compatible with NelmioApiDocBundle, we could add the class to the annotation analysis in case it exists. Then it shouldn't fail. @kilobyte2007 you want to give it a try and create a PR?

@Tobion
Copy link
Owner

Tobion commented May 20, 2021

@kilobyte2007 are you still interested in solving this?

@kilobyte2007
Copy link
Author

kilobyte2007 commented May 20, 2021

Hey @Tobion. Yes! I have actually given it a try but struggled to understand how all of this works :-(

@mario-fehr
Copy link

@DjordyKoert could you help out here?

@DjordyKoert
Copy link

Hmmm you could have a look at the way NelmioApiDocBundle currently integrates with swagger-php. Maybe that can help you with creating a solution.

https://github.com/nelmio/NelmioApiDocBundle/blob/61c08f139e104db21b12832173b08fa37c22e619/ApiDocGenerator.php#L121-L132

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

4 participants