Swagger-ui api(资源)的名称是如何生成的?
Swagger-ui how is the name of api (resource) generated?
当我大摇大摆地创建一个 API 时,通常我的 API 具有资源名称:
Tasks
/tasks
/tasks/{id}
etc.
有时我只得到一个默认值:
Default
GET /tasks
GET /tasks/{uuid}
etc.
是什么决定了生成的 API 的 header 名称?
期望行为的屏幕截图(任务有时是默认的):
这取决于您在 RESTful 服务实现顶部作为参数传递给 swagger 的 Api 注释 (io.swagger.annotations.Api
) 的内容 -
@Path(value="/")
@Api(value="/")
public interface YourService {
....
}
@Api(value="/")
将生成 default
@Api(value="/Tasks")
将生成 Tasks
你是指 Swagger UI 中的这些 headers 吗?
它们是根据您的 API 操作的 tags
生成的。例如,要在 "Tasks" 下分组操作,请使用:
{
...
"paths": {
"\/tasks:": {
"tags": [
"Tasks"
],
...
每个操作可以有任意数量的标签。没有标签的操作将列在 "Default" 组下。
要为标签提供说明,请使用 top-level tags
部分:
{
...
"tags": [
{
"name": "Tasks",
"description": "Operations to manage tasks"
}
},
{
"name": "Notes",
"description": "Operations to manage notes"
}
}
],
...
当我大摇大摆地创建一个 API 时,通常我的 API 具有资源名称:
Tasks
/tasks
/tasks/{id}
etc.
有时我只得到一个默认值:
Default
GET /tasks
GET /tasks/{uuid}
etc.
是什么决定了生成的 API 的 header 名称?
期望行为的屏幕截图(任务有时是默认的):
这取决于您在 RESTful 服务实现顶部作为参数传递给 swagger 的 Api 注释 (io.swagger.annotations.Api
) 的内容 -
@Path(value="/")
@Api(value="/")
public interface YourService {
....
}
@Api(value="/")
将生成 default
@Api(value="/Tasks")
将生成 Tasks
你是指 Swagger UI 中的这些 headers 吗?
它们是根据您的 API 操作的 tags
生成的。例如,要在 "Tasks" 下分组操作,请使用:
{
...
"paths": {
"\/tasks:": {
"tags": [
"Tasks"
],
...
每个操作可以有任意数量的标签。没有标签的操作将列在 "Default" 组下。
要为标签提供说明,请使用 top-level tags
部分:
{
...
"tags": [
{
"name": "Tasks",
"description": "Operations to manage tasks"
}
},
{
"name": "Notes",
"description": "Operations to manage notes"
}
}
],
...