[英]Swagger node is taking URL phrase as parameter
我为REST API使用了swagger-node ,在这里发现了一个荒谬的问题。
这是我的GET请求之一:
GET: /students/{id}/{name}
(id是数字)
现在我写了另一个请求:
GET: /students/routeInfo/{id}
但第2次要求我以下错误:
预期类型为数字,找到类型为string 。 这显然意味着第二请求试图“掩模” 1个请求。 我认为不应该这样。
我是在做错什么,还是有其他方法可以解决这个问题?
在路径定义中,更改更改“参数” type: number
type: string
您的路径将如下所示:
/students/routeInfo/{id}:
x-swagger-router-controller: yourStudentController
get:
tags:
- Student
description: description
operationId: yourOperation
parameters:
- name: id
in: path
description: description id of routeInfo
required: true
type: string
请参阅https://swagger.io/docs/specification/paths-and-operations/
在OpenAPI规范v3.0文档中描述了完全相同的情况:“路径模板匹配”部分,第3个示例。 这被称为模糊匹配,并且“ ...由工具决定使用哪个路径。” 该工具当然是摇摇欲坠的节点。
不过这很奇怪,不是!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.