swagalicious 0.4.2 → 0.4.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +20 -20
- data/lib/swagalicious/example_helpers.rb +11 -5
- data/lib/swagalicious/extended_schema.rb +1 -1
- data/lib/swagalicious/request_factory.rb +1 -1
- data/lib/swagalicious/swagger_formatter.rb +15 -21
- data/lib/swagalicious/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8fe701583dd2d70b9be1dd659ce40864a5724e982fb3951034135f412bdcca01
|
4
|
+
data.tar.gz: a78071f0d850a70b940dc8e07957241423a1742265cd026a38ca0915cfb2d4f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c306f2b4cb881e8581a4c079b4565789a4cabc3df4388955dde7ca89519eca45234f6c15d7cb9b8550df311afbc5f009a133700cfc4003de5245422ec37db02
|
7
|
+
data.tar.gz: 31e69267fef1575cd91652418c22a7a538c97c9698be86c147980b25b854c9f0918c02ffa26aa3c9863b875cc5912c38a40166255f326a9e9eb94031f9fdd890
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
swagalicious (0.4.
|
4
|
+
swagalicious (0.4.4)
|
5
5
|
faraday (~> 1.3.0)
|
6
6
|
json-schema (~> 2.8.1)
|
7
7
|
oj (~> 3.11.0)
|
@@ -10,41 +10,41 @@ PATH
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
|
-
activesupport (6.1.
|
13
|
+
activesupport (6.1.6)
|
14
14
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
15
15
|
i18n (>= 1.6, < 2)
|
16
16
|
minitest (>= 5.1)
|
17
17
|
tzinfo (~> 2.0)
|
18
18
|
zeitwerk (~> 2.3)
|
19
|
-
addressable (2.
|
19
|
+
addressable (2.8.0)
|
20
20
|
public_suffix (>= 2.0.2, < 5.0)
|
21
21
|
byebug (11.1.3)
|
22
22
|
coderay (1.1.3)
|
23
|
-
concurrent-ruby (1.1.
|
24
|
-
diff-lcs (1.
|
23
|
+
concurrent-ruby (1.1.10)
|
24
|
+
diff-lcs (1.5.0)
|
25
25
|
factory_bot (6.1.0)
|
26
26
|
activesupport (>= 5.0.0)
|
27
|
-
faraday (1.3.
|
27
|
+
faraday (1.3.1)
|
28
28
|
faraday-net_http (~> 1.0)
|
29
29
|
multipart-post (>= 1.2, < 3)
|
30
|
-
ruby2_keywords
|
30
|
+
ruby2_keywords (>= 0.0.4)
|
31
31
|
faraday-net_http (1.0.1)
|
32
|
-
i18n (1.
|
32
|
+
i18n (1.10.0)
|
33
33
|
concurrent-ruby (~> 1.0)
|
34
34
|
json-schema (2.8.1)
|
35
35
|
addressable (>= 2.4)
|
36
36
|
method_source (1.0.0)
|
37
|
-
minitest (5.
|
38
|
-
multipart-post (2.
|
39
|
-
oj (3.11.
|
37
|
+
minitest (5.15.0)
|
38
|
+
multipart-post (2.2.0)
|
39
|
+
oj (3.11.8)
|
40
40
|
pry (0.13.1)
|
41
41
|
coderay (~> 1.1)
|
42
42
|
method_source (~> 1.0)
|
43
43
|
pry-byebug (3.9.0)
|
44
44
|
byebug (~> 11.0)
|
45
45
|
pry (~> 0.13.0)
|
46
|
-
public_suffix (4.0.
|
47
|
-
rack (2.2.3)
|
46
|
+
public_suffix (4.0.7)
|
47
|
+
rack (2.2.3.1)
|
48
48
|
rack-test (1.1.0)
|
49
49
|
rack (>= 1.0, < 3)
|
50
50
|
rake (12.3.3)
|
@@ -52,19 +52,19 @@ GEM
|
|
52
52
|
rspec-core (~> 3.10.0)
|
53
53
|
rspec-expectations (~> 3.10.0)
|
54
54
|
rspec-mocks (~> 3.10.0)
|
55
|
-
rspec-core (3.10.
|
55
|
+
rspec-core (3.10.2)
|
56
56
|
rspec-support (~> 3.10.0)
|
57
|
-
rspec-expectations (3.10.
|
57
|
+
rspec-expectations (3.10.2)
|
58
58
|
diff-lcs (>= 1.2.0, < 2.0)
|
59
59
|
rspec-support (~> 3.10.0)
|
60
|
-
rspec-mocks (3.10.
|
60
|
+
rspec-mocks (3.10.3)
|
61
61
|
diff-lcs (>= 1.2.0, < 2.0)
|
62
62
|
rspec-support (~> 3.10.0)
|
63
|
-
rspec-support (3.10.
|
64
|
-
ruby2_keywords (0.0.
|
63
|
+
rspec-support (3.10.3)
|
64
|
+
ruby2_keywords (0.0.5)
|
65
65
|
tzinfo (2.0.4)
|
66
66
|
concurrent-ruby (~> 1.0)
|
67
|
-
zeitwerk (2.4
|
67
|
+
zeitwerk (2.5.4)
|
68
68
|
|
69
69
|
PLATFORMS
|
70
70
|
ruby
|
@@ -78,4 +78,4 @@ DEPENDENCIES
|
|
78
78
|
swagalicious!
|
79
79
|
|
80
80
|
BUNDLED WITH
|
81
|
-
2.2.
|
81
|
+
2.2.31
|
@@ -52,16 +52,22 @@ class Swagalicious
|
|
52
52
|
metadata[:paths] ||= []
|
53
53
|
metadata[:paths] << request[:path]
|
54
54
|
|
55
|
-
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
|
-
metadata[:response][:examples] ||= {}
|
55
|
+
metadata[:response][:requestBody] ||= {}
|
56
|
+
metadata[:response][:examples] ||= {}
|
60
57
|
|
61
58
|
mime_types = metadata[:response][:produces] || ["application/json"]
|
62
59
|
full_title = metadata[:swagger_example_name] || "#{metadata[:operation][:summary]}: #{metadata[:description]}"
|
63
60
|
|
64
61
|
mime_types.each do |mime_type|
|
62
|
+
if request[:payload]
|
63
|
+
metadata[:response][:requestBody][:content] ||= {}
|
64
|
+
metadata[:response][:requestBody][:content][mime_type] ||= {}
|
65
|
+
metadata[:response][:requestBody][:content][mime_type][:examples] ||= {}
|
66
|
+
metadata[:response][:requestBody][:content][mime_type][:examples][full_title] ||= {}
|
67
|
+
|
68
|
+
metadata[:response][:requestBody][:content][mime_type][:examples][full_title][:value] = Oj.load(request[:payload]).dup
|
69
|
+
end
|
70
|
+
|
65
71
|
metadata[:response][:examples][mime_type] ||= {}
|
66
72
|
metadata[:response][:examples][mime_type][full_title] = @body
|
67
73
|
end
|
@@ -12,7 +12,7 @@ class Swagalicious
|
|
12
12
|
|
13
13
|
class ExtendedTypeAttribute < JSON::Schema::TypeV4Attribute
|
14
14
|
def self.validate(current_schema, data, fragments, processor, validator, options={})
|
15
|
-
return if data.nil? && current_schema.schema["null"] == true
|
15
|
+
return if data.nil? && (current_schema.schema["null"] == true || current_schema.schema["nullable"] == true)
|
16
16
|
super
|
17
17
|
end
|
18
18
|
end
|
@@ -86,7 +86,7 @@ class Swagalicious
|
|
86
86
|
end
|
87
87
|
|
88
88
|
def add_path(request, metadata, swagger_doc, parameters, example)
|
89
|
-
template = (swagger_doc[:basePath] || "") + metadata[:path_item][:template]
|
89
|
+
template = (swagger_doc[:basePath] || (swagger_doc[:servers]&.first || {})[:url] || "") + metadata[:path_item][:template]
|
90
90
|
|
91
91
|
request[:path] = template.tap do |path_template|
|
92
92
|
parameters.select { |p| p[:in] == :path }.each do |p|
|
@@ -31,27 +31,6 @@ class Swagalicious
|
|
31
31
|
upgrade_response_produces!(doc, metadata)
|
32
32
|
upgrade_request_type!(metadata)
|
33
33
|
|
34
|
-
unless doc_version(doc).start_with?("2")
|
35
|
-
doc[:paths]&.each_pair do |_k, v|
|
36
|
-
v.each_pair do |_verb, value|
|
37
|
-
is_hash = value.is_a?(Hash)
|
38
|
-
if is_hash && value.dig(:parameters)
|
39
|
-
schema_param = value.dig(:parameters)&.find { |p| (p[:in] == :body || p[:in] == :formData) && p[:schema] }
|
40
|
-
mime_list = value.dig(:consumes)
|
41
|
-
if value && schema_param && mime_list
|
42
|
-
value[:requestBody] = { content: {} } unless value.dig(:requestBody, :content)
|
43
|
-
mime_list.each do |mime|
|
44
|
-
value[:requestBody][:content][mime] = { schema: schema_param[:schema] }
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
value[:parameters].reject! { |p| p[:in] == :body || p[:in] == :formData }
|
49
|
-
end
|
50
|
-
remove_invalid_operation_keys!(value)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
34
|
doc.deep_merge!(metadata_to_swagger(metadata))
|
56
35
|
end
|
57
36
|
|
@@ -93,6 +72,7 @@ class Swagalicious
|
|
93
72
|
response_code = metadata[:response][:code]
|
94
73
|
response = metadata[:response].reject { |k, _v| k == :code }
|
95
74
|
examples = response.delete(:examples) || []
|
75
|
+
body = response.delete(:requestBody) || {}
|
96
76
|
|
97
77
|
examples.each do |mime_type, titles|
|
98
78
|
titles.each do |title, example|
|
@@ -111,6 +91,20 @@ class Swagalicious
|
|
111
91
|
.reject { |k, _v| k == :verb }
|
112
92
|
.merge(responses: { response_code => response })
|
113
93
|
|
94
|
+
is_hash = operation.is_a?(Hash)
|
95
|
+
if is_hash && operation.dig(:parameters)
|
96
|
+
schema_param = operation.dig(:parameters)&.find { |p| (p[:in] == :body || p[:in] == :formData) && p[:schema] }
|
97
|
+
mime_list = operation.dig(:consumes)
|
98
|
+
if operation && schema_param && mime_list
|
99
|
+
operation[:requestBody] = { content: {} }
|
100
|
+
mime_list.each do |mime|
|
101
|
+
operation[:requestBody][:content][mime] = { schema: schema_param[:schema] }.merge((body.dig(:content, mime) || {}))
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
operation[:parameters].reject! { |p| p[:in] == :body || p[:in] == :formData }
|
106
|
+
end
|
107
|
+
|
114
108
|
path_template = metadata[:path_item][:template]
|
115
109
|
path_item = metadata[:path_item]
|
116
110
|
.reject { |k, _v| k == :template }
|
data/lib/swagalicious/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: swagalicious
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eugene Howe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|