grape-swagger 1.4.1 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +2 -4
- data/.gitignore +1 -0
- data/.rspec +2 -0
- data/CHANGELOG.md +9 -0
- data/Gemfile +1 -1
- data/README.md +31 -0
- data/UPGRADING.md +4 -0
- data/lib/grape-swagger/doc_methods/format_data.rb +2 -0
- data/lib/grape-swagger/doc_methods/move_params.rb +6 -7
- data/lib/grape-swagger/doc_methods/parse_params.rb +31 -5
- data/lib/grape-swagger/rake/oapi_tasks.rb +1 -1
- data/lib/grape-swagger/version.rb +1 -1
- data/spec/issues/832_array_hash_float_decimal_spec.rb +111 -0
- data/spec/swagger_v2/api_swagger_v2_additional_properties_spec.rb +83 -0
- data/spec/swagger_v2/api_swagger_v2_param_type_body_nested_spec.rb +73 -1
- data/spec/swagger_v2/boolean_params_spec.rb +3 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d7b364d5b11e9fb35f7c67ce09c2953a7dd50da37cde1bc5b323bbdf9a3b6e4
|
4
|
+
data.tar.gz: 6c825fe6753c899c7f337253495677596acd40320e5e33f83c7c220e71e03e44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5e2a5c0d06216c3e2a474051b5986a9f8343a351714b3e255396bbef3984704d85436218fa87e39f0988fbb18b3f5227b2531d514a788f4a4b131028dc19de2
|
7
|
+
data.tar.gz: 6bd210a20332285224d0d24036b9892c729fc84c435991b3e36dd81d8d1976d4ae35c406d3e9d742a82bd90acac75903355c6a827380870e6f1deb2af0b17b7f
|
data/.github/workflows/ruby.yml
CHANGED
@@ -13,8 +13,8 @@ jobs:
|
|
13
13
|
runs-on: ubuntu-latest
|
14
14
|
strategy:
|
15
15
|
matrix:
|
16
|
-
ruby-version: ['2.6', '2.7', '3.0']
|
17
|
-
grape-version: [1.
|
16
|
+
ruby-version: ['2.6', '2.7', '3.0', 'head']
|
17
|
+
grape-version: [1.6.0, 1.5.3]
|
18
18
|
model-parser: [grape-swagger-entity, grape-swagger-representable, '']
|
19
19
|
|
20
20
|
steps:
|
@@ -28,5 +28,3 @@ jobs:
|
|
28
28
|
bundler-cache: true
|
29
29
|
- name: Run rspec
|
30
30
|
run: bundle exec rspec
|
31
|
-
- name: Run rubocop
|
32
|
-
run: bundle exec rubocop
|
data/.gitignore
CHANGED
data/.rspec
CHANGED
data/CHANGELOG.md
CHANGED
@@ -9,6 +9,15 @@
|
|
9
9
|
* Your contribution here.
|
10
10
|
|
11
11
|
|
12
|
+
### 1.4.2 (October 22, 2021)
|
13
|
+
|
14
|
+
#### Fixes
|
15
|
+
|
16
|
+
* [#840](https://github.com/ruby-grape/grape-swagger/pull/840): Fixes documentation of `additionalProperties` field when used with array parameters, or when setting it to `false` - [@magni-](https://github.com/magni-)
|
17
|
+
* [#841](https://github.com/ruby-grape/grape-swagger/pull/839): Fixes `type` and `format` values for object fields nested in an array ([#832](https://github.com/ruby-grape/grape-swagger/issue/832)) - [@magni-](https://github.com/magni-)
|
18
|
+
* [#839](https://github.com/ruby-grape/grape-swagger/pull/839): Fixes documentation of `false` or `nil` default parameter values - [@magni-](https://github.com/magni-)
|
19
|
+
|
20
|
+
|
12
21
|
### 1.4.1 (September 15, 2021)
|
13
22
|
|
14
23
|
#### Fixes
|
data/Gemfile
CHANGED
@@ -33,7 +33,7 @@ end
|
|
33
33
|
group :test do
|
34
34
|
gem 'coveralls_reborn', require: false
|
35
35
|
|
36
|
-
gem 'ruby-grape-danger', '~> 0.
|
36
|
+
gem 'ruby-grape-danger', '~> 0.2.0', require: false
|
37
37
|
gem 'simplecov', require: false
|
38
38
|
|
39
39
|
unless ENV['MODEL_PARSER'] == 'grape-swagger-entity'
|
data/README.md
CHANGED
@@ -451,6 +451,7 @@ add_swagger_documentation \
|
|
451
451
|
* [Collection Format](#collection-format)
|
452
452
|
* [Hiding parameters](#hiding-parameters)
|
453
453
|
* [Setting a Swagger default value](#default-value)
|
454
|
+
* [Setting `additionalProperties` for `object`-type parameters](#additional-properties)
|
454
455
|
* [Example parameter value](#param-example)
|
455
456
|
* [Response documentation](#response)
|
456
457
|
* [Changing default status codes](#change-status)
|
@@ -779,6 +780,36 @@ params do
|
|
779
780
|
end
|
780
781
|
```
|
781
782
|
|
783
|
+
### Setting `additionalProperties` for `object`-type parameters <a name="additional-properties">
|
784
|
+
|
785
|
+
Use the `additional_properties` option in the `documentation` hash for `object`-type parameters to set [`additionalProperties`](https://swagger.io/specification/v2/#model-with-mapdictionary-properties).
|
786
|
+
|
787
|
+
#### Allow any additional properties
|
788
|
+
```ruby
|
789
|
+
params do
|
790
|
+
optional :thing, type: Hash, documentation: { additional_properties: true }
|
791
|
+
end
|
792
|
+
```
|
793
|
+
|
794
|
+
#### Allow any additional properties of a particular type
|
795
|
+
```ruby
|
796
|
+
params do
|
797
|
+
optional :thing, type: Hash, documentation: { additional_properties: String }
|
798
|
+
end
|
799
|
+
```
|
800
|
+
|
801
|
+
#### Allow any additional properties matching a defined schema
|
802
|
+
```ruby
|
803
|
+
class Entity < Grape::Entity
|
804
|
+
expose :this
|
805
|
+
end
|
806
|
+
|
807
|
+
params do
|
808
|
+
optional :thing, type: Hash, documentation: { additional_properties: Entity }
|
809
|
+
end
|
810
|
+
```
|
811
|
+
|
812
|
+
|
782
813
|
#### Example parameter value <a name="param-example"></a>
|
783
814
|
|
784
815
|
The example parameter will populate the Swagger UI with the example value, and can be used for optional or required parameters.
|
data/UPGRADING.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
## Upgrading Grape-swagger
|
2
2
|
|
3
|
+
### Upgrading to >= 1.4.2
|
4
|
+
|
5
|
+
- `additionalProperties` has been deprecated and will be removed in a future version of `grape-swagger`. It has been replaced with `additional_properties`.
|
6
|
+
|
3
7
|
### Upgrading to >= 1.4.0
|
4
8
|
|
5
9
|
- Official support for ruby < 2.5 removed, ruby 2.5 only in testing mode, but no support.
|
@@ -35,6 +35,8 @@ module GrapeSwagger
|
|
35
35
|
|
36
36
|
def add_array(parameter, related_parameters)
|
37
37
|
related_parameters.each do |p|
|
38
|
+
next if p.key?(:items)
|
39
|
+
|
38
40
|
p_type = p[:type] == 'array' ? 'string' : p[:type]
|
39
41
|
p[:items] = { type: p_type, format: p[:format], enum: p[:enum], is_array: p[:is_array] }
|
40
42
|
p[:items].delete_if { |_k, v| v.nil? }
|
@@ -103,9 +103,9 @@ module GrapeSwagger
|
|
103
103
|
|
104
104
|
def document_as_property(param)
|
105
105
|
property_keys.each_with_object({}) do |x, memo|
|
106
|
-
|
107
|
-
next if value.blank?
|
106
|
+
next unless param.key?(x)
|
108
107
|
|
108
|
+
value = param[x]
|
109
109
|
if x == :type && @definitions[value].present?
|
110
110
|
memo['$ref'] = "#/definitions/#{value}"
|
111
111
|
else
|
@@ -181,7 +181,8 @@ module GrapeSwagger
|
|
181
181
|
end
|
182
182
|
|
183
183
|
def property_keys
|
184
|
-
%i[type format description minimum maximum items enum default additionalProperties
|
184
|
+
%i[type format description minimum maximum items enum default additional_properties additionalProperties
|
185
|
+
example]
|
185
186
|
end
|
186
187
|
|
187
188
|
def deletable?(param)
|
@@ -193,8 +194,7 @@ module GrapeSwagger
|
|
193
194
|
end
|
194
195
|
|
195
196
|
def includes_body_param?(params)
|
196
|
-
params.
|
197
|
-
false
|
197
|
+
params.any? { |x| x[:in] == 'body' || x[:param_type] == 'body' }
|
198
198
|
end
|
199
199
|
|
200
200
|
def should_expose_as_array?(params)
|
@@ -202,8 +202,7 @@ module GrapeSwagger
|
|
202
202
|
end
|
203
203
|
|
204
204
|
def should_exposed_as(params)
|
205
|
-
params.
|
206
|
-
'array'
|
205
|
+
params.any? { |x| x[:type] && x[:type] != 'array' } ? 'object' : 'array'
|
207
206
|
end
|
208
207
|
end
|
209
208
|
end
|
@@ -25,7 +25,7 @@ module GrapeSwagger
|
|
25
25
|
document_default_value(settings) unless value_type[:is_array]
|
26
26
|
document_range_values(settings) unless value_type[:is_array]
|
27
27
|
document_required(settings)
|
28
|
-
document_additional_properties(settings)
|
28
|
+
document_additional_properties(definitions, settings) unless value_type[:is_array]
|
29
29
|
document_add_extensions(settings)
|
30
30
|
document_example(settings)
|
31
31
|
|
@@ -51,7 +51,7 @@ module GrapeSwagger
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def document_default_value(settings)
|
54
|
-
@parsed_param[:default] = settings[:default] if settings
|
54
|
+
@parsed_param[:default] = settings[:default] if settings.key?(:default)
|
55
55
|
end
|
56
56
|
|
57
57
|
def document_type_and_format(settings, data_type)
|
@@ -105,12 +105,38 @@ module GrapeSwagger
|
|
105
105
|
|
106
106
|
array_items[:default] = value_type[:default] if value_type[:default].present?
|
107
107
|
|
108
|
+
set_additional_properties, additional_properties = parse_additional_properties(definitions, value_type)
|
109
|
+
array_items[:additionalProperties] = additional_properties if set_additional_properties
|
110
|
+
|
108
111
|
array_items
|
109
112
|
end
|
110
113
|
|
111
|
-
def document_additional_properties(settings)
|
112
|
-
additional_properties = settings
|
113
|
-
@parsed_param[:additionalProperties] = additional_properties if
|
114
|
+
def document_additional_properties(definitions, settings)
|
115
|
+
set_additional_properties, additional_properties = parse_additional_properties(definitions, settings)
|
116
|
+
@parsed_param[:additionalProperties] = additional_properties if set_additional_properties
|
117
|
+
end
|
118
|
+
|
119
|
+
def parse_additional_properties(definitions, settings)
|
120
|
+
return false unless settings.key?(:additionalProperties) || settings.key?(:additional_properties)
|
121
|
+
|
122
|
+
value =
|
123
|
+
if settings.key?(:additionalProperties)
|
124
|
+
GrapeSwagger::Errors::SwaggerSpecDeprecated.tell!(:additionalProperties)
|
125
|
+
settings[:additionalProperties]
|
126
|
+
else
|
127
|
+
settings[:additional_properties]
|
128
|
+
end
|
129
|
+
|
130
|
+
parsed_value =
|
131
|
+
if definitions[value.to_s]
|
132
|
+
{ '$ref': "#/definitions/#{value}" }
|
133
|
+
elsif value.is_a?(Class)
|
134
|
+
{ type: DataType.call(value) }
|
135
|
+
else
|
136
|
+
value
|
137
|
+
end
|
138
|
+
|
139
|
+
[true, parsed_value]
|
114
140
|
end
|
115
141
|
|
116
142
|
def document_example(settings)
|
@@ -64,7 +64,7 @@ module GrapeSwagger
|
|
64
64
|
::Rake::Task['oapi:fetch'].invoke
|
65
65
|
exit if error?
|
66
66
|
|
67
|
-
output = system "swagger validate #{file}"
|
67
|
+
output = system "swagger-cli validate #{file}"
|
68
68
|
|
69
69
|
$stdout.puts 'install swagger-cli with `npm install swagger-cli -g`' if output.nil?
|
70
70
|
FileUtils.rm(file)
|
@@ -0,0 +1,111 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe '#832 array of objects with nested Float/BigDecimal fields' do
|
6
|
+
let(:app) do
|
7
|
+
Class.new(Grape::API) do
|
8
|
+
resource :issue_832 do
|
9
|
+
params do
|
10
|
+
requires :array_param, type: Array do
|
11
|
+
requires :float_param, type: Float
|
12
|
+
requires :big_decimal_param, type: BigDecimal
|
13
|
+
requires :object_param, type: Hash do
|
14
|
+
requires :float_param, type: Float
|
15
|
+
requires :big_decimal_param, type: BigDecimal
|
16
|
+
requires :object_param, type: Hash do
|
17
|
+
requires :float_param, type: Float
|
18
|
+
requires :big_decimal_param, type: BigDecimal
|
19
|
+
requires :array_param, type: Array do
|
20
|
+
requires :integer_param, type: Integer
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
post do
|
27
|
+
{ message: 'hello world' }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
add_swagger_documentation
|
32
|
+
end
|
33
|
+
end
|
34
|
+
let(:parameters) { subject['paths']['/issue_832']['post']['parameters'] }
|
35
|
+
|
36
|
+
subject do
|
37
|
+
get '/swagger_doc'
|
38
|
+
JSON.parse(last_response.body)
|
39
|
+
end
|
40
|
+
|
41
|
+
specify do
|
42
|
+
expect(parameters).to eql(
|
43
|
+
[
|
44
|
+
{
|
45
|
+
'in' => 'formData',
|
46
|
+
'name' => 'array_param[float_param]',
|
47
|
+
'type' => 'array',
|
48
|
+
'required' => true,
|
49
|
+
'items' => {
|
50
|
+
'type' => 'number',
|
51
|
+
'format' => 'float'
|
52
|
+
}
|
53
|
+
}, {
|
54
|
+
'in' => 'formData',
|
55
|
+
'name' => 'array_param[big_decimal_param]',
|
56
|
+
'type' => 'array',
|
57
|
+
'required' => true,
|
58
|
+
'items' => {
|
59
|
+
'type' => 'number',
|
60
|
+
'format' => 'double'
|
61
|
+
}
|
62
|
+
}, {
|
63
|
+
'in' => 'formData',
|
64
|
+
'name' => 'array_param[object_param][float_param]',
|
65
|
+
'type' => 'array',
|
66
|
+
'required' => true,
|
67
|
+
'items' => {
|
68
|
+
'type' => 'number',
|
69
|
+
'format' => 'float'
|
70
|
+
}
|
71
|
+
}, {
|
72
|
+
'in' => 'formData',
|
73
|
+
'name' => 'array_param[object_param][big_decimal_param]',
|
74
|
+
'type' => 'array',
|
75
|
+
'required' => true,
|
76
|
+
'items' => {
|
77
|
+
'type' => 'number',
|
78
|
+
'format' => 'double'
|
79
|
+
}
|
80
|
+
}, {
|
81
|
+
'in' => 'formData',
|
82
|
+
'name' => 'array_param[object_param][object_param][float_param]',
|
83
|
+
'type' => 'array',
|
84
|
+
'required' => true,
|
85
|
+
'items' => {
|
86
|
+
'type' => 'number',
|
87
|
+
'format' => 'float'
|
88
|
+
}
|
89
|
+
}, {
|
90
|
+
'in' => 'formData',
|
91
|
+
'name' => 'array_param[object_param][object_param][big_decimal_param]',
|
92
|
+
'type' => 'array',
|
93
|
+
'required' => true,
|
94
|
+
'items' => {
|
95
|
+
'type' => 'number',
|
96
|
+
'format' => 'double'
|
97
|
+
}
|
98
|
+
}, {
|
99
|
+
'in' => 'formData',
|
100
|
+
'name' => 'array_param[object_param][object_param][array_param][integer_param]',
|
101
|
+
'type' => 'array',
|
102
|
+
'required' => true,
|
103
|
+
'items' => {
|
104
|
+
'type' => 'integer',
|
105
|
+
'format' => 'int32'
|
106
|
+
}
|
107
|
+
}
|
108
|
+
]
|
109
|
+
)
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe 'parsing additional_parameters' do
|
6
|
+
let(:app) do
|
7
|
+
Class.new(Grape::API) do
|
8
|
+
namespace :things do
|
9
|
+
class Element < Grape::Entity
|
10
|
+
expose :id
|
11
|
+
end
|
12
|
+
|
13
|
+
params do
|
14
|
+
optional :closed, type: Hash, documentation: { additional_properties: false, in: 'body' } do
|
15
|
+
requires :only
|
16
|
+
end
|
17
|
+
optional :open, type: Hash, documentation: { additional_properties: true }
|
18
|
+
optional :type_limited, type: Hash, documentation: { additional_properties: String }
|
19
|
+
optional :ref_limited, type: Hash, documentation: { additional_properties: Element }
|
20
|
+
optional :fallback, type: Hash, documentation: { additional_properties: { type: 'integer' } }
|
21
|
+
end
|
22
|
+
post do
|
23
|
+
present params
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
add_swagger_documentation format: :json, models: [Element]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
subject do
|
32
|
+
get '/swagger_doc/things'
|
33
|
+
JSON.parse(last_response.body)
|
34
|
+
end
|
35
|
+
|
36
|
+
describe 'POST' do
|
37
|
+
specify do
|
38
|
+
expect(subject.dig('paths', '/things', 'post', 'parameters')).to eql(
|
39
|
+
[
|
40
|
+
{ 'name' => 'Things', 'in' => 'body', 'required' => true, 'schema' => { '$ref' => '#/definitions/postThings' } }
|
41
|
+
]
|
42
|
+
)
|
43
|
+
end
|
44
|
+
|
45
|
+
specify do
|
46
|
+
expect(subject.dig('definitions', 'postThings')).to eql(
|
47
|
+
'type' => 'object',
|
48
|
+
'properties' => {
|
49
|
+
'closed' => {
|
50
|
+
'type' => 'object',
|
51
|
+
'additionalProperties' => false,
|
52
|
+
'properties' => {
|
53
|
+
'only' => { 'type' => 'string' }
|
54
|
+
},
|
55
|
+
'required' => ['only']
|
56
|
+
},
|
57
|
+
'open' => {
|
58
|
+
'type' => 'object',
|
59
|
+
'additionalProperties' => true
|
60
|
+
},
|
61
|
+
'type_limited' => {
|
62
|
+
'type' => 'object',
|
63
|
+
'additionalProperties' => {
|
64
|
+
'type' => 'string'
|
65
|
+
}
|
66
|
+
},
|
67
|
+
'ref_limited' => {
|
68
|
+
'type' => 'object',
|
69
|
+
'additionalProperties' => {
|
70
|
+
'$ref' => '#/definitions/Element'
|
71
|
+
}
|
72
|
+
},
|
73
|
+
'fallback' => {
|
74
|
+
'type' => 'object',
|
75
|
+
'additionalProperties' => {
|
76
|
+
'type' => 'integer'
|
77
|
+
}
|
78
|
+
}
|
79
|
+
}
|
80
|
+
)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -13,7 +13,7 @@ describe 'moving body/formData Params to definitions' do
|
|
13
13
|
detail: 'more details description',
|
14
14
|
success: Entities::UseNestedWithAddress
|
15
15
|
params do
|
16
|
-
optional :contact, type: Hash do
|
16
|
+
optional :contact, type: Hash, documentation: { additional_properties: true } do
|
17
17
|
requires :name, type: String, documentation: { desc: 'name', in: 'body' }
|
18
18
|
optional :addresses, type: Array do
|
19
19
|
requires :street, type: String, documentation: { desc: 'street', in: 'body' }
|
@@ -96,6 +96,27 @@ describe 'moving body/formData Params to definitions' do
|
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
99
|
+
namespace :nested_params_array do
|
100
|
+
desc 'post in body with array of nested parameters',
|
101
|
+
detail: 'more details description',
|
102
|
+
success: Entities::UseNestedWithAddress
|
103
|
+
params do
|
104
|
+
optional :contacts, type: Array, documentation: { additional_properties: false } do
|
105
|
+
requires :name, type: String, documentation: { desc: 'name', in: 'body' }
|
106
|
+
optional :addresses, type: Array do
|
107
|
+
requires :street, type: String, documentation: { desc: 'street', in: 'body' }
|
108
|
+
requires :postcode, type: String, documentation: { desc: 'postcode', in: 'body' }
|
109
|
+
requires :city, type: String, documentation: { desc: 'city', in: 'body' }
|
110
|
+
optional :country, type: String, documentation: { desc: 'country', in: 'body' }
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
post '/in_body' do
|
116
|
+
{ 'declared_params' => declared(params) }
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
99
120
|
add_swagger_documentation
|
100
121
|
end
|
101
122
|
end
|
@@ -126,6 +147,7 @@ describe 'moving body/formData Params to definitions' do
|
|
126
147
|
'properties' => {
|
127
148
|
'contact' => {
|
128
149
|
'type' => 'object',
|
150
|
+
'additionalProperties' => true,
|
129
151
|
'properties' => {
|
130
152
|
'name' => { 'type' => 'string', 'description' => 'name' },
|
131
153
|
'addresses' => {
|
@@ -280,4 +302,54 @@ describe 'moving body/formData Params to definitions' do
|
|
280
302
|
end
|
281
303
|
end
|
282
304
|
end
|
305
|
+
|
306
|
+
describe 'array of nested body parameters given' do
|
307
|
+
subject do
|
308
|
+
get '/swagger_doc/nested_params_array'
|
309
|
+
JSON.parse(last_response.body)
|
310
|
+
end
|
311
|
+
|
312
|
+
describe 'POST' do
|
313
|
+
specify do
|
314
|
+
expect(subject['paths']['/nested_params_array/in_body']['post']['parameters']).to eql(
|
315
|
+
[
|
316
|
+
{ 'name' => 'NestedParamsArrayInBody', 'in' => 'body', 'required' => true, 'schema' => { '$ref' => '#/definitions/postNestedParamsArrayInBody' } }
|
317
|
+
]
|
318
|
+
)
|
319
|
+
end
|
320
|
+
|
321
|
+
specify do
|
322
|
+
expect(subject['definitions']['postNestedParamsArrayInBody']).to eql(
|
323
|
+
'type' => 'object',
|
324
|
+
'properties' => {
|
325
|
+
'contacts' => {
|
326
|
+
'type' => 'array',
|
327
|
+
'items' => {
|
328
|
+
'type' => 'object',
|
329
|
+
'additionalProperties' => false,
|
330
|
+
'properties' => {
|
331
|
+
'name' => { 'type' => 'string', 'description' => 'name' },
|
332
|
+
'addresses' => {
|
333
|
+
'type' => 'array',
|
334
|
+
'items' => {
|
335
|
+
'type' => 'object',
|
336
|
+
'properties' => {
|
337
|
+
'street' => { 'type' => 'string', 'description' => 'street' },
|
338
|
+
'postcode' => { 'type' => 'string', 'description' => 'postcode' },
|
339
|
+
'city' => { 'type' => 'string', 'description' => 'city' },
|
340
|
+
'country' => { 'type' => 'string', 'description' => 'country' }
|
341
|
+
},
|
342
|
+
'required' => %w[street postcode city]
|
343
|
+
}
|
344
|
+
}
|
345
|
+
},
|
346
|
+
'required' => %w[name]
|
347
|
+
}
|
348
|
+
}
|
349
|
+
},
|
350
|
+
'description' => 'post in body with array of nested parameters'
|
351
|
+
)
|
352
|
+
end
|
353
|
+
end
|
354
|
+
end
|
283
355
|
end
|
@@ -9,6 +9,7 @@ describe 'Boolean Params' do
|
|
9
9
|
|
10
10
|
params do
|
11
11
|
requires :a_boolean, type: Grape::API::Boolean
|
12
|
+
optional :another_boolean, type: Grape::API::Boolean, default: false
|
12
13
|
end
|
13
14
|
post :splines do
|
14
15
|
{ message: 'hi' }
|
@@ -27,7 +28,8 @@ describe 'Boolean Params' do
|
|
27
28
|
|
28
29
|
it 'converts boolean types' do
|
29
30
|
expect(subject).to eq [
|
30
|
-
{ 'in' => 'formData', 'name' => 'a_boolean', 'type' => 'boolean', 'required' => true }
|
31
|
+
{ 'in' => 'formData', 'name' => 'a_boolean', 'type' => 'boolean', 'required' => true },
|
32
|
+
{ 'in' => 'formData', 'name' => 'another_boolean', 'type' => 'boolean', 'required' => false, 'default' => false }
|
31
33
|
]
|
32
34
|
end
|
33
35
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grape-swagger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- LeFnord
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-
|
12
|
+
date: 2021-10-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: grape
|
@@ -102,6 +102,7 @@ files:
|
|
102
102
|
- spec/issues/776_multiple_presents_spec.rb
|
103
103
|
- spec/issues/784_extensions_on_params_spec.rb
|
104
104
|
- spec/issues/809_utf8_routes_spec.rb
|
105
|
+
- spec/issues/832_array_hash_float_decimal_spec.rb
|
105
106
|
- spec/lib/data_type_spec.rb
|
106
107
|
- spec/lib/endpoint/params_parser_spec.rb
|
107
108
|
- spec/lib/endpoint_spec.rb
|
@@ -127,6 +128,7 @@ files:
|
|
127
128
|
- spec/support/namespace_tags.rb
|
128
129
|
- spec/support/the_paths_definitions.rb
|
129
130
|
- spec/swagger_v2/api_documentation_spec.rb
|
131
|
+
- spec/swagger_v2/api_swagger_v2_additional_properties_spec.rb
|
130
132
|
- spec/swagger_v2/api_swagger_v2_body_definitions_spec.rb
|
131
133
|
- spec/swagger_v2/api_swagger_v2_definitions-models_spec.rb
|
132
134
|
- spec/swagger_v2/api_swagger_v2_detail_spec.rb
|
@@ -230,6 +232,7 @@ test_files:
|
|
230
232
|
- spec/issues/776_multiple_presents_spec.rb
|
231
233
|
- spec/issues/784_extensions_on_params_spec.rb
|
232
234
|
- spec/issues/809_utf8_routes_spec.rb
|
235
|
+
- spec/issues/832_array_hash_float_decimal_spec.rb
|
233
236
|
- spec/lib/data_type_spec.rb
|
234
237
|
- spec/lib/endpoint/params_parser_spec.rb
|
235
238
|
- spec/lib/endpoint_spec.rb
|
@@ -255,6 +258,7 @@ test_files:
|
|
255
258
|
- spec/support/namespace_tags.rb
|
256
259
|
- spec/support/the_paths_definitions.rb
|
257
260
|
- spec/swagger_v2/api_documentation_spec.rb
|
261
|
+
- spec/swagger_v2/api_swagger_v2_additional_properties_spec.rb
|
258
262
|
- spec/swagger_v2/api_swagger_v2_body_definitions_spec.rb
|
259
263
|
- spec/swagger_v2/api_swagger_v2_definitions-models_spec.rb
|
260
264
|
- spec/swagger_v2/api_swagger_v2_detail_spec.rb
|