I'm using http://petstore.swagger.io/ and testing https://github.com/pjfanning/swagger-akka-http-sample.
I've maintained this sample for a while but haven't checked it recently.
The Try It option now generates a URL with //add and this fails But /add works.
curl -X POST http://localhost:12345//add -H "accept: application/json" -H "content-type: application/json" -d "{ \"numbers\": [ 0 ]}"
The swagger.json is
{
"swagger" : "2.0",
"info" : {
"description" : "",
"version" : "1.0",
"title" : "",
"termsOfService" : ""
},
"host" : "localhost:12345",
"basePath" : "/",
"tags" : [ {
"name" : "add"
}, {
"name" : "hello"
} ],
"schemes" : [ "http" ],
"paths" : {
"/add" : {
"post" : {
"tags" : [ "add" ],
"summary" : "Add integers",
"description" : "",
"operationId" : "addIntegers",
"produces" : [ "application/json" ],
"parameters" : [ {
"in" : "body",
"name" : "body",
"description" : "\"numbers\" to sum",
"required" : true,
"schema" : {
"$ref" : "#/definitions/AddRequest"
}
} ],
"responses" : {
"200" : {
"description" : "Return sum",
"schema" : {
"$ref" : "#/definitions/AddResponse"
}
},
"500" : {
"description" : "Internal server error"
}
}
}
},
"/hello" : {
"get" : {
"tags" : [ "hello" ],
"summary" : "Return Hello greeting",
"description" : "",
"operationId" : "anonymousHello",
"produces" : [ "application/json" ],
"parameters" : [ ],
"responses" : {
"200" : {
"description" : "Return Hello Greeting",
"schema" : {
"$ref" : "#/definitions/Greeting"
}
},
"500" : {
"description" : "Internal server error"
}
}
}
},
"/hello/{name}" : {
"get" : {
"tags" : [ "hello" ],
"summary" : "Return Hello greeting with person's name",
"description" : "",
"operationId" : "hello",
"produces" : [ "application/json" ],
"parameters" : [ {
"name" : "name",
"in" : "path",
"description" : "Name of person to greet",
"required" : true,
"type" : "string"
} ],
"responses" : {
"200" : {
"description" : "Return Hello Greeting",
"schema" : {
"$ref" : "#/definitions/Greeting"
}
},
"500" : {
"description" : "Internal server error"
}
}
}
}
},
"securityDefinitions" : {
"basicAuth" : {
"type" : "basic"
}
},
"definitions" : {
"Function1" : {
"type" : "object"
},
"Function1RequestContextFutureRouteResult" : {
"type" : "object"
},
"AddResponse" : {
"type" : "object",
"required" : [ "sum" ],
"properties" : {
"sum" : {
"type" : "integer",
"format" : "int32"
}
}
},
"AddRequest" : {
"type" : "object",
"required" : [ "numbers" ],
"properties" : {
"numbers" : {
"type" : "array",
"items" : {
"type" : "integer",
"format" : "int32"
}
}
}
},
"Greeting" : {
"type" : "object",
"required" : [ "greeting" ],
"properties" : {
"greeting" : {
"type" : "string"
}
}
}
},
"externalDocs" : {
"description" : "Core Docs",
"url" : "http://acme.com/docs"
}
}
@shockey - this is an edge case when the basePath ends with a \. Since all paths must start with a \ and they are appended to the basePath, the safe solution would be to remove the trailing \ from the basePath if one exists.
@webron same issue here. The extra / is making my api not to recognize the path and returning a 404 in Node.js. Do you guys have a way to reference ealier version of swagger.io petstore in the meantime? The immediate impact is that users are no longer to use Swagger UI to explore the API.
curl -X GET http://localhost:3030//accounts/{account_id}/business-dashboard/map
Thanks!
@dzuluaga - all the older versions are here in the repo, you can just use any of those...
Thanks @webron for the workaround. Will do.
I liked you that guys had been serving the UI and support URL query param. So, I just stuck my OpenAPI spec to it without hosting the UI and passed it around. But I know, hosting the app is not biggie.
Hi everyone- I've just opened a PR that fixes this in swagger-js.
I'm anticipating having the fix for this released in JS and UI on Friday evening.
Confirmed fixed- will be pushing the release to Git and NPM momentarily.
Thanks @shockey. Has it been pushed to the site http://petstore.swagger.io? I've just tried it and I'm still seeing the the double slash today. I thought I saw it yesterday fixed.
@dzuluaga, doesn't look like it- the test spec I created for this issue is creating a double slash on petstore.swagger.io, but works for me with Swagger-UI 3.0.5 locally.
@fehguy, can you advise on when the site will be updated?
The process it not automated yet.
It's updated now
It works! Thank you!
Most helpful comment
Hi everyone- I've just opened a PR that fixes this in swagger-js.
I'm anticipating having the fix for this released in JS and UI on Friday evening.