Open lilactown opened 5 years ago
There is an option for this in the swagger spec called :basePath
. if you add {:swagger {:basePath "/service-name"}}
to the route data, it should add that to all paths.
I think that could be an example in the docs (https://github.com/metosin/reitit/blob/master/doc/ring/swagger.md)...
added an example to the docs.
Thanks! The swagger :basePath
did fix the API requests from swagger-ui (number 3).
However, the redirect from e.g. /service-name/api-docs/
still goes to /api-docs/index.html
, instead of /service-name/api-docs/index.html
.
I'm running into the same issue when I try to convert an AWS Lambda being used with the API Gateway to a ring request being serviced with reitit. The index.html and swagger-ui.js routes don't prepend the basePath when the redirect occurs.
Did anyone find a solution to the index.html
redirect problem?
In my case /service-name
is redirected to /index.html
, yet I can find the resource at service-name/index.html
.
Did anyone find a solution to the
index.html
redirect problem? In my case/service-name
is redirected to/index.html
, yet I can find the resource atservice-name/index.html
.
yes, I ran into the same problem yesterday. Basically, I think swagger-ui generate all the swagger-ui stuff in the express path/. Someone suggested ngnix rewrite in stackoverflow. I am able to resolve that by redirected in express as following.
// serve the swagger ui in a temporary directory (you can go to "/service-name/temp-api-docs/" to see the swaggerUI")
app.use('/temp-api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument));
// generate the redirect path with your service-name, please notice the last slash
const apiDocsRedirectPath = "/service-name".concat('/temp-api-docs/');
// redirect the path that you want to what swaggerUI serving
app.get('/api-docs', function(req, res) {
res.redirect(apiDocsRedirectPath);
});
// when you hit "/service-name/api-docs" which will redirect to "/service-name/temp-api-docs/"
swagger-ui works while developing locally:
localhost:4321/
redirects me to the swagger UI and I can send requests.However, once deployed, my service is routed via
domain.com/service-name/
.This causes 3 problems:
domain.com/service-name/
goes todomain.com/index.html
domain.com/swagger.json
. Fixable by specifying full URL in:url
configdomain.com/endpoint
, rather thandomain.com/service-name/endpoint
What I want is:
domain.com/service-name/
todomain.com/service-name/index.html
swagger.json