Skip to content

Commit ea4b3d8

Browse files
committed
Convert all URL-import specs to YAML
1 parent 0a9966f commit ea4b3d8

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/standalone/topbar/topbar.jsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,13 @@ export default class Topbar extends React.Component {
4646
let url = prompt("Enter the URL to import from:")
4747

4848
if(url) {
49-
this.props.specActions.updateUrl(url)
50-
this.props.specActions.download(url)
49+
fetch(url)
50+
.then(res => res.text())
51+
.then(text => {
52+
this.props.specActions.updateSpec(
53+
YAML.safeDump(YAML.safeLoad(text))
54+
)
55+
})
5156
}
5257
}
5358

@@ -74,15 +79,15 @@ export default class Topbar extends React.Component {
7479
}
7580

7681
saveAsJson = () => {
77-
// Editor content -> JS object -> YAML string
82+
// Editor content -> JS object -> Pretty JSON string
7883
let editorContent = this.props.specSelectors.specStr()
7984
let jsContent = YAML.safeLoad(editorContent)
8085
let prettyJsonContent = beautifyJson(jsContent, null, 2)
8186
downloadFile(prettyJsonContent, "swagger.json")
8287
}
8388

8489
saveAsText = () => {
85-
// Editor content -> JS object -> YAML string
90+
// Download raw text content
8691
let editorContent = this.props.specSelectors.specStr()
8792
downloadFile(editorContent, "swagger.txt")
8893
}

0 commit comments

Comments
 (0)