Add support for `basePath` in swagger 2.0 files (#2211)

Fixes #2175

Signed-off-by: Alejandro Pedraza <alejandro@buoyant.io>
This commit is contained in:
Alejandro Pedraza 2019-02-06 13:44:35 -05:00 committed by GitHub
parent 79b875a1e8
commit 50fbcc60b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -5,6 +5,7 @@ import (
"io" "io"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"path"
"regexp" "regexp"
"sort" "sort"
@ -65,8 +66,9 @@ func swaggerToServiceProfile(swagger spec.Swagger, namespace, name, controlPlane
sort.Strings(paths) sort.Strings(paths)
} }
for _, path := range paths { for _, relPath := range paths {
item := swagger.Paths.Paths[path] item := swagger.Paths.Paths[relPath]
path := path.Join(swagger.BasePath, relPath)
pathRegex := pathToRegex(path) pathRegex := pathToRegex(path)
if item.Delete != nil { if item.Delete != nil {
spec := mkRouteSpec(path, pathRegex, http.MethodDelete, item.Delete.Responses) spec := mkRouteSpec(path, pathRegex, http.MethodDelete, item.Delete.Responses)