Skip to content

Commit 118ecae

Browse files
authored
Examples in body params (#833)
* examples in body * changelog entry
1 parent 19cd0dd commit 118ecae

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#### Fixes
88

9-
* Your contribution here.
9+
* [#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)
1010

1111

1212
### 1.4.0 (March 20, 2021)

lib/grape-swagger/doc_methods/move_params.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def parse_model(ref)
181181
end
182182

183183
def property_keys
184-
%i[type format description minimum maximum items enum default additionalProperties]
184+
%i[type format description minimum maximum items enum default additionalProperties example]
185185
end
186186

187187
def deletable?(param)

spec/support/the_paths_definitions.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
produces: ['application/json'],
99
consumes: ['application/json'],
1010
parameters: [
11-
{ in: 'body', name: 'in_body_1', description: 'in_body_1', type: 'integer', format: 'int32', required: true },
11+
{ in: 'body', name: 'in_body_1', description: 'in_body_1', type: 'integer', format: 'int32', required: true, example: 23 },
1212
{ in: 'body', name: 'in_body_2', description: 'in_body_2', type: 'string', required: false },
1313
{ in: 'body', name: 'in_body_3', description: 'in_body_3', type: 'string', required: false }
1414
],
@@ -31,7 +31,7 @@
3131
{ in: 'path', name: 'key', description: nil, type: 'integer', format: 'int32', required: true },
3232
{ in: 'body', name: 'in_body_1', description: 'in_body_1', type: 'integer', format: 'int32', required: true },
3333
{ in: 'body', name: 'in_body_2', description: 'in_body_2', type: 'string', required: false },
34-
{ in: 'body', name: 'in_body_3', description: 'in_body_3', type: 'string', required: false }
34+
{ in: 'body', name: 'in_body_3', description: 'in_body_3', type: 'string', required: false, example: 'my example string' }
3535
],
3636
responses: { 200 => { description: 'put in body /wo entity', schema: { '$ref' => '#/definitions/InBody' } } },
3737
tags: ['in_body'],
@@ -85,7 +85,7 @@
8585
{
8686
type: 'object',
8787
properties: {
88-
in_body_1: { type: 'integer', format: 'int32', description: 'in_body_1' },
88+
in_body_1: { type: 'integer', format: 'int32', description: 'in_body_1', example: 23 },
8989
in_body_2: { type: 'string', description: 'in_body_2' },
9090
in_body_3: { type: 'string', description: 'in_body_3' }
9191
},
@@ -99,7 +99,7 @@
9999
properties: {
100100
in_body_1: { type: 'integer', format: 'int32', description: 'in_body_1' },
101101
in_body_2: { type: 'string', description: 'in_body_2' },
102-
in_body_3: { type: 'string', description: 'in_body_3' }
102+
in_body_3: { type: 'string', description: 'in_body_3', example: 'my example string' }
103103
},
104104
required: [:in_body_1]
105105
}

0 commit comments

Comments
 (0)