Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swagger-codegen generated code having issues Routing requests with parameters in path #5763

Open
karthikrmw opened this issue Jun 2, 2017 · 1 comment

Comments

@karthikrmw
Copy link

karthikrmw commented Jun 2, 2017

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

/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: 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"

https://stackoverflow.com/questions/44318120/swagger-codegen-generated-code-having-issues-routing-requests-with-parameters-in

@karthikrmw
Copy link
Author

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 "-"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant