wcandillon / swagger-js-codegen

A Swagger Codegen for typescript, nodejs & angularjs
Apache License 2.0
693 stars 286 forks source link

Fix "empty" base path #118

Closed chdanielmueller closed 8 years ago

chdanielmueller commented 8 years ago

closes #117

wcandillon commented 8 years ago

@chdanielmueller thks for this PR! Can you give me a sample swagger file I can use for reproducing the issue and for testing?

chdanielmueller commented 8 years ago

Hi @wcandillon,

This example json should reproduce the error. The problem is the basePath parameter.

{
  "info": {
    "title": "Hello World",
    "version": "1.0.0",
    "description": "A sample API"
  },
  "host": "localhost:3000",
  "basePath": "/",
  "swagger": "2.0",
  "paths": {
    "/hello": {
      "get": {
        "description": "Returns the homepage",
        "responses": {
          "200": {
            "description": "hello world"
          }
        }
      }
    }
  }
}
wcandillon commented 8 years ago

@chdanielmueller Thank you so much for pointing out this issue. Shouldn't basePath be normalized to have its trailing slash remove instead? While your PR seems to be fix "basePath": "/",, it doesn't seem to work for "basePath": "/v1/", for instance?

chdanielmueller commented 8 years ago

You are right... I changed the code to use a regex which removes trailing slashes.