ruby-grape / grape-swagger

Add OAPI/swagger v2.0 compliant documentation to your grape API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Should not document examples for non-schema parameters

spaceraccoon opened this issue · comments

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