This is how I configure swagger :
const openapi = Openapi.initialize({
paths: openApiPaths,
app,
apiDoc,
});
const openApiSpec = openapi.apiDoc;
console.log(openApiSpec);
app.use(swaggerUI(openApiSpec));
How can I change the base path /docs/
to /projectName/docs/
?
I did not find any relevant answer to that
EDIT
My api doc is described as below in it's own file:
export const apiDoc = {
'x-express-openapi-additional-middleware': [checkBodyValidity],
swagger: '2.0',
basePath: '/api/v1',
info: {
title: 'Documentation Rest API',
version: 'v1',
},
paths: {},
definitions: {}
}
CheckBodyValidity is kind of a middleware that check request params validity (not relevant for my question):
export const checkBodyValidity: any = (req, res, next) => {}
Swagger is initialized as below in a file named openapiSetup :
export async function init(app: any): Promise<any> {
[...]
const openapi = Openapi.initialize({
paths: openApiPaths,
app,
apiDoc,
});
const openApiSpec = openapi.apiDoc;
app.use(swaggerUI(openApiSpec));
}
-> openApiPaths is the path{} part if the doc. It's constructed from directories and file names
Finally in express app :
await openapiSetup.init(app);