File tree Expand file tree Collapse file tree 1 file changed +26
-15
lines changed Expand file tree Collapse file tree 1 file changed +26
-15
lines changed Original file line number Diff line number Diff line change 71
71
<script>
72
72
73
73
window.onload = function() {
74
- // Build a system
75
- const ui = SwaggerUIBundle({
76
- url: "{{AppUrl}}swagger.{{.APIJSONVersion}}.json",
77
- dom_id: '#swagger-ui',
78
- deepLinking: true,
79
- presets: [
80
- SwaggerUIBundle.presets.apis,
81
- SwaggerUIStandalonePreset
82
- ],
83
- plugins: [
84
- SwaggerUIBundle.plugins.DownloadUrl
85
- ],
86
- layout: "StandaloneLayout"
87
- })
74
+ // Fetch the Swagger JSON specs
75
+ var url = "{{AppUrl}}swagger.{{.APIJSONVersion}}.json"
76
+ fetch(url)
77
+ .then(function(response) {
78
+ response.json()
79
+ .then(function(spec) {
80
+ // Make the page's protocol be at the top of the schemes list
81
+ var protocol = window.location.protocol.slice(0, -1)
82
+ spec.schemes.sort(function(x,y){ return x == protocol ? -1 : y == protocol ? 1 : 0 })
83
+ // Build the Swagger UI
84
+ const ui = SwaggerUIBundle({
85
+ spec: spec,
86
+ dom_id: '#swagger-ui',
87
+ deepLinking: true,
88
+ presets: [
89
+ SwaggerUIBundle.presets.apis,
90
+ SwaggerUIStandalonePreset
91
+ ],
92
+ plugins: [
93
+ SwaggerUIBundle.plugins.DownloadUrl
94
+ ],
95
+ layout: "StandaloneLayout"
96
+ })
88
97
89
- window.ui = ui
98
+ window.ui = ui
99
+ })
100
+ })
90
101
}
91
102
</script>
92
103
</body>
You can’t perform that action at this time.
0 commit comments