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
/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"
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 "-"
here is the open issue created in Swagger-codegen https://github.com/swagger-api/swagger-codegen/issues/5763