【问题标题】:API Platform - how to document authentication routesAPI 平台 - 如何记录身份验证路由
【发布时间】:2018-04-22 15:11:11
【问题描述】:
【问题讨论】:
标签:
symfony
swagger
openapi
api-platform.com
【解决方案1】:
感谢this comment in a Github issue,我找到了答案。由于我使用 YAML 进行资源配置,因此我必须翻译 auth/login 端点的示例;
App\Entity\User:
collectionOperations:
auth:
route_name: auth
swagger_context:
parameters:
-
name: username
required: true
type: string
description: "User's username or email address"
-
name: password
required: true
type: string
description: "User's password"
responses:
200:
description: "Successful login attempt, returning a new token"
schema:
type: object
required:
- username
- password
properties:
username:
type: string
password:
type: string
summary: Performs a login attempt, returning a valid token on success
consumes:
- "application/json"
- "application/ld-json"
produces:
- "application/ld-json"
【解决方案2】:
更新:openapi/swagger v3 的 openapi_contex 而不是 swagger_contex。