Regarding an API served at https://example.com/api/sub-api/, we should expect an API doc like this:
# api-doc.yml
openapi: '3.0.2'
info:
title: Sub API
version: '1.0.0'
description: 'The Sub API does stuff...'
servers:
- url: https://example.com/api/sub-api/
paths: {}
But if we try, for the sake of containment, to mount a sub express app at /api/sub-api with express-openapi we land in a "double nested routing" that leads to serving our API on /api/sub-api/api/sub-api/.
It seems that this lib is not subtracting the express mounting point to the actual calculated basePath.
To illustrate, here is a bootstrap of the situation:
Here I would expect that /api/sub-api is removed from the generated routing at the mount point but it is not the case. This leads to 2 awkward workarounds:
Replace .use("/api/sub-api", apiApp) by .use("/", apiApp) which could lead to unexpected routing hung by implementation of express-openapi and writing of the api-doc.yml.
Replace url: https://example.com/api/sub-api/ by url: https://example.com/ which is untrue and could break other dependencies like Swagger UI.
Don't you think it could be valuable to remove the mount path from the base path? It could be seamless since I think people can't use the lib that way right now.
Regarding an API served at
https://example.com/api/sub-api/
, we should expect an API doc like this:But if we try, for the sake of containment, to mount a sub express app at
/api/sub-api
withexpress-openapi
we land in a "double nested routing" that leads to serving our API on/api/sub-api/api/sub-api/
.It seems that this lib is not subtracting the express mounting point to the actual calculated
basePath
.To illustrate, here is a bootstrap of the situation:
Here I would expect that
/api/sub-api
is removed from the generated routing at the mount point but it is not the case. This leads to 2 awkward workarounds:.use("/api/sub-api", apiApp)
by.use("/", apiApp)
which could lead to unexpected routing hung by implementation ofexpress-openapi
and writing of theapi-doc.yml
.url: https://example.com/api/sub-api/
byurl: https://example.com/
which is untrue and could break other dependencies like Swagger UI.Don't you think it could be valuable to remove the mount path from the base path? It could be seamless since I think people can't use the lib that way right now.