Reputation: 2683
I'm using the grape-swagger
gem and I'm being unable to get a Grape-based API properly described in Swagger.
Using: grape (0.11.0)
and grape-swagger (0.10.1)
When I enable the Swagger json listing I get this output listing all endpoints but not the methods contained in each endpoint.
My output:
{
"apiVersion": "v0",
"swaggerVersion": "1.2",
"produces": [
"application/json"
],
"apis": [
{
"path": "/version.{format}",
"description": "Operations about versions"
},
{
"path": "/ping.{format}",
"description": "Operations about pings"
},
{
"path": "/users.{format}",
"description": "Operations about users"
},
{
"path": "/company.{format}",
"description": "Operations about companies"
},
{
"path": "/merchants.{format}",
"description": "Operations about merchants"
}
],
"info": {}
}
I've also added CORS Allowance in config.ru like this:
require 'rack/cors'
use Rack::Cors do
allow do
origins '*'
resource '*',
headers: :any,
methods: [:get, :post, :put, :delete, :options]
end
end
Any clue on how to get methods for each endpoint listed inside?
Upvotes: 0
Views: 346
Reputation: 14840
That's just not how Swagger 1.2 works.
Assuming you get the above JSON at /api-docs
, try opening /api-docs/version.json
for example to see the operations for version
. Of course, if it's not hosted under /api-docs
, just replace that part with whichever path segment is actually used.
Upvotes: 1