Skip to content

Commit ce8fa1b

Browse files
feat: can now read yaml api descriptions
1 parent d2837ef commit ce8fa1b

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

public/src/App.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
<script>
2929
import OpenApi from 'vue-openapi'
30+
import yaml from 'js-yaml'
3031
3132
// https://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript
3233
function getParameterByName(name, url) {
@@ -80,7 +81,13 @@ export default {
8081
if (newUrl !== window.location.href) {
8182
window.location.href = newUrl
8283
}
83-
this.$http.get(this.useProxy ? ('./proxy?url=' + this.url) : this.url).then(response => response.json()).then(api => {
84+
this.$http.get(this.useProxy ? ('./proxy?url=' + this.url) : this.url).then(response => {
85+
try {
86+
return yaml.safeLoad(response.bodyText, 'utf8');
87+
} catch (e) {
88+
return response.json()
89+
}
90+
}).then(api => {
8491
this.api = api
8592
this.error = null
8693
}, error => {

0 commit comments

Comments
 (0)