open_api_import 0.10.9 → 0.10.11
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 +21 -18
- metadata +25 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ff3ff403e355b1f422b8d005c1302c2c22f77507d2c1785fe5446050e044096
|
4
|
+
data.tar.gz: 5f2c733cac57f1db5e88504e3aba1db7b61241378ecdb89d7ed68e1012e95012
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 583ae4003d2bb422e87cd0502b4f0cd317ffbb0919c1113d44d8173546dee5afdb32a0e8b62b1bea89aa18a713c4b8fb2a6299a90ed2de233c9d1890aeffcdd5
|
7
|
+
data.tar.gz: f392b2a77e39447efec45dca83a13deb22d2561e96432487a7bf25861b95d9e059006311fd316fa6e989de22b66c6d3c981e6d0c80b60cca9618b75364ded7f0
|
data/lib/open_api_import.rb
CHANGED
@@ -218,7 +218,7 @@ class OpenApiImport
|
|
218
218
|
|
219
219
|
output << ""
|
220
220
|
output << "# operationId: #{cont[:operationId]}, method: #{met}"
|
221
|
-
output << "# summary: #{cont[:summary]}"
|
221
|
+
output << "# summary: #{cont[:summary]}"
|
222
222
|
if !cont[:description].to_s.split("\n").empty?
|
223
223
|
output << "# description: "
|
224
224
|
cont[:description].to_s.split("\n").each do |d|
|
@@ -238,14 +238,12 @@ class OpenApiImport
|
|
238
238
|
data_pattern += get_patterns('', v[:schema]) if v.key?(:schema)
|
239
239
|
data_pattern.uniq!
|
240
240
|
v[:description] = v[:description].to_s.gsub("'", %q(\\\'))
|
241
|
-
|
242
241
|
if !response_example.empty?
|
243
242
|
responses << "'#{k}': { "
|
244
243
|
responses << "message: '#{v[:description]}', "
|
245
244
|
responses << "data: "
|
246
245
|
responses << response_example
|
247
|
-
responses << "},"
|
248
|
-
|
246
|
+
responses << "},"
|
249
247
|
if mock_response and mock_example.size==0
|
250
248
|
mock_example << "code: '#{k}',"
|
251
249
|
mock_example << "message: '#{v[:description]}',"
|
@@ -254,9 +252,8 @@ class OpenApiImport
|
|
254
252
|
end
|
255
253
|
|
256
254
|
else
|
257
|
-
responses << "'#{k}': { message: '#{v[:description]}'}, "
|
255
|
+
responses << "'#{k}': { message: '#{v[:description]}'}, "
|
258
256
|
end
|
259
|
-
|
260
257
|
end
|
261
258
|
end
|
262
259
|
# todo: for open api 3.0 add the new Link feature: https://swagger.io/docs/specification/links/
|
@@ -295,18 +292,19 @@ class OpenApiImport
|
|
295
292
|
params_path << param_name
|
296
293
|
end
|
297
294
|
#params_required << param_name if p[:required].to_s=="true"
|
298
|
-
description_parameters << "# #{p[:name]}: (#{type}) #{"(required)" if p[:required].to_s=="true"} #{p[:description]}"
|
295
|
+
description_parameters << "# #{p[:name]}: (#{type}) #{"(required)" if p[:required].to_s=="true"} #{p[:description].split("\n").join("\n#\t\t\t")}"
|
299
296
|
end
|
300
297
|
elsif p[:in] == "query"
|
301
298
|
params_query << p[:name]
|
302
299
|
params_required << p[:name] if p[:required].to_s=="true"
|
303
|
-
description_parameters << "# #{p[:name]}: (#{type}) #{"(required)" if p[:required].to_s=="true"} #{p[:description]}"
|
300
|
+
description_parameters << "# #{p[:name]}: (#{type}) #{"(required)" if p[:required].to_s=="true"} #{p[:description].split("\n").join("\n#\t\t\t")}"
|
304
301
|
elsif p[:in] == "formData" or p[:in] == "formdata"
|
305
302
|
#todo: take in consideration: default, required
|
306
303
|
#todo: see if we should add the required as params to the method and not required as options
|
307
304
|
#todo: set on data the required fields with the values from args
|
308
305
|
|
309
|
-
description_parameters << "# #{p[:name]}: (#{p[:type]}) #{p[:description]}"
|
306
|
+
description_parameters << "# #{p[:name]}: (#{p[:type]}) #{p[:description].split("\n").join("\n#\t\t\t")}"
|
307
|
+
|
310
308
|
case p[:type]
|
311
309
|
when /^string$/i
|
312
310
|
data_form << "#{p[:name]}: ''"
|
@@ -368,9 +366,10 @@ class OpenApiImport
|
|
368
366
|
valv = ""
|
369
367
|
end
|
370
368
|
end
|
369
|
+
|
371
370
|
if dpv.keys.include?(:description)
|
372
371
|
description_parameters << "# #{dpk}: (#{dpv[:type]}) #{dpv[:description].split("\n").join("\n#\t\t\t")}"
|
373
|
-
end
|
372
|
+
end
|
374
373
|
|
375
374
|
data_pattern += get_patterns(dpk,dpv)
|
376
375
|
data_pattern.uniq!
|
@@ -407,9 +406,11 @@ class OpenApiImport
|
|
407
406
|
params_data.pop if params_data[-1].match?(/^\s*$/im)
|
408
407
|
else
|
409
408
|
if valv.to_s == ""
|
410
|
-
valv = '"
|
409
|
+
valv = '""'
|
410
|
+
elsif valv.include?('"')
|
411
|
+
valv.gsub!('"',"'")
|
411
412
|
end
|
412
|
-
params_data << "#{dpk}: #{valv}"
|
413
|
+
params_data << "#{dpk}: #{valv}"
|
413
414
|
end
|
414
415
|
}
|
415
416
|
if params_data.size > 0
|
@@ -705,10 +706,13 @@ class OpenApiImport
|
|
705
706
|
if val[:example].is_a?(Array) and val.key?(:type) and val[:type]=='string'
|
706
707
|
example << " #{prop.to_sym}: \"#{val[:example][0]}\", " # only the first example
|
707
708
|
else
|
708
|
-
|
709
|
-
|
709
|
+
if val[:example].is_a?(String)
|
710
|
+
val[:example].gsub!('"', "'")
|
711
|
+
example << " #{prop.to_sym}: \"#{val[:example]}\", "
|
712
|
+
elsif val[:example].is_a?(Time)
|
713
|
+
example << " #{prop.to_sym}: \"#{val[:example]}\", "
|
710
714
|
else
|
711
|
-
" #{prop.to_sym}: #{val[:example]}, "
|
715
|
+
example << " #{prop.to_sym}: #{val[:example]}, "
|
712
716
|
end
|
713
717
|
end
|
714
718
|
elsif val.key?(:type)
|
@@ -716,7 +720,7 @@ class OpenApiImport
|
|
716
720
|
format = val[:type] if format.to_s == ""
|
717
721
|
case val[:type].downcase
|
718
722
|
when "string"
|
719
|
-
example << " #{prop.to_sym}: \"#{format}\", "
|
723
|
+
example << " #{prop.to_sym}: \"#{format}\", "
|
720
724
|
when "integer", "number"
|
721
725
|
example << " #{prop.to_sym}: 0, "
|
722
726
|
when "boolean"
|
@@ -748,7 +752,7 @@ class OpenApiImport
|
|
748
752
|
example << get_response_examples({schema: val}, remove_readonly).join("\n")
|
749
753
|
else
|
750
754
|
example << " #{prop.to_sym}: " + get_response_examples({schema: val}, remove_readonly).join("\n") + ", "
|
751
|
-
end
|
755
|
+
end
|
752
756
|
end
|
753
757
|
when "object"
|
754
758
|
#todo: differ between response examples and data examples
|
@@ -809,7 +813,6 @@ class OpenApiImport
|
|
809
813
|
else
|
810
814
|
tresp = ""
|
811
815
|
end
|
812
|
-
|
813
816
|
if tresp.is_a?(String)
|
814
817
|
response_example << tresp
|
815
818
|
elsif tresp.is_a?(Hash)
|
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.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mario Ruiz
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oas_parser
|
@@ -53,25 +53,39 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.17'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: activesupport
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 3.8.0
|
62
59
|
- - "~>"
|
63
60
|
- !ruby/object:Gem::Version
|
64
|
-
version: '
|
65
|
-
type: :
|
61
|
+
version: '6.1'
|
62
|
+
type: :runtime
|
66
63
|
prerelease: false
|
67
64
|
version_requirements: !ruby/object:Gem::Requirement
|
68
65
|
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '6.1'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.8'
|
69
76
|
- - ">="
|
70
77
|
- !ruby/object:Gem::Version
|
71
78
|
version: 3.8.0
|
79
|
+
type: :development
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
72
83
|
- - "~>"
|
73
84
|
- !ruby/object:Gem::Version
|
74
85
|
version: '3.8'
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 3.8.0
|
75
89
|
- !ruby/object:Gem::Dependency
|
76
90
|
name: coveralls
|
77
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,8 +142,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
142
|
- !ruby/object:Gem::Version
|
129
143
|
version: '0'
|
130
144
|
requirements: []
|
131
|
-
rubygems_version: 3.
|
132
|
-
signing_key:
|
145
|
+
rubygems_version: 3.2.15
|
146
|
+
signing_key:
|
133
147
|
specification_version: 4
|
134
148
|
summary: OpenApiImport -- Import a Swagger or Open API file and create a Ruby Request
|
135
149
|
Hash file including all requests and responses with all the examples. The file can
|