Skip to content

Commit 0ed4b33

Browse files
committed
remove defaultModelRendering (does nothing), misc refactors
1 parent d866b87 commit 0ed4b33

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

web_src/js/standalone/swagger.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import SwaggerUI from 'swagger-ui-dist/swagger-ui-es-bundle.js';
22
import 'swagger-ui-dist/swagger-ui.css';
33
import {parseUrl} from '../utils.js';
4-
import {load} from "js-yaml";
4+
import {load} from 'js-yaml';
55

6+
// This code is shared for our own spec as well as user-defined specs via files in repo
67
window.addEventListener('load', async () => {
78
const url = parseUrl(document.getElementById('swagger-ui').getAttribute('data-source'));
89
const res = await fetch(url.toString());
910
const text = await res.text();
1011
const spec = /\.ya?ml$/i.test(url.pathname) ? load(text) : JSON.parse(text);
12+
const isOwnSpec = url.pathname.endsWith('/swagger.v1.json');
1113

12-
// This code is shared for our own spec as well as user-defined specs, this
13-
// section is for our own spec
14-
if (url.pathname.endsWith('/swagger.v1.json')) {
14+
if (isOwnSpec) {
1515
// Make the page's protocol be at the top of the schemes list
1616
const proto = window.location.protocol.slice(0, -1);
1717
spec.schemes.sort((a, b) => {
@@ -26,7 +26,6 @@ window.addEventListener('load', async () => {
2626
dom_id: '#swagger-ui',
2727
deepLinking: true,
2828
docExpansion: 'none',
29-
defaultModelRendering: 'model', // don't show examples by default, because they may be incomplete
3029
presets: [
3130
SwaggerUI.presets.apis
3231
],

0 commit comments

Comments
 (0)