Les*_*Les 5 spring-boot openapi
我正在使用 Spring Boot,并且有一个定义一些端点的 Yaml 文件。我需要为其中一个端点设置别名以拥有不同的端点,但功能完全相同。
举个例子,如果我有一个规范如下:
openapi: '3.0.1'
servers:
- url: 'http://localhost:8080/api
paths:
/v3/users
.... (remainder of endpoint spec)
Run Code Online (Sandbox Code Playgroud)
根据我所读到的内容,我想补充的是:
/globalusers/v3/users
$ref: '#/paths/~1v3~1users
Run Code Online (Sandbox Code Playgroud)
当我这样做时,生成的 Spring API 不包含新的 RequestMapping。我尝试复制整个/v3/users定义并将其也放入其中,但没有任何变化。
要么我遗漏了一些东西,要么误解了我读到的内容。感谢所有帮助!
谢谢。
您可以使用创建路径的别名$ref
paths:
/authorizations:
get:
description: Returns a list of authorizations
responses:
200:
description: OK
/authorisations:
$ref: '#/paths/~1authorizations'
Run Code Online (Sandbox Code Playgroud)
示例取自此处。
正在~1转义字符/,因为路径本身也有/,即/authorizations
| 归档时间: |
|
| 查看次数: |
1733 次 |
| 最近记录: |