swagger-codegen icon indicating copy to clipboard operation
swagger-codegen copied to clipboard

[nodejs] Missing paths/methods : a simple workaround

Open Cooker-Monster opened this issue 11 years ago • 4 comments

This is related to bug : https://github.com/swagger-api/swagger-codegen/issues/652

As api/swagger.json is not currently well generated, there is a simple way to fix this

  • Add "x-swagger-router-controller" at the path level of the original Swagger Specification for each defined path of the specification (it's mandatory by swagger-tools/router).
  • Get the nodejs generated code and unzip wherether you want !
  • Replace the api/swagger.json generated file by the original file (I.E, download json file from editor.swagger.io).

After that, you can see all the operations of all paths with http://localhost:8080/docs and all the functions (named by operationId) are well routed with paths.

Hope it help to wait the v2.1.0 !

Cooker-Monster avatar May 06 '15 15:05 Cooker-Monster

@Cooker-Monster Im experiencing the reference bug and having problems applying your solution.

A part of my swagger file looks like this:

paths:
  /users:
      get:
        summary: Users
        description: |
          Get Users
        tags:
          - Users
        responses:
          200:
            description: Array of users
      post:
        summary: Users
        description: |
          Register User
        tags:
          - Users
        responses:
          200:
            description: Register successful

Only the POST path is generated when exporting to NodeJS. Where am i supposed to add x-swagger-router-controller to fix this problem?

Nume avatar Jun 18 '15 12:06 Nume

Hi Nume ! As I said, your own swagger file must contain the x-swagger-router-controller attribute but that will not fix the problem on his own ! You also must replace the generated swagger file by your own file, as the generated file don't respect the Swagger spec syntax.

Cooker-Monster avatar Jun 18 '15 17:06 Cooker-Monster

The generated swagger file should represent what you used directly. Please reopen if you still see an issue with this.

fehguy avatar Oct 25 '15 23:10 fehguy

The generated code is now correct ! Thx a lot for this well done job.

Cooker-Monster avatar Oct 28 '15 19:10 Cooker-Monster