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

api.getPath does not handle basePath for swagger-node-runner and express sub-app #81

Closed
CallMeLaNN opened this issue May 16, 2016 · 1 comment

Comments

@CallMeLaNN
Copy link

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 SwaggerMiddleware is then added into apiApp.

Both swagger definition and express already configured to use the /api basePath, but the swagger middleware bypass it by calling next() because the api.getPath return undefined in swagger-node-runner/lib/connect_middleware.js

Now in 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 use pathOrReq.originalUrl instead of pathOrReq.url since originalUrl is the full path url.

@whitlockjc
Copy link
Member

swagger-node needs to be updated to call api.getPath appropriately so that the url property of the object passed to the API has the proper value. Sway will never have code in it that is server framework aware and as people write integrations that use Sway, it is their responsibility to make a Sway API call that will work.

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

2 participants