我想在某个地方编写一个@SWG\定义,并在@SWG\Response注释中的@SWG\Schema中引用它,用于我的Symfony 3应用程序中的多个REST API操作。我使用的是Nelmio的api-doc-bundle的dev-master版本,但我似乎可以找到任何建议这个定义应该放在哪里的东西。Swagger-PHP文档敦促如果可能的话,不要重复,我想遵循这个建议。有什么提示吗?
发布于 2017-10-28 01:06:22
典型的。最后分解并询问,然后很快找出解决方案……
我发现我可以在Symfony的app/config/config.yml中预加载文档数据。
nelmio_api_doc:
documentation:
definitios:
Error:
type: object
properties:
success:
type: boolean
example: false
error:
type: string
example: message现在我可以在我的所有REST操作中使用类似这样的东西
/**
* @API\Operation(
* ...
* @SWG\Response(
* response="default",
* description="Failure",
* @SWG\Schema(ref="#definitions/Error")
* )
* )
*/https://stackoverflow.com/questions/46979473
复制相似问题