open_api_import 0.11.1 → 0.11.2
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/get_examples.rb +1 -1
- data/lib/open_api_import/open_api_import.rb +12 -4
- metadata +7 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '086658ecb8430c46e04c59f9f7040083c5dd1599c5fc8538a021bdc6f0214d88'
|
4
|
+
data.tar.gz: 1508d5c5c35a315dc13b4a4d71d4b4dba37ab56f96bbc409bf95ff980a4fe2f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef3fb3ee1ada1afd408313b818eaceb7f16dd98a26a0b215004e2a3fba465d4731bed7bae7ead4edf8ed87c1d108b6fe3ff8220d4e289688344ad1172b2c9caa
|
7
|
+
data.tar.gz: 88a71dbd1ac92bb4b9c73dbe9cf8c1146c5667d50cd43eb273afd5bb55e9c1ef1c75fac05ede6ef4b80199960c6b1646308bdcb08833e011ed9a63cca6907d9a
|
@@ -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]}\", "
|
@@ -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 << "},"
|
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.11.
|
4
|
+
version: 0.11.2
|
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-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oas_parser
|
@@ -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
|
@@ -150,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
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
|