swagger_autogenerate 1.1.2 → 1.2.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/CHANGELOG.md +1 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/swagger_autogenerate/configuration.rb +5 -3
- data/lib/swagger_autogenerate/swagger_trace.rb +21 -8
- data/lib/swagger_autogenerate/version.rb +1 -1
- data/lib/swagger_autogenerate.rb +2 -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: '08b276dd458b54318a75f32c666d40840602065d89a8fa26e7ffac44341e0f15'
|
4
|
+
data.tar.gz: bacd1e78fe71a2909d112901a9e6ba2900117b7e2a45522b1d25f11b542aa624
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f6c2c1c285f982a2677daf6d90040bed5682595fd65ee690ac2e01d188a37bc4afca6f4531fc4e8daad142dd5098a54d4dcb336c58ebc97e2ec305afba9eff7
|
7
|
+
data.tar.gz: 4c5d8642ac585f043cab7193e3eb9fb7fbe3c027c41d6bcdae6b17b5f6b905a4559469db54f166a9014a4283f9c1d798968a30f18c1ee38160c4579985d5626a
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -64,7 +64,7 @@ This file should contain the test scenarios for each action (e.g., index, show,
|
|
64
64
|
|
65
65
|
3) Run the spec code using the rspec command and set the environment variable SWAGGER to the desired YAML file name. For example:
|
66
66
|
```
|
67
|
-
|
67
|
+
SWAGGER_PATH='employee_apis.yaml' rspec spec/your_path/employees_controller_spec.rb
|
68
68
|
```
|
69
69
|
4) This command runs the spec file and instructs the swagger_autogenerate gem to generate Swagger YAML documentation and save it to the file named employee_apis.yaml.
|
70
70
|
5) Once the command finishes executing, you will have the Swagger YAML documentation generated based on the test scenarios in the employees_controller_spec.rb file.
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module SwaggerAutogenerate
|
2
2
|
class Configuration
|
3
3
|
attr_accessor :with_config, :with_multiple_examples, :with_rspec_examples, :with_example_description,
|
4
|
-
:with_response_description, :
|
5
|
-
:environment_name, :security, :swagger_config, :response_status
|
4
|
+
:with_response_description, :swagger_path_environment_variable, :generate_swagger_environment_variable,
|
5
|
+
:default_path, :environment_name, :security, :swagger_config, :response_status
|
6
6
|
|
7
7
|
def initialize
|
8
8
|
@with_config = true
|
@@ -11,7 +11,9 @@ 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
|
+
@swagger_path_environment_variable = 'SWAGGER_PATH'
|
15
|
+
@generate_swagger_environment_variable = 'SWAGGER_GENERATE'
|
16
|
+
@default_path = 'swagger'
|
15
17
|
@environment_name = :test
|
16
18
|
@security = default_security
|
17
19
|
@swagger_config = default_swagger_config
|
@@ -10,6 +10,7 @@ module SwaggerAutogenerate
|
|
10
10
|
@security = ::SwaggerAutogenerate.configuration.security
|
11
11
|
@swagger_config = ::SwaggerAutogenerate.configuration.swagger_config
|
12
12
|
@response_status = ::SwaggerAutogenerate.configuration.response_status
|
13
|
+
@default_path = ::SwaggerAutogenerate.configuration.default_path
|
13
14
|
@request = request
|
14
15
|
@response = response
|
15
16
|
@@paths = {}
|
@@ -20,12 +21,20 @@ module SwaggerAutogenerate
|
|
20
21
|
write_swagger_trace
|
21
22
|
end
|
22
23
|
|
23
|
-
def self.
|
24
|
-
::SwaggerAutogenerate.configuration.
|
24
|
+
def self.swagger_path_environment_variable
|
25
|
+
::SwaggerAutogenerate.configuration.swagger_path_environment_variable
|
25
26
|
end
|
26
27
|
|
27
|
-
def
|
28
|
-
SwaggerTrace.
|
28
|
+
def swagger_path_environment_variable
|
29
|
+
SwaggerTrace.swagger_path_environment_variable
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.generate_swagger_environment_variable
|
33
|
+
::SwaggerAutogenerate.configuration.generate_swagger_environment_variable
|
34
|
+
end
|
35
|
+
|
36
|
+
def generate_swagger_environment_variable
|
37
|
+
SwaggerTrace.generate_swagger_environment_variable
|
29
38
|
end
|
30
39
|
|
31
40
|
def self.environment_name
|
@@ -40,7 +49,7 @@ module SwaggerAutogenerate
|
|
40
49
|
|
41
50
|
attr_reader :request, :response, :current_path, :yaml_file, :configuration,
|
42
51
|
:with_config, :with_multiple_examples, :with_rspec_examples,
|
43
|
-
:with_response_description, :security, :response_status, :swagger_config
|
52
|
+
:with_response_description, :security, :response_status, :swagger_config, :default_path
|
44
53
|
|
45
54
|
# main methods
|
46
55
|
|
@@ -431,10 +440,14 @@ module SwaggerAutogenerate
|
|
431
440
|
def swagger_location
|
432
441
|
return @swagger_location if instance_variable_defined?(:@swagger_location)
|
433
442
|
|
434
|
-
if ENV[
|
435
|
-
|
443
|
+
if ENV[generate_swagger_environment_variable].present?
|
444
|
+
directory_path = Rails.root.join(default_path).to_s
|
445
|
+
FileUtils.mkdir_p(directory_path) unless File.directory?(directory_path)
|
446
|
+
@swagger_location = "#{directory_path}/#{tags.first}.yaml"
|
447
|
+
elsif ENV[swagger_path_environment_variable].include?('.yaml') || ENV[swagger_path_environment_variable].include?('.yml')
|
448
|
+
@swagger_location = Rails.root.join(ENV.fetch(swagger_path_environment_variable, nil).to_s).to_s
|
436
449
|
else
|
437
|
-
directory_path = Rails.root.join(ENV.fetch(
|
450
|
+
directory_path = Rails.root.join(ENV.fetch(swagger_path_environment_variable, nil).to_s).to_s
|
438
451
|
FileUtils.mkdir_p(directory_path) unless File.directory?(directory_path)
|
439
452
|
@swagger_location = "#{directory_path}/#{tags.first}.yaml"
|
440
453
|
end
|
data/lib/swagger_autogenerate.rb
CHANGED
@@ -15,7 +15,8 @@ module SwaggerAutogenerate
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.allow_swagger?
|
18
|
-
ENV[SwaggerTrace.
|
18
|
+
(ENV[SwaggerTrace.swagger_path_environment_variable].present? || ENV[SwaggerTrace.generate_swagger_environment_variable].present?) &&
|
19
|
+
Rails.env.send("#{SwaggerTrace.environment_name.to_s}?")
|
19
20
|
end
|
20
21
|
end
|
21
22
|
|
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.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MohammedBuraiah
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-08
|
11
|
+
date: 2024-09-08 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
|