我找到了一种方法,可以使用NelmioApiDocBundle(4.x(为/API/login_check和/API/token/refresh生成API文档
我的项目是一个带有Symfony 5.1的API REST。
这是我的路线。yaml:
api_login_check:
path: /api/login_check
methods: POST
gesdinet_jwt_refresh_token:
path: /api/token/refresh
controller: gesdinet.jwtrefreshtoken::refresh
methods: POST`
和我的config/packages/nelmio_api_doc.yaml:
nelmio_api_doc:
models: { use_jms: false }
documentation:
info:
title: BileMoAPI
description: This is an awesome API REST for BileMo!
version: 1.0.0
components:
securitySchemes:
Bearer:
type: http
scheme: bearer
bearerFormat: JWT
in: header
security:
- Bearer: []
paths:
/api/login_check:
post:
tags:
- Login
summary: Login into the api.
requestBody:
content:
application/json:
schema:
properties:
username:
type: string
password:
type: string
type: object
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
properties:
token:
type: string
refresh_token:
type: string
'401':
description: Invalid credentials
'400':
description: Invalid JSON.
security: []
/api/token/refresh:
post:
tags:
- Login
summary: Login into the api by refresh token.
requestBody:
content:
application/json:
schema:
properties:
refresh_token:
type: string
type: object
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
properties:
token:
type: string
refresh_token:
type: string
'401':
description: An authentication exception occurred.
security: []
areas: # to filter documented areas
path_patterns:
- ^/api(?!(/doc|/doc.json|/token/refresh)$)
#host_patterns:
# - ^/api
/api/doc的截图:/api/doc 的屏幕截图
我希望能帮助别人:(
答案在问题中(对不起,我是Stack的新手(