swagger_autogenerate 0.1.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -1
- data/README.md +15 -6
- data/lib/swagger_autogenerate/swagger_trace.rb +6 -4
- 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: 0b52220aecae46c5818f0640a1ca979f59d38fba0720e2d5a35685fbb6c06bbd
|
4
|
+
data.tar.gz: 995666a3bd4de256824656420231be0c38d564aa236a6bfca10659d1474908ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c966988c943c3d108a30fa1abc38cef2295679e8f02b2f1dd302a64eedca45d5c97f37ff2c30f7ca35c516b92fa797ea6a0670a25ef1c587cef97ab22433f569
|
7
|
+
data.tar.gz: a6e6c285bdad27980d524f221c8ae5204e06a3ed222de805c2c5a6ebcda637c5e312712f395aa9247bae4002182fad5d264056c0b837a9a38c7ff5dd0d105d1c
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -7,6 +7,12 @@ automating Swagger YAML generation in Ruby on Rails offers a range of benefits f
|
|
7
7
|
|
8
8
|
The gem automatically observes the request/response patterns during the execution of test scenarios, generating accurate Swagger YAML files that reflect the API's behavior. developers and consumers can better understand and interact with the APIs.
|
9
9
|
|
10
|
+
## Dependencies
|
11
|
+
|
12
|
+
The SwaggerAutogenerate gem depends on the rspec-rails gem, which brings the RSpec testing framework to Ruby on Rails.
|
13
|
+
Please install rspec-rails first: https://github.com/rspec/rspec-rails
|
14
|
+
Then continue the installation process.
|
15
|
+
|
10
16
|
## Installation
|
11
17
|
|
12
18
|
1) Open your Gemfile located at ./Gemfile
|
@@ -18,7 +24,9 @@ The gem automatically observes the request/response patterns during the executio
|
|
18
24
|
end
|
19
25
|
```
|
20
26
|
3) Install the gem and add to the application's Gemfile by executing:
|
21
|
-
|
27
|
+
```
|
28
|
+
bundle install
|
29
|
+
```
|
22
30
|
|
23
31
|
## Configuration
|
24
32
|
|
@@ -31,6 +39,11 @@ To configure the swagger_autogenerate gem in your Rails application, follow thes
|
|
31
39
|
```
|
32
40
|
include SwaggerAutogenerate if Rails.env.test? && ENV['SWAGGER'].present?
|
33
41
|
```
|
42
|
+
in the #Example-step you will set the ENV['SWAGGER'],
|
43
|
+
|
44
|
+
By setting the ENV['SWAGGER'] environment variable, you can specify the path to the new file,
|
45
|
+
whether it's a specific file (e.g., ../myfile.yaml) or a directory (e.g., ../docs).
|
46
|
+
This flexibility ensures that the documentation can be easily integrated into your project's structure and workflow.
|
34
47
|
|
35
48
|
### Step 2 (optional)
|
36
49
|
1) Create a file called swagger_autogenerate.rb in the ./config/initializers
|
@@ -56,7 +69,7 @@ To generate Swagger YAML documentation for the APIs implemented in the Employees
|
|
56
69
|
$ spec/your_path/employees_controller_spec.rb
|
57
70
|
This file should contain the test scenarios for each action (e.g., index, show, create) of the controller.
|
58
71
|
|
59
|
-
3)Run the spec code using the rspec command and set the environment variable SWAGGER to the desired YAML file name. For example:
|
72
|
+
3) Run the spec code using the rspec command and set the environment variable SWAGGER to the desired YAML file name. For example:
|
60
73
|
```
|
61
74
|
SWAGGER='employee_apis.yaml' rspec spec/your_path/employees_controller_spec.rb
|
62
75
|
```
|
@@ -69,7 +82,3 @@ that the generated documentation will depend on the test scenarios defined in yo
|
|
69
82
|
## License
|
70
83
|
|
71
84
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
72
|
-
|
73
|
-
## Code of Conduct
|
74
|
-
|
75
|
-
Everyone interacting in the SwaggerAutogenerate project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/swagger_autogenerate/blob/master/CODE_OF_CONDUCT.md).
|
@@ -17,8 +17,10 @@ module SwaggerAutogenerate
|
|
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|
|
@@ -53,7 +55,7 @@ module SwaggerAutogenerate
|
|
53
55
|
paths[path.to_s].merge!(hash)
|
54
56
|
end
|
55
57
|
|
56
|
-
def
|
58
|
+
def write_swagger_trace
|
57
59
|
if paths[current_path][request.method.downcase].present?
|
58
60
|
paths[current_path][request.method.downcase]['responses'] = swagger_response
|
59
61
|
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.
|
4
|
+
version: 1.0.2
|
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:
|