You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Seems some cache issue when loading the swagger UI page when we update server url value dynamically with each /api-doc load page. Is this expected? amI missing something. Logs do show that I am updating the url with correct value and swagger.json page also shows correct url but UI page shows one from previously accessed url.
Q&A (please complete the following information)
OS: [e.g. macOS] All OS
Browser: [e.g. chrome, safari] All browsers
Version: [e.g. 22] swagger-ui-express": "^4.6.3"
Method of installation: [e.g. npm, dist assets] npm
So basically I have trying to update the Swagger server every time I load /api-doc path.
I am using ExpressJS framework for it.
I am using following dependencies
"swagger-jsdoc": "^4.0.0",
"swagger-ui-express": "^4.6.3"
Server url value is loaded like this in certain way
apiDocRouter.use("/", swaggerUi.serve);
apiDocRouter.get("/", async function(req, res) {
res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
res.setHeader("Pragma", "no-cache");
res.setHeader("Expires", 0);
// here update the url with what is coming from req path
await formatOptions(req);
logger.info(options json used in swagger is : ${JSON.stringify(options)});
UI page that loads server does not have correct url from swagger.json server. I see logs also update the server value correctly but it does not get reflected into UI. UI shows up the one from previously accessed url and this is randomly happening not persistent for all users.
How can we help?
Is this a known issue? Is there any other way where I can update server which has dynamic part and not only static path? I want to update server on each local of /api-doc (swagger UI page)
The text was updated successfully, but these errors were encountered:
Seems some cache issue when loading the swagger UI page when we update server url value dynamically with each /api-doc load page. Is this expected? amI missing something. Logs do show that I am updating the url with correct value and swagger.json page also shows correct url but UI page shows one from previously accessed url.
Q&A (please complete the following information)
Content & configuration
So basically I have trying to update the Swagger server every time I load /api-doc path.
I am using ExpressJS framework for it.
I am using following dependencies
"swagger-jsdoc": "^4.0.0",
"swagger-ui-express": "^4.6.3"
Server url value is loaded like this in certain way
apiDocRouter.use("/", swaggerUi.serve);
apiDocRouter.get("/", async function(req, res) {
res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
res.setHeader("Pragma", "no-cache");
res.setHeader("Expires", 0);
// here update the url with what is coming from req path
await formatOptions(req);
logger.info(
options json used in swagger is : ${JSON.stringify(options)}
);const specs = await swaggerJSDoc(options);
swaggerUi.setup(specs)(req, res);
});
Swagger/OpenAPI definition:
# your YAML here
Any YAML file is fine. I am trying to update url through swagger specs
Swagger-UI configuration options:
let options = {
definition: {
openapi: "3.0.0",
components: {},
security: {
bearerAuth: []
},
servers: [
{
url:
"api/v1/openapi/"
}
],
info: {
title: "XYZ API",
version: "1.0.0",
description:
""
}
},
/* Path to the API docs*/
apis: apisPaths
};
Screenshots
UI page that loads server does not have correct url from swagger.json server. I see logs also update the server value correctly but it does not get reflected into UI. UI shows up the one from previously accessed url and this is randomly happening not persistent for all users.
How can we help?
Is this a known issue? Is there any other way where I can update server which has dynamic part and not only static path? I want to update server on each local of /api-doc (swagger UI page)
The text was updated successfully, but these errors were encountered: