Handle basePath together with express sub-app
I have this URL format: domain.com/api/resource
The baseUrl defined in swagger.yaml is /api
The express configured so that the /api is just a sub-app:
app = express();
apiApp = express();
app.use('/api', apiApp);
The swagger middleware is then added into apiApp.
Both swagger definition and express already configured to use the /api basePath, but connect middleware bypass it by calling next() because the runner.getPath return undefined.
Note the api.getPath, the pathOrReq.url here is returning only the sub path. In this case the pathOrReq.url = '/resource' instead of '/api/resource'. Therefore the regexp and isArray return false.
I suggest we fix this by calling api.getPath(req.originalUrl) either in runner or connect middleware since originalUrl contain the full path.
Refer to this also https://github.com/apigee-127/sway/issues/81
@theganyo what do you think about this? If you feel ok, let me know if I can do it, run npm run test and send PR.
It seems reasonable to me as long as it's completely backward compatible. Do you see any potential issues there? Thanks!