ruby-grape / ruby-grape/grape-swagger

how to document implicit (path?) parameters that are in the url path

Open
#831 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
1.1k
Forks
479
Avg merge
2d 14h
Merged PRs (30d)
6

Description

It wasn't immediately clear to me what syntax I would use to document examples and other info for an implicit parameter defined by a symbol in the URL path, e.g.

        desc 'return a specific check', {
          headers: SWAGGER_HEADERS,
        }
        get '/:id' do

as opposed to

        desc 'return a specific check', {
          headers: SWAGGER_HEADERS,
        }
        params do
          requires :id, type: String, documentation: { example: '7', desc: 'Unique Identifier' }
        end
        get '/' do

i tried:

 get '/:id', documentation: { example: '7', desc: 'Unique Identifier' } do

but that didn't seem to work ... at least the presence of a path parameter generates a little chunk of swagger liks this:

          {
            "in": "path",
            "name": "id",
            "type": "integer",
            "format": "int32",
            "required": true
          }

but I was wondering if there was some syntax to add an example and/or desc to this ...

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 with the issue's two Grape route examples and the generated Swagger path-parameter output. Check the project's documentation and parameter-handling entry points for existing syntax covering implicit URL parameters, then verify whether an example and description can be represented. Done means documenting the supported syntax or clarifying that it is not supported.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
api, documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.