Skip to content

Commit 897be68

Browse files
committed
make it work for for openapi 3.x
1 parent 8d70d57 commit 897be68

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

web_src/js/standalone/swagger.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@ window.addEventListener('load', async () => {
66
const res = await fetch(url);
77
const spec = await res.json();
88

9-
// Make the page's protocol be at the top of the schemes list
10-
const proto = window.location.protocol.slice(0, -1);
11-
spec.schemes.sort((a, b) => {
12-
if (a === proto) return -1;
13-
if (b === proto) return 1;
14-
return 0;
15-
});
9+
// This code is shared for our own spec as well as user-defined specs, this
10+
// section is for our own spec
11+
if (url.endsWith('/swagger.v1.json')) {
12+
// Make the page's protocol be at the top of the schemes list
13+
const proto = window.location.protocol.slice(0, -1);
14+
spec.schemes.sort((a, b) => {
15+
if (a === proto) return -1;
16+
if (b === proto) return 1;
17+
return 0;
18+
});
19+
}
1620

1721
const ui = SwaggerUI({
1822
spec,

0 commit comments

Comments
 (0)