2017-06-01 90 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