Assign :example param on array properties (#903)
* Assign :example param on array properties * Update CHANGELOG
This commit is contained in:
parent
55267acd39
commit
a56b56aaf1
|
@ -6,6 +6,7 @@
|
|||
|
||||
#### Fixes
|
||||
|
||||
* [#903](https://github.com/ruby-grape/grape-swagger/pull/903): Accept `example` documentation parameter for arrays - [@VladMomotov](https://github.com/VladMomotov)
|
||||
* Your contribution here.
|
||||
|
||||
|
||||
|
|
|
@ -97,6 +97,7 @@ module GrapeSwagger
|
|||
{}.tap do |property|
|
||||
property[:type] = 'array'
|
||||
property[:description] = param.delete(:description) unless param[:description].nil?
|
||||
property[:example] = param.delete(:example) unless param[:example].nil?
|
||||
property[:items] = document_as_property(param)[:items]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -39,7 +39,7 @@ describe 'Group Params as Array' do
|
|||
# cause it could not be distinguished anymore, so this would be translated to one array,
|
||||
# see also next example for the difference
|
||||
params do
|
||||
requires :array_of_string, type: Array[String], documentation: { param_type: 'body', desc: 'nested array of strings' }
|
||||
requires :array_of_string, type: Array[String], documentation: { param_type: 'body', desc: 'nested array of strings', example: %w[a b] }
|
||||
requires :array_of_integer, type: Array[Integer], documentation: { param_type: 'body', desc: 'nested array of integers' }
|
||||
end
|
||||
|
||||
|
@ -123,7 +123,7 @@ describe 'Group Params as Array' do
|
|||
'type' => 'object',
|
||||
'properties' => {
|
||||
'array_of_string' => {
|
||||
'items' => { 'type' => 'string' }, 'type' => 'array', 'description' => 'nested array of strings'
|
||||
'items' => { 'type' => 'string' }, 'type' => 'array', 'description' => 'nested array of strings', 'example' => %w[a b]
|
||||
},
|
||||
'array_of_integer' => {
|
||||
'items' => { 'type' => 'integer', 'format' => 'int32' }, 'type' => 'array', 'description' => 'nested array of integers'
|
||||
|
|
Loading…
Reference in New Issue