I'd like to write a @SWG\Definition somewhere and refer to it in the @SWG\Schema in @SWG\Response annotations for multiple REST API actions in my Symfony 3 application. I'm using the dev-master version of Nelmio's api-doc-bundle but I can seem to find anything that suggests where that definition should go. The Swagger-PHP docs urge not repeating if possible and I'd like to follow that recommendation. Any hints?
Asked
Active
Viewed 1,866 times
1 Answers
1
Typical... Finally break down and ask then figure out a solution shortly after...
I found that I can preload the documentation data in Symfony's app/config/config.yml.
nelmio_api_doc:
documentation:
definitios:
Error:
type: object
properties:
success:
type: boolean
example: false
error:
type: string
example: message
Now I can use something like this in all my REST actions
/**
* @API\Operation(
* ...
* @SWG\Response(
* response="default",
* description="Failure",
* @SWG\Schema(ref="#definitions/Error")
* )
* )
*/

Paul Dugas
- 325
- 2
- 14
-
Trouble with this approach is that there doesn't seem to be a way to trigger generation of definitions for entities with @API\Model(). – Paul Dugas Oct 28 '17 at 02:12