问题描述
我最近开始为 APi 文档学习 Swagger。但是,当我转到 localhost:5000/apidocs 时,我看到我添加的 API,但即使我在 yml 文件中描述了参数,所有 API 也没有参数。我在互联网上找不到任何相关内容。
这是我的 YML 代码:
paths:
/api/ppp:
get:
tags:
- "user"
summary: "Find User by uID"
description: "Returns a single user info"
operationId: "getuserById"
produces:
- "application/xml"
- "application/json"
parameters:
- name: "userId"
in: "path"
description: "ID of user to return"
required: true
type: "uuid"
这是我如何向 api 添加招摇 @swag_from('pathto/swagger.yml')
同样,我还有一个疑问。我们在 yml 规范文件中定义架构。我想知道这些架构到底代表什么,是否有必要使用它们?
附上 APIdocs 页面截图
解决方法
试试这个:
tags:
- user
summary: "Find User by uID"
description: "Returns a single user info"
operationId: "getuserById"
produces:
- "application/xml"
- "application/json"
parameters:
- name: "userId"
in: "path"
description: "ID of user to return"
required: true
type: "uuid"