diff --git a/CHANGELOG.md b/CHANGELOG.md index e5915c51e..11096e47f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ #### Fixes -* Your contribution here. +* [#833](https://github.com/ruby-grape/grape-swagger/pull/833): Fixes issue of examples not showing for `in: 'body'` parameters - [@stevenou](https://github.com/stevenou) ### 1.4.0 (March 20, 2021) diff --git a/lib/grape-swagger/doc_methods/move_params.rb b/lib/grape-swagger/doc_methods/move_params.rb index 4a404f4b1..ab1c2e402 100644 --- a/lib/grape-swagger/doc_methods/move_params.rb +++ b/lib/grape-swagger/doc_methods/move_params.rb @@ -181,7 +181,7 @@ def parse_model(ref) end def property_keys - %i[type format description minimum maximum items enum default additionalProperties] + %i[type format description minimum maximum items enum default additionalProperties example] end def deletable?(param) diff --git a/spec/support/the_paths_definitions.rb b/spec/support/the_paths_definitions.rb index df4a75409..3bf43c1e9 100644 --- a/spec/support/the_paths_definitions.rb +++ b/spec/support/the_paths_definitions.rb @@ -8,7 +8,7 @@ produces: ['application/json'], consumes: ['application/json'], parameters: [ - { in: 'body', name: 'in_body_1', description: 'in_body_1', type: 'integer', format: 'int32', required: true }, + { in: 'body', name: 'in_body_1', description: 'in_body_1', type: 'integer', format: 'int32', required: true, example: 23 }, { in: 'body', name: 'in_body_2', description: 'in_body_2', type: 'string', required: false }, { in: 'body', name: 'in_body_3', description: 'in_body_3', type: 'string', required: false } ], @@ -31,7 +31,7 @@ { in: 'path', name: 'key', description: nil, type: 'integer', format: 'int32', required: true }, { in: 'body', name: 'in_body_1', description: 'in_body_1', type: 'integer', format: 'int32', required: true }, { in: 'body', name: 'in_body_2', description: 'in_body_2', type: 'string', required: false }, - { in: 'body', name: 'in_body_3', description: 'in_body_3', type: 'string', required: false } + { in: 'body', name: 'in_body_3', description: 'in_body_3', type: 'string', required: false, example: 'my example string' } ], responses: { 200 => { description: 'put in body /wo entity', schema: { '$ref' => '#/definitions/InBody' } } }, tags: ['in_body'], @@ -85,7 +85,7 @@ { type: 'object', properties: { - in_body_1: { type: 'integer', format: 'int32', description: 'in_body_1' }, + in_body_1: { type: 'integer', format: 'int32', description: 'in_body_1', example: 23 }, in_body_2: { type: 'string', description: 'in_body_2' }, in_body_3: { type: 'string', description: 'in_body_3' } }, @@ -99,7 +99,7 @@ properties: { in_body_1: { type: 'integer', format: 'int32', description: 'in_body_1' }, in_body_2: { type: 'string', description: 'in_body_2' }, - in_body_3: { type: 'string', description: 'in_body_3' } + in_body_3: { type: 'string', description: 'in_body_3', example: 'my example string' } }, required: [:in_body_1] }