ruby-grape / ruby-grape/grape-swagger
Failing to use description for summary when neither detail nor summary are provided
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 1.1k
- Forks
- 479
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 6
Description
Right now, if an endpoint doesn't declare anything beyond the default desc value, the summary field will be empty.
I.e. if this is done:
desc 'A short endpoint description'
get '/endpoint' do
end
The swagger documentation for this endpoint will not contain the summary field. This is a problem because if you then render using something like Swagger UI the resulting rendering will not contain any short description, the line will have just the url, like this:
This seems to me like undesirable behaviour since the endpoint would look more informative if it used the desc value as summary.
This behaviour is right now encoded in specs, although indirectly. There are many specs but one of the simpler cases is in the mounted_target_class_spec which declares an endpoint with just desc but then doesn't expect any summary in the result.
I have a hunch that it didn't used to be like this since the code tries to read the desc attribute of route options and use it as summary but current version of grape never sets that attribute anywhere in the code.
Is this really desirable behaviour or a bug?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in lib/grape-swagger/endpoint.rb around the summary handling at line 142, then run the mounted target example in spec/swagger_v2/mounted_target_class_spec.rb. Compare the endpoint declared with only desc against the generated Swagger output; done means the expected summary behavior is covered by the spec.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- api, documentation
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100