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
I opened an issue for swagger-ui-express's maintainer, and he replied with:
I think this issue is with the Swagger UI and would be best placed fixed by them. Happy to take a PR to fix in this module but feel it would he best place fixed in Swagger UI therefore its fixed across the board.
The original issue I place over there
What I am using:
I'm using the explorer's select in the topbar to view several swagger docs.
The select is working great, and upon clicking on each it switches to the relevant url that hosts the desired swagger json.
What is the problem:
The problem starts when I refresh the page.
Let's say I have 3 swagger schemas/options in the dropdown:
All
Images
Users
presented just as in the above order. "All" is first, "Images" is second, "Users" is third.
Let's say i'm now on Users schema, so my url looks like this:
If I were to refresh the page at this point, the url would stay the same, however the select would revert back to the first option ("All"), and the schema to be loaded would match that first option! The Question is: How can I make it so that upon refresh, the select will preserve my current selected option and load the swagger json that matches?
I know that I can pass a custom.js file, and I could probably implement a waitForSelector function to wait for the "select" id, and then do a programmatic click() somehow, but it sounds like too much of a work-around, and this seems like an operation that should be given out-of-the-box by swagger-ui-express, isn't it?
Could you please implement some logic that uses the "urls.primaryName" query param to load a swagger json based on its value? 🙏🏼
Additional information:
This is how I am using swagger-ui-express:
server.js
// Step 1: import swagger's extra options
import { swaggerExtraOptions } from './swagger';
// Step 2: host all swagger.json files (i.e. all.json, images.json, users.json)
app.use('/api-docs', express.static('./src/swagger'));
// Step 3: basic swagger-ui-express usage according to the documentation
app.use(
'/api-docs',
swaggerUi.serve,
swaggerUi.setup(null, swaggerExtraOptions)
);
swaggerExtraOptions object
const swaggerExtraOptions = {
// customJs: './custom.js', // I'd prefer not to use it if possible...
explorer: true,
swaggerOptions: {
urls: [
{
name: "All",
url: "http://localhost:5000/api-docs/configs/all.json",
},
{
name: "Images",
url: "http://localhost:5000/api-docs/configs/images.json",
},
{
name: "Users",
url: "http://localhost:5000/api-docs/configs/users.json",
}
]
},
};
The text was updated successfully, but these errors were encountered:
Summary
I opened an issue for swagger-ui-express's maintainer, and he replied with:
The original issue I place over there
What I am using:
I'm using the explorer's select in the topbar to view several swagger docs.
The select is working great, and upon clicking on each it switches to the relevant url that hosts the desired swagger json.
What is the problem:
The problem starts when I refresh the page.
Let's say I have 3 swagger schemas/options in the dropdown:
presented just as in the above order. "All" is first, "Images" is second, "Users" is third.
Let's say i'm now on Users schema, so my url looks like this:
http://localhost:5000/api-docs/?urls.primaryName=Users
If I were to refresh the page at this point, the url would stay the same, however the select would revert back to the first option ("All"), and the schema to be loaded would match that first option!
The Question is:
How can I make it so that upon refresh, the select will preserve my current selected option and load the swagger json that matches?
I know that I can pass a custom.js file, and I could probably implement a waitForSelector function to wait for the "select" id, and then do a programmatic click() somehow, but it sounds like too much of a work-around, and this seems like an operation that should be given out-of-the-box by swagger-ui-express, isn't it?
Could you please implement some logic that uses the "urls.primaryName" query param to load a swagger json based on its value? 🙏🏼
Additional information:
This is how I am using swagger-ui-express:
server.js
swaggerExtraOptions object
The text was updated successfully, but these errors were encountered: