weak_swagger_parameters 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6211a459cdc615888d19c200cba93e408dbaac6ddd97f68bb354d7430cf7e1ad
|
4
|
+
data.tar.gz: 97458b2dc2281a480e8b462aed40015b6442ad972f9cf9de0102a33a0c7288ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7602c71a0dea1a2b2726177d98027b4c266a2be9a871fc32a93571d65549b7957409819353af6efc0ad3366cf40d26836bdc63d5d5969a15314be10bcb28ee22
|
7
|
+
data.tar.gz: aa0a83fef2dc58c7bf50886ad3948b28becd40a1315567e88924e25305c9e61ef720a5438a6d27c76242f2bc6d7eb1a6d8c70bb7e22d5d5f71e774b88f8f35a0
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module WeakSwaggerParameters
|
4
|
+
module Definitions
|
5
|
+
class ArrayProperty
|
6
|
+
include WeakSwaggerParameters::Definitions::PropertyContainer
|
7
|
+
|
8
|
+
def initialize(name, description, item_type, &block)
|
9
|
+
@name = name
|
10
|
+
@description = description
|
11
|
+
@item_type = item_type
|
12
|
+
|
13
|
+
instance_eval(&block) if block.present?
|
14
|
+
end
|
15
|
+
|
16
|
+
def apply_validations(parent_node)
|
17
|
+
name = @name
|
18
|
+
|
19
|
+
parent_node.instance_eval do
|
20
|
+
array name
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def apply_docs(parent_node)
|
25
|
+
name = @name
|
26
|
+
description = @description
|
27
|
+
item_type = @item_type
|
28
|
+
definitions = child_definitions
|
29
|
+
|
30
|
+
parent_node.instance_eval do
|
31
|
+
schema_node = Swagger::Blocks::SchemaNode.call(version: version, inline_keys: nil)
|
32
|
+
definitions.each { |definition| definition.apply_docs(schema_node) }
|
33
|
+
|
34
|
+
property name, description: description, type: :array do
|
35
|
+
items do
|
36
|
+
if definitions.any?
|
37
|
+
key :type, :object
|
38
|
+
key :properties, schema_node.as_json[:properties]
|
39
|
+
else
|
40
|
+
key :type, item_type
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -30,6 +30,11 @@ module WeakSwaggerParameters
|
|
30
30
|
register_definition(name, options, WeakSwaggerParameters::Definitions::ModelProperty.new(name, description, model_class))
|
31
31
|
end
|
32
32
|
|
33
|
+
def array(name, description, options = {}, &block)
|
34
|
+
item_type = options[:item_type] || block || (raise StandardError('missing :item_type option'))
|
35
|
+
register_definition(name, options, WeakSwaggerParameters::Definitions::ArrayProperty.new(name, description, item_type, &block))
|
36
|
+
end
|
37
|
+
|
33
38
|
def collection(name, description, model_class, options = {})
|
34
39
|
register_definition(name, options, WeakSwaggerParameters::Definitions::CollectionProperty.new(name, description, model_class))
|
35
40
|
end
|
@@ -4,6 +4,7 @@ require 'weak_swagger_parameters/definitions/leaf_definition'
|
|
4
4
|
require 'weak_swagger_parameters/definitions/param_container'
|
5
5
|
require 'weak_swagger_parameters/definitions/property_container'
|
6
6
|
require 'weak_swagger_parameters/definitions/hash_property'
|
7
|
+
require 'weak_swagger_parameters/definitions/array_property'
|
7
8
|
require 'weak_swagger_parameters/definitions/collection_property'
|
8
9
|
require 'weak_swagger_parameters/definitions/model_property'
|
9
10
|
require 'weak_swagger_parameters/definitions/parameter'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: weak_swagger_parameters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AgileFreaks
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -186,6 +186,7 @@ files:
|
|
186
186
|
- lib/weak_swagger_parameters/controller.rb
|
187
187
|
- lib/weak_swagger_parameters/definitions.rb
|
188
188
|
- lib/weak_swagger_parameters/definitions/api.rb
|
189
|
+
- lib/weak_swagger_parameters/definitions/array_property.rb
|
189
190
|
- lib/weak_swagger_parameters/definitions/body.rb
|
190
191
|
- lib/weak_swagger_parameters/definitions/collection_property.rb
|
191
192
|
- lib/weak_swagger_parameters/definitions/collection_ref.rb
|
@@ -228,8 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
228
229
|
- !ruby/object:Gem::Version
|
229
230
|
version: '0'
|
230
231
|
requirements: []
|
231
|
-
|
232
|
-
rubygems_version: 2.6.11
|
232
|
+
rubygems_version: 3.0.6
|
233
233
|
signing_key:
|
234
234
|
specification_version: 4
|
235
235
|
summary: Generate docs and Validate request parameters
|