2017-06-01 93 views
1

我使用swagger创建了我的api定义,并使用NodeJs中的Swagger工具生成了服务器代码。 SwaggerRouter正确处理所有路由,除了具有ID的路由。 例如,路线等Swagger-codegen生成的代码有问题通过路径中的参数路由请求

/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

PLS通过https://github.com/swagger-api/报告问题swagger-codegen/issues/new,这样swagger codegen社区可以帮助你。 –

回答

0

一些试验和错误后的样本,我想通了,如果有这个路径参数不工作“ - ”(factori-ID) 因此更改factori -id给factori_id修复它。但它仍然是一个错误,因为路径参数无法处理“ - ”

这里创建的开放问题扬鞭,CODEGEN https://github.com/swagger-api/swagger-codegen/issues/5763