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

Swagger Server URL loads previously requested url basePath but logs show correct value #10024

Open
parth-patil-uipath opened this issue Jun 17, 2024 · 0 comments

Comments

@parth-patil-uipath
Copy link

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
  • Swagger-UI version: [e.g. 3.10.0] swagger-ui-express": "^4.6.3"
  • Swagger/OpenAPI version: [e.g. Swagger 2.0, OpenAPI 3.0] OpenAPI 3.0

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:

SwaggerUI({
  // your config options here
})

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
};

?yourQueryStringConfig

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)

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

1 participant