open_api_import 0.11.1 → 0.11.3
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
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2898c6734c8b0816229742064e145a6c3c48d8a4b4969c4cc4a032a7efaec90a
|
4
|
+
data.tar.gz: 2966b9d5e861f8857c964645d9b7089b43c08ae7cb564aff99ddae3a94025ec0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f606dfb92494c7ceed2298c55f56b3666edeb2605af2e8b9f5876d450fbce214152a7efc3efe03423613533a15c4899406e2121f31992bd3689d90c85cdf5bdc
|
7
|
+
data.tar.gz: 16ae0345a060a5feabef4eaaae4d1eb7f11fb3a01decd58c59aaa020564812f8509999d56220bcc30f06168ae6556d7b4c9274a972719fe4b9491af0a67266fa
|
@@ -17,7 +17,7 @@ module LibOpenApiImport
|
|
17
17
|
example << " #{prop.to_sym}: \"#{val[:example][0]}\", " # only the first example
|
18
18
|
else
|
19
19
|
if val[:example].is_a?(String)
|
20
|
-
val[:example].gsub!('"', "'")
|
20
|
+
val[:example].gsub!('"', "'") unless val.include?("'")
|
21
21
|
example << " #{prop.to_sym}: \"#{val[:example]}\", "
|
22
22
|
elsif val[:example].is_a?(Time)
|
23
23
|
example << " #{prop.to_sym}: \"#{val[:example]}\", "
|
@@ -36,11 +36,11 @@ module LibOpenApiImport
|
|
36
36
|
when "boolean"
|
37
37
|
example << " #{prop.to_sym}: true, "
|
38
38
|
when "array"
|
39
|
-
if val.key?(:items) and val[:items].
|
39
|
+
if val.key?(:items) and val[:items].is_a?(Hash) and val[:items].size == 1 and val[:items].key?(:type)
|
40
40
|
val[:items][:enum] = [val[:items][:type]]
|
41
41
|
end
|
42
42
|
|
43
|
-
if val.key?(:items) and val[:items].key?(:enum)
|
43
|
+
if val.key?(:items) and !val[:items].nil? and val[:items].key?(:enum)
|
44
44
|
#before we were getting in all these cases a random value from the enum, now we are getting the first position by default
|
45
45
|
#the reason is to avoid confusion later in case we want to compare two swaggers and verify the changes
|
46
46
|
if type == :only_value
|
@@ -60,8 +60,8 @@ module LibOpenApiImport
|
|
60
60
|
end
|
61
61
|
elsif v.key?(:schema) && v[:schema].is_a?(Hash) &&
|
62
62
|
(v[:schema].key?(:properties) ||
|
63
|
-
(v[:schema].key?(:items) && v[:schema][:items].key?(:properties)) ||
|
64
|
-
(v[:schema].key?(:items) && v[:schema][:items].key?(:allOf)) ||
|
63
|
+
(v[:schema].key?(:items) && v[:schema][:items].is_a?(Hash) && v[:schema][:items].key?(:properties)) ||
|
64
|
+
(v[:schema].key?(:items) && v[:schema][:items].is_a?(Hash) && v[:schema][:items].key?(:allOf)) ||
|
65
65
|
v[:schema].key?(:allOf))
|
66
66
|
properties = {}
|
67
67
|
if v[:schema].key?(:properties)
|
@@ -89,7 +89,7 @@ module LibOpenApiImport
|
|
89
89
|
response_example << "]"
|
90
90
|
end
|
91
91
|
end
|
92
|
-
elsif v.key?(:schema) and v[:schema].key?(:items) and v[:schema][:items].key?(:type)
|
92
|
+
elsif v.key?(:schema) and v[:schema].key?(:items) and v[:schema][:items].is_a?(Hash) and v[:schema][:items].key?(:type)
|
93
93
|
# for the case only type supplied but nothing else for the array
|
94
94
|
response_example << "[\"#{v[:schema][:items][:type]}\"]"
|
95
95
|
end
|
@@ -52,12 +52,12 @@ class OpenApiImport
|
|
52
52
|
begin
|
53
53
|
definition = OasParser::Definition.resolve(swagger_file)
|
54
54
|
rescue Exception => stack
|
55
|
-
message = "There was a problem parsing the Open Api document using the
|
56
|
-
message += "Visit the github for
|
55
|
+
message = "There was a problem parsing the Open Api document using the oas_parser_reborn gem. The execution was aborted.\n"
|
56
|
+
message += "Visit the github for oas_parser_reborn gem for bugs and more info: https://github.com/MarioRuiz/oas_parser_reborn\n"
|
57
57
|
message += "Error: #{stack.message}"
|
58
58
|
puts message
|
59
59
|
@logger.fatal message
|
60
|
-
@logger.fatal stack.backtrace
|
60
|
+
@logger.fatal stack.backtrace.join("\n")
|
61
61
|
exit!
|
62
62
|
end
|
63
63
|
|
@@ -209,7 +209,7 @@ class OpenApiImport
|
|
209
209
|
|
210
210
|
output << ""
|
211
211
|
output << "# operationId: #{cont[:operationId]}, method: #{met}"
|
212
|
-
output << "# summary: #{cont[:summary]}"
|
212
|
+
output << "# summary: #{cont[:summary].split("\n").join("\n# ")}" if cont.key?(:summary)
|
213
213
|
if !cont[:description].to_s.split("\n").empty?
|
214
214
|
output << "# description: "
|
215
215
|
cont[:description].to_s.split("\n").each do |d|
|
@@ -284,12 +284,14 @@ class OpenApiImport
|
|
284
284
|
params_path << param_name
|
285
285
|
end
|
286
286
|
#params_required << param_name if p[:required].to_s=="true"
|
287
|
-
|
287
|
+
@logger.warn "Description key is missing for #{met} #{path.path} #{p[:name]}" if p[:description].nil?
|
288
|
+
description_parameters << "# #{p[:name]}: (#{type}) #{"(required)" if p[:required].to_s == "true"} #{p[:description].to_s.split("\n").join("\n#\t\t\t")}"
|
288
289
|
end
|
289
290
|
elsif p[:in] == "query"
|
290
291
|
params_query << p[:name]
|
291
292
|
params_required << p[:name] if p[:required].to_s == "true"
|
292
|
-
|
293
|
+
@logger.warn "Description key is missing for #{met} #{path.path} #{p[:name]}" if p[:description].nil?
|
294
|
+
description_parameters << "# #{p[:name]}: (#{type}) #{"(required)" if p[:required].to_s == "true"} #{p[:description].to_s.split("\n").join("\n#\t\t\t")}"
|
293
295
|
elsif p[:in] == "formData" or p[:in] == "formdata"
|
294
296
|
#todo: take in consideration: default, required
|
295
297
|
#todo: see if we should add the required as params to the method and not required as options
|
@@ -403,7 +405,7 @@ class OpenApiImport
|
|
403
405
|
if valv.to_s == ""
|
404
406
|
valv = '""'
|
405
407
|
elsif valv.include?('"')
|
406
|
-
valv.gsub!('"', "'")
|
408
|
+
valv.gsub!('"', "'") unless valv.include?("'")
|
407
409
|
end
|
408
410
|
params_data << "#{dpk}: #{valv}"
|
409
411
|
end
|
@@ -539,8 +541,12 @@ class OpenApiImport
|
|
539
541
|
begin
|
540
542
|
data_examples[0].uniq!
|
541
543
|
data_ex = eval("{#{data_examples[0].join(", ")}}")
|
544
|
+
rescue SyntaxError
|
545
|
+
data_ex = {}
|
546
|
+
@logger.warn "Syntax error: #{met} for path: #{path.path} evaluating data_examples[0] => #{data_examples[0].inspect}"
|
542
547
|
rescue
|
543
548
|
data_ex = {}
|
549
|
+
@logger.warn "Syntax error: #{met} for path: #{path.path} evaluating data_examples[0] => #{data_examples[0].inspect}"
|
544
550
|
end
|
545
551
|
if (data_required.grep(/\./)).empty?
|
546
552
|
reqdata = filter(data_ex, data_required) #not nested
|
@@ -548,6 +554,7 @@ class OpenApiImport
|
|
548
554
|
reqdata = filter(data_ex, data_required, true) #nested
|
549
555
|
end
|
550
556
|
unless reqdata.empty?
|
557
|
+
reqdata.uniq!
|
551
558
|
phsd = pretty_hash_symbolized(reqdata)
|
552
559
|
phsd[0] = "data: {"
|
553
560
|
output += phsd
|
@@ -569,6 +576,7 @@ class OpenApiImport
|
|
569
576
|
reqdata << edata unless read_only
|
570
577
|
end
|
571
578
|
unless reqdata.empty?
|
579
|
+
reqdata.uniq!
|
572
580
|
output << "data: {"
|
573
581
|
output << reqdata.join(", \n")
|
574
582
|
output << "},"
|
data/lib/open_api_import.rb
CHANGED
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: open_api_import
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mario Ruiz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: oas_parser_reborn
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
@@ -30,28 +30,28 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 0.16.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 0.16.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: nice_hash
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '1.
|
47
|
+
version: '1.18'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '1.
|
54
|
+
version: '1.18'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: activesupport
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,26 +86,6 @@ dependencies:
|
|
86
86
|
- - ">="
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: 3.8.0
|
89
|
-
- !ruby/object:Gem::Dependency
|
90
|
-
name: coveralls
|
91
|
-
requirement: !ruby/object:Gem::Requirement
|
92
|
-
requirements:
|
93
|
-
- - "~>"
|
94
|
-
- !ruby/object:Gem::Version
|
95
|
-
version: '0.8'
|
96
|
-
- - ">="
|
97
|
-
- !ruby/object:Gem::Version
|
98
|
-
version: 0.8.22
|
99
|
-
type: :development
|
100
|
-
prerelease: false
|
101
|
-
version_requirements: !ruby/object:Gem::Requirement
|
102
|
-
requirements:
|
103
|
-
- - "~>"
|
104
|
-
- !ruby/object:Gem::Version
|
105
|
-
version: '0.8'
|
106
|
-
- - ">="
|
107
|
-
- !ruby/object:Gem::Version
|
108
|
-
version: 0.8.22
|
109
89
|
description: OpenApiImport -- Import a Swagger or Open API file and create a Ruby
|
110
90
|
Request Hash file including all requests and responses with all the examples. The
|
111
91
|
file can be in JSON or YAML
|
@@ -143,14 +123,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
143
123
|
requirements:
|
144
124
|
- - ">="
|
145
125
|
- !ruby/object:Gem::Version
|
146
|
-
version: '2.
|
126
|
+
version: '2.7'
|
147
127
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
128
|
requirements:
|
149
129
|
- - ">="
|
150
130
|
- !ruby/object:Gem::Version
|
151
131
|
version: '0'
|
152
132
|
requirements: []
|
153
|
-
rubygems_version: 3.
|
133
|
+
rubygems_version: 3.4.3
|
154
134
|
signing_key:
|
155
135
|
specification_version: 4
|
156
136
|
summary: OpenApiImport -- Import a Swagger or Open API file and create a Ruby Request
|