@@ -72,23 +72,30 @@ export default class Topbar extends React.Component {
7272 saveAsYaml = ( ) => {
7373 // Editor content -> JS object -> YAML string
7474 let editorContent = this . props . specSelectors . specStr ( )
75+ let isOAS3 = this . props . specSelectors . isOAS3 ( )
76+ let fileName = isOAS3 ? "openapi.yaml" : "swagger.yaml"
7577 let jsContent = YAML . safeLoad ( editorContent )
7678 let yamlContent = YAML . safeDump ( jsContent )
77- downloadFile ( yamlContent , "swagger.yaml" )
79+ downloadFile ( yamlContent , fileName )
7880 }
7981
8082 saveAsJson = ( ) => {
8183 // Editor content -> JS object -> Pretty JSON string
8284 let editorContent = this . props . specSelectors . specStr ( )
85+ let isOAS3 = this . props . specSelectors . isOAS3 ( )
86+ let fileName = isOAS3 ? "openapi.json" : "swagger.json"
8387 let jsContent = YAML . safeLoad ( editorContent )
8488 let prettyJsonContent = beautifyJson ( jsContent , null , 2 )
85- downloadFile ( prettyJsonContent , "swagger.json" )
89+ downloadFile ( prettyJsonContent , fileName )
8690 }
8791
8892 saveAsText = ( ) => {
8993 // Download raw text content
94+ console . warn ( "DEPRECATED: saveAsText will be removed in the next minor version." )
9095 let editorContent = this . props . specSelectors . specStr ( )
91- downloadFile ( editorContent , "swagger.txt" )
96+ let isOAS3 = this . props . specSelectors . isOAS3 ( )
97+ let fileName = isOAS3 ? "openapi.txt" : "swagger.txt"
98+ downloadFile ( editorContent , fileName )
9299 }
93100
94101 convertToYaml = ( ) => {
@@ -199,11 +206,11 @@ export default class Topbar extends React.Component {
199206 </ DropdownMenu >
200207 { showGenerateMenu ? < DropdownMenu className = "long" { ...makeMenuOptions ( "Generate Server" ) } >
201208 { this . state . servers
202- . map ( serv => < li > < button type = "button" onClick = { this . downloadGeneratedFile . bind ( null , "server" , serv ) } > { serv } </ button > </ li > ) }
209+ . map ( ( serv , i ) => < li key = { i } > < button type = "button" onClick = { this . downloadGeneratedFile . bind ( null , "server" , serv ) } > { serv } </ button > </ li > ) }
203210 </ DropdownMenu > : null }
204211 { showGenerateMenu ? < DropdownMenu className = "long" { ...makeMenuOptions ( "Generate Client" ) } >
205212 { this . state . clients
206- . map ( cli => < li > < button type = "button" onClick = { this . downloadGeneratedFile . bind ( null , "client" , cli ) } > { cli } </ button > </ li > ) }
213+ . map ( ( cli , i ) => < li key = { i } > < button type = "button" onClick = { this . downloadGeneratedFile . bind ( null , "client" , cli ) } > { cli } </ button > </ li > ) }
207214 </ DropdownMenu > : null }
208215 </ div >
209216 </ div >
0 commit comments