swagger_autogenerate 1.2.2 → 1.2.4
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 +2 -0
- data/Gemfile.lock +1 -1
- data/lib/swagger_autogenerate/configuration.rb +3 -2
- data/lib/swagger_autogenerate/swagger_trace.rb +28 -3
- data/lib/swagger_autogenerate/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4d62d2b3204e47e668408ea353aa7f5015a9f1a8f86e727e635b1030e999f587
|
|
4
|
+
data.tar.gz: 7cbcbfc449684fe35db3c76c7c8bb0ae357ebabf8585ba7289c3b6d58abec9a9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f9dea5813fe7a651d4fa59d618b86a02a2e909a23bdcb8744aa56bd96ff667143482d52316b70f78868c2cbbf3de5e2e6104b9cdb8f13e00e6a2483f15ac2da7
|
|
7
|
+
data.tar.gz: a7fa27d728d65a7e8d2fb58dcb052c81d1486a1d3c89b3326851797419cff037e28322eec8284a19f81be1c4121ed9dd33a83605a31ee1606bdccfa61b30c813
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -2,7 +2,7 @@ module SwaggerAutogenerate
|
|
|
2
2
|
class Configuration
|
|
3
3
|
attr_accessor :with_config, :with_multiple_examples, :with_rspec_examples, :with_example_description,
|
|
4
4
|
:with_response_description, :swagger_path_environment_variable, :generate_swagger_environment_variable,
|
|
5
|
-
:default_path, :environment_name, :security, :swagger_config, :response_status
|
|
5
|
+
:default_path, :environment_name, :security, :swagger_config, :response_status, :action_for_old_examples
|
|
6
6
|
|
|
7
7
|
def initialize
|
|
8
8
|
@with_config = true
|
|
@@ -11,7 +11,8 @@ module SwaggerAutogenerate
|
|
|
11
11
|
# remove this when we do not need it any more
|
|
12
12
|
@with_example_description = true
|
|
13
13
|
@with_response_description = true
|
|
14
|
-
@
|
|
14
|
+
@action_for_old_examples = :append # :replace or :append
|
|
15
|
+
@swagger_path_environment_variable = 'SWAGGER_GENERATE_PATH'
|
|
15
16
|
@generate_swagger_environment_variable = 'SWAGGER_GENERATE'
|
|
16
17
|
@default_path = 'swagger'
|
|
17
18
|
@environment_name = :test
|
|
@@ -13,6 +13,7 @@ module SwaggerAutogenerate
|
|
|
13
13
|
@default_path = ::SwaggerAutogenerate.configuration.default_path
|
|
14
14
|
@request = request
|
|
15
15
|
@response = response
|
|
16
|
+
@action_for_old_examples = ::SwaggerAutogenerate.configuration.action_for_old_examples
|
|
16
17
|
@@paths = {}
|
|
17
18
|
end
|
|
18
19
|
|
|
@@ -49,7 +50,8 @@ module SwaggerAutogenerate
|
|
|
49
50
|
|
|
50
51
|
attr_reader :request, :response, :current_path, :yaml_file, :configuration,
|
|
51
52
|
:with_config, :with_multiple_examples, :with_rspec_examples,
|
|
52
|
-
:with_response_description, :security, :response_status, :swagger_config,
|
|
53
|
+
:with_response_description, :security, :response_status, :swagger_config,
|
|
54
|
+
:default_path, :action_for_old_examples
|
|
53
55
|
|
|
54
56
|
# main methods
|
|
55
57
|
|
|
@@ -62,6 +64,9 @@ module SwaggerAutogenerate
|
|
|
62
64
|
|
|
63
65
|
@current_path = path
|
|
64
66
|
method = request.method.to_s.downcase
|
|
67
|
+
|
|
68
|
+
process_replacing_examples
|
|
69
|
+
|
|
65
70
|
hash =
|
|
66
71
|
{
|
|
67
72
|
method => {
|
|
@@ -131,6 +136,26 @@ module SwaggerAutogenerate
|
|
|
131
136
|
|
|
132
137
|
# Helpers
|
|
133
138
|
|
|
139
|
+
def process_replacing_examples
|
|
140
|
+
$removed_examples ||= []
|
|
141
|
+
if action_for_old_examples == :replace && !$removed_examples.include?({ @current_path => request.method.to_s.downcase })
|
|
142
|
+
current_yaml_file = YAML.load(
|
|
143
|
+
File.read(swagger_location),
|
|
144
|
+
aliases: true,
|
|
145
|
+
permitted_classes: [Symbol, Date, ActiveSupport::HashWithIndifferentAccess]
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
current_yaml_file["paths"][@current_path][request.method.to_s.downcase] = {}
|
|
149
|
+
|
|
150
|
+
File.open(swagger_location, 'w') do |file|
|
|
151
|
+
result = add_quotes_to_dates(YAML.dump(current_yaml_file))
|
|
152
|
+
file.write(result)
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
$removed_examples << { @current_path => request.method.to_s.downcase }
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
|
|
134
159
|
def add_quotes_to_dates(string)
|
|
135
160
|
string = remove_quotes_in_dates(string)
|
|
136
161
|
string.gsub(/\b\d{4}-\d{2}-\d{2}\b/, "'\\0'")
|
|
@@ -396,14 +421,14 @@ module SwaggerAutogenerate
|
|
|
396
421
|
end
|
|
397
422
|
|
|
398
423
|
def is_valid_date?(string)
|
|
399
|
-
Date.
|
|
424
|
+
Date.strptime(string)
|
|
400
425
|
true
|
|
401
426
|
rescue ArgumentError
|
|
402
427
|
false
|
|
403
428
|
end
|
|
404
429
|
|
|
405
430
|
def convert_to_date(string)
|
|
406
|
-
datetime = DateTime.
|
|
431
|
+
datetime = DateTime.strptime(string)
|
|
407
432
|
datetime.strftime('%Y-%m-%d')
|
|
408
433
|
rescue ArgumentError
|
|
409
434
|
string
|
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: 1.2.
|
|
4
|
+
version: 1.2.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- MohammedBuraiah
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2024-09-
|
|
11
|
+
date: 2024-09-15 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
|