[英]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.