swagger_autogenerate 1.1.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fa0e0d56334a728cbd835bf8ecf0cf4b2c330eb62aeb92e6b9bc20d1251ed5cd
4
- data.tar.gz: c5869ad74ec90bffdb1a58bdfbb52645849b14f88e81e876f5b856d280dab536
3
+ metadata.gz: '08b276dd458b54318a75f32c666d40840602065d89a8fa26e7ffac44341e0f15'
4
+ data.tar.gz: bacd1e78fe71a2909d112901a9e6ba2900117b7e2a45522b1d25f11b542aa624
5
5
  SHA512:
6
- metadata.gz: 7766553dbaa81ee1506f36727411a24e36d9dd7c73bc4733a2bc034be406b2c94e4526f7c73467e1d383cf3e566fecaa6ea592a06627f4a5778dba61cd5f142e
7
- data.tar.gz: ab857ce41cc465f94b961c61d2f3bbeb48195c8bf5472152c43524384caa57313325b852df8417e2c07489fed8ae0e656c941d9c91a395ea6e16895ace7a990c
6
+ metadata.gz: 9f6c2c1c285f982a2677daf6d90040bed5682595fd65ee690ac2e01d188a37bc4afca6f4531fc4e8daad142dd5098a54d4dcb336c58ebc97e2ec305afba9eff7
7
+ data.tar.gz: 4c5d8642ac585f043cab7193e3eb9fb7fbe3c027c41d6bcdae6b17b5f6b905a4559469db54f166a9014a4283f9c1d798968a30f18c1ee38160c4579985d5626a
data/CHANGELOG.md CHANGED
@@ -12,5 +12,6 @@
12
12
  ## [1.1.0] - 2024-06-23
13
13
  ## [1.1.1] - 2024-06-26
14
14
  ## [1.1.2] - 2024-08-17
15
+ ## [1.2.0] - 2024-09-08
15
16
 
16
17
  - Initial release
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- swagger_autogenerate (1.1.2)
4
+ swagger_autogenerate (1.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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
- SWAGGER='employee_apis.yaml' rspec spec/your_path/employees_controller_spec.rb
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, :swagger_environment_variable,
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
- @swagger_environment_variable = 'SWAGGER'
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.swagger_environment_variable
24
- ::SwaggerAutogenerate.configuration.swagger_environment_variable
24
+ def self.swagger_path_environment_variable
25
+ ::SwaggerAutogenerate.configuration.swagger_path_environment_variable
25
26
  end
26
27
 
27
- def swagger_environment_variable
28
- SwaggerTrace.swagger_environment_variable
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[swagger_environment_variable].include?('.yaml') || ENV[swagger_environment_variable].include?('.yml')
435
- @swagger_location = Rails.root.join(ENV.fetch(swagger_environment_variable, nil).to_s).to_s
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(swagger_environment_variable, nil).to_s).to_s
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SwaggerAutogenerate
4
- VERSION = "1.1.2"
4
+ VERSION = "1.2.0"
5
5
  end
@@ -15,7 +15,8 @@ module SwaggerAutogenerate
15
15
  end
16
16
 
17
17
  def self.allow_swagger?
18
- ENV[SwaggerTrace.swagger_environment_variable].present? && Rails.env.send("#{SwaggerTrace.environment_name.to_s}?")
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.1.2
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-17 00:00:00.000000000 Z
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