open_api_import 0.8.9 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/bin/open_api_import +4 -0
- data/lib/open_api_import.rb +13 -10
- metadata +24 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11e41e0bbb6b94eb93ba0e288d579737ad2e046a01e05c31b6cf3ca5f1a1dd1e
|
4
|
+
data.tar.gz: 0d442acb434e846803001f03dab342145bcbd4649ea23d41c407eecec7204537
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf392458a892e7a1e77b64da2af9f4f3c5bfac57d1f49b226e645eaf38ec0baab2577f85e4c22e000cbe5ebf838ca64be7e5ca8b6fe277166405a5069856fc22
|
7
|
+
data.tar.gz: 6fb8d679183ea58ccfdc258c30b3ec428d38bf94b9c723def84cfe0a8e0f2839492b6dcb646fa80cbb292f44c446fce336b5a3c559dd4f683b5939e34991336a
|
data/README.md
CHANGED
@@ -107,6 +107,7 @@ In case no options supplied:
|
|
107
107
|
-f, --create_files It will create a file per module
|
108
108
|
-T, --tags_module It will be used the tags key to create the module name
|
109
109
|
-F, --fixed_module all the requests will be under the module Requests
|
110
|
+
-s, --silent It will display only errors
|
110
111
|
```
|
111
112
|
|
112
113
|
|
data/bin/open_api_import
CHANGED
data/lib/open_api_import.rb
CHANGED
@@ -18,18 +18,19 @@ class OpenApiImport
|
|
18
18
|
# operation_id: it will be used the operationId field but using the snake_case version, for example for listUsers: list_users
|
19
19
|
# operationId: it will be used the operationId field like it is, for example: listUsers
|
20
20
|
# @param name_for_module [Symbol]. (:path, :path_file, :fixed, :tags, :tags_file) (default: :path). How the module names will be created.
|
21
|
+
# @param silent [Boolean]. (default: false) It will display only errors.
|
21
22
|
# path: It will be used the first folder of the path to create the module name, for example the path /users/list will be in the module Users and all the requests from all modules in the same file.
|
22
23
|
# path_file: It will be used the first folder of the path to create the module name, for example the path /users/list will be in the module Users and each module will be in a new requests file.
|
23
24
|
# tags: It will be used the tags key to create the module name, for example the tags: [users,list] will create the module UsersList and all the requests from all modules in the same file.
|
24
25
|
# tags_file: It will be used the tags key to create the module name, for example the tags: [users,list] will create the module UsersList and and each module will be in a new requests file.
|
25
26
|
# fixed: all the requests will be under the module Requests
|
26
27
|
##############################################################################################
|
27
|
-
def self.from(swagger_file, create_method_name: :operation_id, include_responses: true, mock_response: false, name_for_module: :path)
|
28
|
+
def self.from(swagger_file, create_method_name: :operation_id, include_responses: true, mock_response: false, name_for_module: :path, silent: false)
|
28
29
|
begin
|
29
30
|
f = File.new("#{swagger_file}_open_api_import.log", "w")
|
30
31
|
f.sync = true
|
31
32
|
@logger = Logger.new f
|
32
|
-
puts "Logs file: #{swagger_file}_open_api_import.log"
|
33
|
+
puts "Logs file: #{swagger_file}_open_api_import.log" unless silent
|
33
34
|
rescue StandardError => e
|
34
35
|
warn "Not possible to create the Logger file"
|
35
36
|
warn e
|
@@ -140,7 +141,7 @@ class OpenApiImport
|
|
140
141
|
|
141
142
|
# for the case operationId is missing
|
142
143
|
cont[:operationId] = "undefined" unless cont.key?(:operationId)
|
143
|
-
|
144
|
+
|
144
145
|
if create_method_name == :path
|
145
146
|
method_name = (met.to_s + "_" + path.path.to_s).snake_case
|
146
147
|
method_name.chop! if method_name[-1] == "_"
|
@@ -276,9 +277,11 @@ class OpenApiImport
|
|
276
277
|
param_name = p[:name].to_s.snake_case
|
277
278
|
path_txt.gsub!("{#{p[:name]}}", "\#{#{param_name}}")
|
278
279
|
end
|
279
|
-
params_path
|
280
|
-
|
281
|
-
|
280
|
+
unless params_path.include?(param_name)
|
281
|
+
params_path << param_name
|
282
|
+
#params_required << param_name if p[:required].to_s=="true"
|
283
|
+
description_parameters << "# #{p[:name]}: (#{type}) #{"(required)" if p[:required].to_s=="true"} #{p[:description]}"
|
284
|
+
end
|
282
285
|
elsif p[:in] == "query"
|
283
286
|
params_query << p[:name]
|
284
287
|
params_required << p[:name] if p[:required].to_s=="true"
|
@@ -557,7 +560,7 @@ class OpenApiImport
|
|
557
560
|
File.open(requests_file_path, "w") { |file| file.write(output_txt) }
|
558
561
|
res_rufo = `rufo #{requests_file_path}`
|
559
562
|
message = "** Requests file: #{swagger_file}.rb that contains the code of the requests after importing the Swagger file"
|
560
|
-
puts message
|
563
|
+
puts message unless silent
|
561
564
|
@logger.info message
|
562
565
|
@logger.error " Error formating with rufo" unless res_rufo.to_s.match?(/\AFormat:.+$\s*\z/)
|
563
566
|
@logger.error " Syntax Error: #{`ruby -c #{requests_file_path}`}" unless `ruby -c #{requests_file_path}`.include?("Syntax OK")
|
@@ -569,7 +572,7 @@ class OpenApiImport
|
|
569
572
|
|
570
573
|
requires_txt = ""
|
571
574
|
message = "** Generated files that contain the code of the requests after importing the Swagger file: "
|
572
|
-
puts message
|
575
|
+
puts message unless silent
|
573
576
|
@logger.info message
|
574
577
|
files.each do |mod, out_mod|
|
575
578
|
output = output_header + out_mod + output_footer
|
@@ -579,7 +582,7 @@ class OpenApiImport
|
|
579
582
|
File.open(requests_file_path, "w") { |file| file.write(output_txt) }
|
580
583
|
res_rufo = `rufo #{requests_file_path}`
|
581
584
|
message = " - #{requests_file_path}"
|
582
|
-
puts message
|
585
|
+
puts message unless silent
|
583
586
|
@logger.info message
|
584
587
|
@logger.error " Error formating with rufo" unless res_rufo.to_s.match?(/\AFormat:.+$\s*\z/)
|
585
588
|
@logger.error " Syntax Error: #{`ruby -c #{requests_file_path}`}" unless `ruby -c #{requests_file_path}`.include?("Syntax OK")
|
@@ -590,7 +593,7 @@ class OpenApiImport
|
|
590
593
|
res_rufo = `rufo #{requests_file_path}`
|
591
594
|
message = "** File that contains all the requires for all Request files: \n"
|
592
595
|
message += " - #{requests_file_path} "
|
593
|
-
puts message
|
596
|
+
puts message unless silent
|
594
597
|
@logger.info message
|
595
598
|
@logger.error " Error formating with rufo" unless res_rufo.to_s.match?(/\AFormat:.+$\s*\z/)
|
596
599
|
@logger.error " Syntax Error: #{`ruby -c #{requests_file_path}`}" unless `ruby -c #{requests_file_path}`.include?("Syntax OK")
|
metadata
CHANGED
@@ -1,55 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: open_api_import
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mario Ruiz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oas_parser
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 0.19.0
|
20
17
|
- - "~>"
|
21
18
|
- !ruby/object:Gem::Version
|
22
|
-
version: '0.
|
19
|
+
version: '0.22'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.22.2
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- - ">="
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 0.19.0
|
30
27
|
- - "~>"
|
31
28
|
- !ruby/object:Gem::Version
|
32
|
-
version: '0.
|
29
|
+
version: '0.22'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.22.2
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: rufo
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- - ">="
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: 0.7.0
|
40
37
|
- - "~>"
|
41
38
|
- !ruby/object:Gem::Version
|
42
39
|
version: '0.7'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 0.7.0
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
|
-
- - ">="
|
48
|
-
- !ruby/object:Gem::Version
|
49
|
-
version: 0.7.0
|
50
47
|
- - "~>"
|
51
48
|
- !ruby/object:Gem::Version
|
52
49
|
version: '0.7'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 0.7.0
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: nice_hash
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -74,22 +74,22 @@ dependencies:
|
|
74
74
|
name: rspec
|
75
75
|
requirement: !ruby/object:Gem::Requirement
|
76
76
|
requirements:
|
77
|
-
- - ">="
|
78
|
-
- !ruby/object:Gem::Version
|
79
|
-
version: 3.8.0
|
80
77
|
- - "~>"
|
81
78
|
- !ruby/object:Gem::Version
|
82
79
|
version: '3.8'
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 3.8.0
|
83
83
|
type: :development
|
84
84
|
prerelease: false
|
85
85
|
version_requirements: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: 3.8.0
|
90
87
|
- - "~>"
|
91
88
|
- !ruby/object:Gem::Version
|
92
89
|
version: '3.8'
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: 3.8.0
|
93
93
|
- !ruby/object:Gem::Dependency
|
94
94
|
name: coveralls
|
95
95
|
requirement: !ruby/object:Gem::Requirement
|
@@ -146,7 +146,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
146
|
- !ruby/object:Gem::Version
|
147
147
|
version: '0'
|
148
148
|
requirements: []
|
149
|
-
|
149
|
+
rubyforge_project:
|
150
|
+
rubygems_version: 2.7.6
|
150
151
|
signing_key:
|
151
152
|
specification_version: 4
|
152
153
|
summary: OpenApiImport -- Import a Swagger or Open API file and create a Ruby Request
|