open_api_import 0.10.4 → 0.10.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/open_api_import.rb +14 -13
- 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: bf4a735fd2ca50a6f7d5070a96fef58896e1783834f586548deb943cee3aac49
|
4
|
+
data.tar.gz: 148fca2cc536cd64fbe1b70d21f902810659d67579922ae04cfaeda621400f17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d31884dda9909b9e6bba2eec6fbfb83967a8d3d4b35e5e0826027e066a2f42c7a496d021257ec905f1b54a47da3e05177dab7bd3d7a8d0ba9ea3547edbd52166
|
7
|
+
data.tar.gz: 0c35baa4265c34312f2c2b6866a7197ecb3403a230dccdba20b03f04282674e3e97b6c1f80fd4142862788a351b759802a172a880b967de1e95a357a17cc9471
|
data/lib/open_api_import.rb
CHANGED
@@ -388,15 +388,17 @@ class OpenApiImport
|
|
388
388
|
end
|
389
389
|
end
|
390
390
|
|
391
|
-
|
392
|
-
|
391
|
+
#todo: consider check default and insert it
|
392
|
+
if dpv.key?(:type)
|
393
|
+
params_data << get_examples({dpk => dpv}, :only_value, true).join
|
394
|
+
params_data[-1].chop!.chop! if params_data[-1].to_s[-2..-1]==', '
|
395
|
+
params_data.pop if params_data[-1].match?(/^\s*$/im)
|
393
396
|
else
|
394
|
-
#todo: consider check default and insert it
|
395
397
|
if valv.to_s == ""
|
396
398
|
valv = '"' + valv + '"'
|
397
399
|
end
|
400
|
+
params_data << "#{dpk}: #{valv}"
|
398
401
|
end
|
399
|
-
params_data << "#{dpk}: #{valv}"
|
400
402
|
}
|
401
403
|
|
402
404
|
if params_data.size > 0
|
@@ -730,14 +732,14 @@ class OpenApiImport
|
|
730
732
|
else
|
731
733
|
#todo: differ between response examples and data examples
|
732
734
|
if type == :only_value
|
733
|
-
example << get_response_examples({schema: val}).join("\n")
|
735
|
+
example << get_response_examples({schema: val}, remove_readonly).join("\n")
|
734
736
|
else
|
735
|
-
example << " #{prop.to_sym}: " + get_response_examples({schema: val}).join("\n") + ", "
|
737
|
+
example << " #{prop.to_sym}: " + get_response_examples({schema: val}, remove_readonly).join("\n") + ", "
|
736
738
|
end
|
737
739
|
end
|
738
740
|
when "object"
|
739
741
|
#todo: differ between response examples and data examples
|
740
|
-
res_ex = get_response_examples({schema: val})
|
742
|
+
res_ex = get_response_examples({schema: val}, remove_readonly)
|
741
743
|
if res_ex.size == 0
|
742
744
|
res_ex = "{ }"
|
743
745
|
else
|
@@ -755,7 +757,7 @@ class OpenApiImport
|
|
755
757
|
end
|
756
758
|
|
757
759
|
# Retrieve the response examples from the hash
|
758
|
-
private def get_response_examples(v)
|
760
|
+
private def get_response_examples(v, remove_readonly = false)
|
759
761
|
# TODO: take in consideration the case allOf, oneOf... schema.items.allOf[0].properties schema.items.allOf[1].properties
|
760
762
|
# example on https://github.com/OAI/OpenAPI-Specification/blob/master/examples/v2.0/yaml/petstore-expanded.yaml
|
761
763
|
v=v.dup
|
@@ -765,7 +767,6 @@ class OpenApiImport
|
|
765
767
|
v[:content][:'application/json'].key?(:schema)
|
766
768
|
v=v[:content][:'application/json'].dup
|
767
769
|
end
|
768
|
-
|
769
770
|
if v.key?(:examples) && v[:examples].is_a?(Hash) && v[:examples].key?(:'application/json')
|
770
771
|
if v[:examples][:'application/json'].is_a?(String)
|
771
772
|
response_example << v[:examples][:'application/json']
|
@@ -817,9 +818,9 @@ class OpenApiImport
|
|
817
818
|
end
|
818
819
|
elsif v.key?(:schema) && v[:schema].is_a?(Hash) &&
|
819
820
|
(v[:schema].key?(:properties) ||
|
820
|
-
|
821
|
-
|
822
|
-
|
821
|
+
(v[:schema].key?(:items) && v[:schema][:items].key?(:properties)) ||
|
822
|
+
(v[:schema].key?(:items) && v[:schema][:items].key?(:allOf)) ||
|
823
|
+
v[:schema].key?(:allOf))
|
823
824
|
properties = {}
|
824
825
|
if v[:schema].key?(:properties)
|
825
826
|
properties = v[:schema][:properties]
|
@@ -837,7 +838,7 @@ class OpenApiImport
|
|
837
838
|
response_example << "["
|
838
839
|
end
|
839
840
|
|
840
|
-
response_example += get_examples(properties) unless properties.empty?
|
841
|
+
response_example += get_examples(properties, :key_value, remove_readonly) unless properties.empty?
|
841
842
|
|
842
843
|
unless response_example.empty?
|
843
844
|
if v[:schema].key?(:properties) || v[:schema].key?(:allOf)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: open_api_import
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mario Ruiz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oas_parser
|