swagger_autogenerate 0.1.1 → 1.0.1
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/CHANGELOG.md +1 -0
- data/lib/swagger_autogenerate/swagger_trace.rb +27 -25
- data/lib/swagger_autogenerate/version.rb +1 -1
- data/swagger_autogenerate-0.1.0.gem +0 -0
- data/swagger_autogenerate-0.1.1.gem +0 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a79f228421fcf8a16a00e06ca839087079f3682a75b59a60db6b80711010958
|
4
|
+
data.tar.gz: f8ee425bfb9d3a65905ebd1a03c527b2d55b52590f217b5e2a400760f964d373
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5867cf7d6d7dd713a5eb84eb2a1f9f222ad7c9e299a99a572fdad5596ddb181d9a47c217cc32345b4cae98aac8af09c9684738cd526d4b481f8282ae932bc90
|
7
|
+
data.tar.gz: 4e58b9f677e91a2811bbbd866ab948f0a5976312e5c7a8df1584337c4dc32d149cb6dd7bac946210abaf4fc14058bcde3ca76419055704d467ff965e830e23d4
|
data/CHANGELOG.md
CHANGED
@@ -13,12 +13,14 @@ module SwaggerAutogenerate
|
|
13
13
|
def initialize(request, response)
|
14
14
|
@request = request
|
15
15
|
@response = response
|
16
|
-
|
16
|
+
@paths = {}
|
17
17
|
end
|
18
18
|
|
19
19
|
def call
|
20
|
-
|
21
|
-
|
20
|
+
if ENV[SWAGGER_ENVIRONMENT_VARIABLE].present?
|
21
|
+
read_swagger_trace
|
22
|
+
write_swagger_trace
|
23
|
+
end
|
22
24
|
end
|
23
25
|
|
24
26
|
private
|
@@ -27,7 +29,7 @@ module SwaggerAutogenerate
|
|
27
29
|
|
28
30
|
# main methods
|
29
31
|
|
30
|
-
def
|
32
|
+
def read_swagger_trace
|
31
33
|
path = request.path
|
32
34
|
|
33
35
|
request.path_parameters.except(:controller, :format, :action).each do |k, v|
|
@@ -49,13 +51,13 @@ module SwaggerAutogenerate
|
|
49
51
|
}
|
50
52
|
|
51
53
|
hash[method].except!('requestBody') if hash[method]['requestBody'].blank?
|
52
|
-
paths[path.to_s] ||= {}
|
53
|
-
paths[path.to_s].merge!(hash)
|
54
|
+
@paths[path.to_s] ||= {}
|
55
|
+
@paths[path.to_s].merge!(hash)
|
54
56
|
end
|
55
57
|
|
56
|
-
def
|
57
|
-
if paths[current_path][request.method.downcase].present?
|
58
|
-
paths[current_path][request.method.downcase]['responses'] = swagger_response
|
58
|
+
def write_swagger_trace
|
59
|
+
if @paths[current_path][request.method.downcase].present?
|
60
|
+
@paths[current_path][request.method.downcase]['responses'] = swagger_response
|
59
61
|
end
|
60
62
|
|
61
63
|
if File.exist?(swagger_location)
|
@@ -68,7 +70,7 @@ module SwaggerAutogenerate
|
|
68
70
|
def create_file
|
69
71
|
File.open(swagger_location, 'w') do |file|
|
70
72
|
data = WITH_CONFIG ? swagger_config : {}
|
71
|
-
data['paths'] = paths
|
73
|
+
data['paths'] = @paths
|
72
74
|
organize_result(data['paths'])
|
73
75
|
data = data.to_hash
|
74
76
|
result = add_quotes_to_dates(YAML.dump(data))
|
@@ -83,15 +85,15 @@ module SwaggerAutogenerate
|
|
83
85
|
permitted_classes: [Symbol, Date, ActiveSupport::HashWithIndifferentAccess]
|
84
86
|
)
|
85
87
|
|
86
|
-
return create_file if yaml_file.nil? || yaml_file['paths'].nil?
|
88
|
+
return create_file if @yaml_file.nil? || @yaml_file['paths'].nil?
|
87
89
|
|
88
|
-
yaml_file.merge!(swagger_config) if WITH_CONFIG
|
90
|
+
@yaml_file.merge!(swagger_config) if WITH_CONFIG
|
89
91
|
|
90
92
|
apply_yaml_file_changes
|
91
|
-
organize_result(yaml_file['paths'])
|
92
|
-
@yaml_file = convert_to_hash(yaml_file)
|
93
|
+
organize_result(@yaml_file['paths'])
|
94
|
+
@yaml_file = convert_to_hash(@yaml_file)
|
93
95
|
File.open(swagger_location, 'w') do |file|
|
94
|
-
result = add_quotes_to_dates(YAML.dump(yaml_file))
|
96
|
+
result = add_quotes_to_dates(YAML.dump(@yaml_file))
|
95
97
|
file.write(result)
|
96
98
|
end
|
97
99
|
end
|
@@ -296,7 +298,7 @@ module SwaggerAutogenerate
|
|
296
298
|
# Static
|
297
299
|
|
298
300
|
def paths
|
299
|
-
|
301
|
+
@paths ||= {}
|
300
302
|
end
|
301
303
|
|
302
304
|
def security
|
@@ -418,7 +420,7 @@ module SwaggerAutogenerate
|
|
418
420
|
|
419
421
|
def check_path
|
420
422
|
unless old_paths.key?(current_path)
|
421
|
-
yaml_file['paths'].merge!({ current_path => paths[current_path] })
|
423
|
+
yaml_file['paths'].merge!({ current_path => @paths[current_path] })
|
422
424
|
end
|
423
425
|
end
|
424
426
|
|
@@ -442,29 +444,29 @@ module SwaggerAutogenerate
|
|
442
444
|
|
443
445
|
def check_parameters
|
444
446
|
if old_paths[current_path][request.method.downcase]['parameters'].blank?
|
445
|
-
yaml_file['paths'][current_path][request.method.downcase]['parameters'] = paths[current_path][request.method.downcase]['parameters']
|
447
|
+
yaml_file['paths'][current_path][request.method.downcase]['parameters'] = @paths[current_path][request.method.downcase]['parameters']
|
446
448
|
end
|
447
449
|
end
|
448
450
|
|
449
451
|
def check_parameter
|
450
|
-
param_names = paths[current_path][request.method.downcase]['parameters'].pluck('name') - yaml_file['paths'][current_path][request.method.downcase]['parameters'].pluck('name')
|
452
|
+
param_names = @paths[current_path][request.method.downcase]['parameters'].pluck('name') - yaml_file['paths'][current_path][request.method.downcase]['parameters'].pluck('name')
|
451
453
|
param_names.each do |param_name|
|
452
|
-
param = paths[current_path][request.method.downcase]['parameters'].find { |parameter| parameter['name'] == param_name }
|
454
|
+
param = @paths[current_path][request.method.downcase]['parameters'].find { |parameter| parameter['name'] == param_name }
|
453
455
|
yaml_file['paths'][current_path][request.method.downcase]['parameters'].push(param)
|
454
456
|
end
|
455
457
|
end
|
456
458
|
|
457
459
|
def check_request_bodys
|
458
|
-
if paths[current_path][request.method.downcase]['requestBody'].present? && old_paths[current_path][request.method.downcase]['requestBody'].nil?
|
459
|
-
yaml_file['paths'][current_path][request.method.downcase]['requestBody'] = paths[current_path][request.method.downcase]['requestBody']
|
460
|
+
if @paths[current_path][request.method.downcase]['requestBody'].present? && old_paths[current_path][request.method.downcase]['requestBody'].nil?
|
461
|
+
yaml_file['paths'][current_path][request.method.downcase]['requestBody'] = @paths[current_path][request.method.downcase]['requestBody']
|
460
462
|
end
|
461
463
|
end
|
462
464
|
|
463
465
|
def check_request_body
|
464
|
-
if paths[current_path][request.method.downcase]['requestBody'].present?
|
465
|
-
param_names = paths[current_path][request.method.downcase]['requestBody']['content']['multipart/form-data']['schema']['properties'].keys - yaml_file['paths'][current_path][request.method.downcase]['requestBody']['content']['multipart/form-data']['schema']['properties'].keys
|
466
|
+
if @paths[current_path][request.method.downcase]['requestBody'].present?
|
467
|
+
param_names = @paths[current_path][request.method.downcase]['requestBody']['content']['multipart/form-data']['schema']['properties'].keys - yaml_file['paths'][current_path][request.method.downcase]['requestBody']['content']['multipart/form-data']['schema']['properties'].keys
|
466
468
|
param_names.each do |param_name|
|
467
|
-
param = paths[current_path][request.method.downcase]['requestBody']['content']['multipart/form-data']['schema']['properties'].select { |parameter| parameter == param_name }
|
469
|
+
param = @paths[current_path][request.method.downcase]['requestBody']['content']['multipart/form-data']['schema']['properties'].select { |parameter| parameter == param_name }
|
468
470
|
yaml_file['paths'][current_path][request.method.downcase]['requestBody']['content']['multipart/form-data']['schema']['properties'].merge!(param)
|
469
471
|
end
|
470
472
|
end
|
Binary file
|
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: swagger_autogenerate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MohammedBuraiah
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-05-
|
11
|
+
date: 2024-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Generating Swagger YAML Automatically Based on Existing Test Cases in
|
14
14
|
Ruby on Rails
|
@@ -29,6 +29,8 @@ files:
|
|
29
29
|
- lib/swagger_autogenerate/swagger_trace.rb
|
30
30
|
- lib/swagger_autogenerate/version.rb
|
31
31
|
- sig/swagger_autogenerate.rbs
|
32
|
+
- swagger_autogenerate-0.1.0.gem
|
33
|
+
- swagger_autogenerate-0.1.1.gem
|
32
34
|
- swagger_autogenerate.gemspec
|
33
35
|
homepage: https://github.com/MohammedBuraiah/swagger_autogenerate
|
34
36
|
licenses:
|