Reputation: 4945
I have deployed a test Grape REST API and I am trying to test it with Swagger UI.
The problem is that when Swagger UI loads the API specification it adds parenthesis to the suffix: http://arcane-shore-2642.herokuapp.com/api/v1/todos(.json)
This causes a 404 error since (.json) suffix is not valid.
The URL it calls should look like this: http://arcane-shore-2642.herokuapp.com/api/v1/todos
Or this: http://arcane-shore-2642.herokuapp.com/api/v1/todos.json
How can I fix this?
More valid routes:
http://arcane-shore-2642.herokuapp.com/api/v1/todos/1
http://arcane-shore-2642.herokuapp.com/api/v1/items/1
http://arcane-shore-2642.herokuapp.com/api/v1/todos/1/items
http://arcane-shore-2642.herokuapp.com/api/v1/todos/1.json
http://arcane-shore-2642.herokuapp.com/api/v1/items/1.json
http://arcane-shore-2642.herokuapp.com/api/v1/todos/1/items.json
Upvotes: 0
Views: 807
Reputation: 36
I have encountered the same problem today. It's because original API spec data came from grape-swagger
gem has the "(.json)" (or format) suffix.
{
apiVersion: "0.1",
swaggerVersion: "1.2",
resourcePath: "/hotels",
produces: [
"application/json"
],
apis: [
{
path: "/hotels.{format}",
operations: [
...
There's a configuration setting hide_format
to the add_swagger_documentation
which can hide the format suffix. However, option hide_format
still has issue in latest released version of grape-swagger
(0.10.1) with latest grape
(0.12.0).
So we need to specify the developing grape-swagger
and then set hide_format
.
Gemfile
gem 'grape-swagger', github: "tim-vandecasteele/grape-swagger"
Your root API
add_swagger_documentation hide_format: true
Upvotes: 1