我找到了一种用NelmioApiDocBundle(4.x)生成/ API /login_check和/api/token/刷新的api文档的方法。
我的项目是使用Symfony 5.1的API REST。
这是我的route.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的屏幕截图
我希望A能帮到某人:)
发布于 2020-11-10 13:08:13
答案在问题中(对不起,我是Stack的新手)
https://stackoverflow.com/questions/64459531
复制相似问题