ruby-grape / ruby-grape/grape-swagger

Failing to use description for summary when neither detail nor summary are provided

Open
#734 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug?
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:

screen shot 2018-12-13 at 09 50 34

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.