You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I created my api definition using swagger and have generated the server code using Swagger-tools in NodeJs. The SwaggerRouter handles all routes properly excepts the routes with ID. For example , routes like
/v1/factoris/self /v1/factoris/create
are directed to the right controller but calls with IDs
/v1/factoris/{factoris_id}
are returned as invalid routes.
Any idea what I might be missing ?
Here is a sample of the swagger specs
Swagger-codegen version
Swagger 2.0
Swagger-editor - 2.10.4
Swagger declaration file content or url
/factoris/create:
post:
tags:
- "Factoris"summary: "Create New Factori"description: ""operationId: "factorisCreatePOST"parameters:
- in: "body"name: "FactoriCreate"description: "Create a new factory"required: trueschema:
$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: truetype: "string"
- name: "expand"in: "query"description: "Provide expanded information on Assemblies or Products or Users"required: truetype: "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"
After some trial and error, I figured out that path parameter does not work if its has a "-" (factori-id)
so changing factori-id to factori_id fixed it. But its still a bug since the path parameter cannot handle "-"
Description
I created my api definition using swagger and have generated the server code using Swagger-tools in NodeJs. The SwaggerRouter handles all routes properly excepts the routes with ID. For example , routes like
are directed to the right controller but calls with IDs
/v1/factoris/{factoris_id}
are returned as invalid routes.
Any idea what I might be missing ?
Here is a sample of the swagger specs
Swagger-codegen version
Swagger 2.0
Swagger-editor - 2.10.4
Swagger declaration file content or url
https://stackoverflow.com/questions/44318120/swagger-codegen-generated-code-having-issues-routing-requests-with-parameters-in
The text was updated successfully, but these errors were encountered: