我使用swagger创建了我的api定义,并使用NodeJs中的Swagger工具生成了服务器代码。除了具有ID的路由之外,SwaggerRouter正确处理所有路由。 例如,
之类的路线/ V1 /因子分解/自 / V1 /因子分解/创建
指向正确的控制器 但使用ID调用
/ V1 /因子分解/ {factoris_id}
作为无效路线返回。
知道我可能缺少什么吗?
以下是招摇规格
的示例/factoris/create:
post:
tags:
- "Factoris"
summary: "Create New Factori"
description: ""
operationId: "factorisCreatePOST"
parameters:
- in: "body"
name: "FactoriCreate"
description: "Create a new factory"
required: true
schema:
$ref: "#/definitions/FactoriCreate"
responses:
201:
description: "A single factori object"
schema:
$ref: "#/definitions/inline_response_201"
405:
description: "Method not allowed"
schema:
$ref: "#/definitions/inline_response_405"
security:
- oauth2:
- "admin"
x-swagger-router-controller: "Factoris"
/factoris/{factori-id}:
get:
tags:
- "Factoris"
summary: "Factori Information"
description: ""
operationId: "factorisFactori_idGET"
parameters:
- name: "factori-id"
in: "path"
description: "The factori identifier string"
required: true
type: "string"
- name: "expand"
in: "query"
description: "Provide expanded information on Assemblies or Products or Users"
required: true
type: "string"
responses:
200:
description: "A single factori object"
schema:
$ref: "#/definitions/inline_response_201"
404:
description: "Factori not found"
schema:
$ref: "#/definitions/inline_response_404"
security:
- oauth2:
- "codeadmin"
x-swagger-router-controller: "Factoris"
答案 0 :(得分:0)
经过一些试验和错误后,我发现路径参数如果有一个" - " (factori-ID) 所以将factori-id更改为factori_id修复它。但它仍然是一个bug,因为path参数无法处理" - "
这是在Swagger-codegen中创建的开放问题 https://github.com/swagger-api/swagger-codegen/issues/5763