ruby-grape / ruby-grape/grape-swagger

Should not document examples for non-schema parameters

Open
#884 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

As documented in the OpenAPI v2 spec, the example keyword only appears in schema objects and not parameter objects. If the example keyword appears in a parameter object, the OpenAPI validator returns the following error:

Structural error at paths./api/test
should NOT have additional properties additionalProperty: example

The root cause is that document_example adds the example keyword without check if the parameter is a schema/body type:

        def document_example(settings)
          example = settings[:example]
          @parsed_param[:example] = example if example
        end

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 by locating the document_example method shown in the issue and inspect how parameter types are represented in @parsed_param. Reproduce the OpenAPI validator error for a non-schema parameter, then verify that example remains documented for schema/body parameters while being omitted elsewhere.

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
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.