ruby-grape / grape-swagger

Add OAPI/swagger v2.0 compliant documentation to your grape API
MIT License
1.09k stars 471 forks source link

Documentation says default format is :json, but it responds differently when it's explicitly specified #343

Open ian-kelling opened 8 years ago

ian-kelling commented 8 years ago

When I have this: add_swagger_documentation api_version: 'v1', mount_path: '/api_docs' $ curl url/api_docs I get a ruby hash string. $ curl url/api_docs.json I get a json document

add_swagger_documentation api_version: 'v1', mount_path: '/api_docs', format: :json $ curl url/api_docs I get a json document $ curl url/api_docs.json I get 404

The documentation claims that the first should be identical to the second (that is the meaning of a default).

And of course, the documentation claims the response format will be json by default, but I got a ruby hash in a string.

dblock commented 8 years ago

So is the unexpected part the 404 when you try to get the .json one in the second example and get back a 404?

The swagger docs are mounted within a Grape API, so there's the format of the documentation, but then there's the whole request/accept negotiation of the content format in the way.

ian-kelling commented 8 years ago

Your docs say a == b, when actually a != b. And you ask whether a or b is unexpected... neither, the expectation is that the docs match the behaviour. The solution is to change either a or b or the docs. I did not propose which of the 3 should happen.

And then separately, docs claim json will be output but it's not. Again, I do not propose a solution.

I think my report was pretty clear.

dblock commented 8 years ago

I am all for making this clear, but someone other than me needs to dig into this and figure out whether and what should be fixed.