This commit is contained in:
Anna Bodnia
2017-04-04 14:34:59 +03:00
parent 52331ab494
commit fde75d408e
3 changed files with 13 additions and 13 deletions

2
dist/swagger-ui.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -4,7 +4,7 @@ export default function curl( request ){
let headers = request.get("headers") let headers = request.get("headers")
curlified.push( "curl" ) curlified.push( "curl" )
curlified.push( "-X", request.get("method") ) curlified.push( "-X", request.get("method") )
curlified.push( request.get("url") ) curlified.push( `"${request.get("url")}"`)
if ( headers && headers.size ) { if ( headers && headers.size ) {
for( let p of request.get("headers").entries() ){ for( let p of request.get("headers").entries() ){

View File

@@ -21,7 +21,7 @@ describe("curlify", function() {
let curlified = curl(Im.fromJS(req)) let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual("curl -X POST http://example.com -H \"Accept: application/json\" -H \"content-type: application/json\" -d {\"id\":0,\"name\":\"doggie\",\"status\":\"available\"}") expect(curlified).toEqual("curl -X POST \"http://example.com\" -H \"Accept: application/json\" -H \"content-type: application/json\" -d {\"id\":0,\"name\":\"doggie\",\"status\":\"available\"}")
}) })
it("does not change the case of header in curl", function() { it("does not change the case of header in curl", function() {
@@ -35,7 +35,7 @@ describe("curlify", function() {
let curlified = curl(Im.fromJS(req)) let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual("curl -X POST http://example.com -H \"conTenT Type: application/Moar\"") expect(curlified).toEqual("curl -X POST \"http://example.com\" -H \"conTenT Type: application/Moar\"")
}) })
it("prints a curl statement with an array of query params", function() { it("prints a curl statement with an array of query params", function() {
@@ -46,7 +46,7 @@ describe("curlify", function() {
let curlified = curl(Im.fromJS(req)) let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual("curl -X GET http://swaggerhub.com/v1/one?name=john|smith") expect(curlified).toEqual("curl -X GET \"http://swaggerhub.com/v1/one?name=john|smith\"")
}) })
it("prints a curl statement with an array of query params and auth", function() { it("prints a curl statement with an array of query params and auth", function() {
@@ -60,7 +60,7 @@ describe("curlify", function() {
let curlified = curl(Im.fromJS(req)) let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual("curl -X GET http://swaggerhub.com/v1/one?name=john|smith -H \"authorization: Basic Zm9vOmJhcg==\"") expect(curlified).toEqual("curl -X GET \"http://swaggerhub.com/v1/one?name=john|smith\" -H \"authorization: Basic Zm9vOmJhcg==\"")
}) })
it("prints a curl statement with html", function() { it("prints a curl statement with html", function() {
@@ -77,7 +77,7 @@ describe("curlify", function() {
let curlified = curl(Im.fromJS(req)) let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual("curl -X GET http://swaggerhub.com/v1/one?name=john|smith -H \"accept: application/json\" -d {\"description\":\"<b>Test</b>\"}") expect(curlified).toEqual("curl -X GET \"http://swaggerhub.com/v1/one?name=john|smith\" -H \"accept: application/json\" -d {\"description\":\"<b>Test</b>\"}")
}) })
it("handles post body with html", function() { it("handles post body with html", function() {
@@ -94,7 +94,7 @@ describe("curlify", function() {
let curlified = curl(Im.fromJS(req)) let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual("curl -X POST http://swaggerhub.com/v1/one?name=john|smith -H \"accept: application/json\" -d {\"description\":\"<b>Test</b>\"}") expect(curlified).toEqual("curl -X POST \"http://swaggerhub.com/v1/one?name=john|smith\" -H \"accept: application/json\" -d {\"description\":\"<b>Test</b>\"}")
}) })
it("handles post body with special chars", function() { it("handles post body with special chars", function() {
@@ -109,7 +109,7 @@ describe("curlify", function() {
let curlified = curl(Im.fromJS(req)) let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual("curl -X POST http://swaggerhub.com/v1/one?name=john|smith -d {\"description\":\"@prefix nif:<http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#> .@prefix itsrdf: <http://www.w3.org/2005/11/its/rdf#> .\"}") expect(curlified).toEqual("curl -X POST \"http://swaggerhub.com/v1/one?name=john|smith\" -d {\"description\":\"@prefix nif:<http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#> .@prefix itsrdf: <http://www.w3.org/2005/11/its/rdf#> .\"}")
}) })
it("handles delete form with parameters", function() { it("handles delete form with parameters", function() {
@@ -123,7 +123,7 @@ describe("curlify", function() {
let curlified = curl(Im.fromJS(req)) let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual("curl -X DELETE http://example.com -H \"accept: application/x-www-form-urlencoded\"") expect(curlified).toEqual("curl -X DELETE \"http://example.com\" -H \"accept: application/x-www-form-urlencoded\"")
}) })
it("should print a curl with formData", function() { it("should print a curl with formData", function() {
@@ -136,7 +136,7 @@ describe("curlify", function() {
let curlified = curl(Im.fromJS(req)) let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual("curl -X POST http://example.com -H \"content-type: multipart/form-data\" -F id=123 -F name=Sahar") expect(curlified).toEqual("curl -X POST \"http://example.com\" -H \"content-type: multipart/form-data\" -F id=123 -F name=Sahar")
}) })
it("prints a curl post statement from an object", function() { it("prints a curl post statement from an object", function() {
@@ -153,7 +153,7 @@ describe("curlify", function() {
let curlified = curl(Im.fromJS(req)) let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual("curl -X POST http://example.com -H \"accept: application/json\" -d {\"id\":10101}") expect(curlified).toEqual("curl -X POST \"http://example.com\" -H \"accept: application/json\" -d {\"id\":10101}")
}) })
it("prints a curl post statement from a string containing a single quote", function() { it("prints a curl post statement from a string containing a single quote", function() {
@@ -168,7 +168,7 @@ describe("curlify", function() {
let curlified = curl(Im.fromJS(req)) let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual("curl -X POST http://example.com -H \"accept: application/json\" -d \"{\\\"id\\\":\\\"foo'bar\\\"}\"") expect(curlified).toEqual("curl -X POST \"http://example.com\" -H \"accept: application/json\" -d \"{\\\"id\\\":\\\"foo'bar\\\"}\"")
}) })
}) })