lazy_api_doc 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/Gemfile.lock +7 -5
- data/README.md +34 -3
- data/docs/example/api.yml +1355 -0
- data/docs/example/index.html +24 -0
- data/docs/example/layout.yml +14 -0
- data/lib/generators/lazy_api_doc/install_generator.rb +42 -14
- data/lib/generators/lazy_api_doc/templates/support/minitest_interceptor.rb +2 -2
- data/lib/generators/lazy_api_doc/templates/support/rspec_interceptor.rb +2 -2
- data/lib/lazy_api_doc/generator.rb +22 -12
- data/lib/lazy_api_doc/route_parser.rb +11 -26
- data/lib/lazy_api_doc/version.rb +1 -1
- data/lib/lazy_api_doc.rb +92 -51
- data/screenshot.png +0 -0
- metadata +10 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 568bfda81852a9cd4823ac786f1bfe2de01a32dc42da6c192304c954dd2d731c
|
4
|
+
data.tar.gz: 5d4ccbd550f9cf6b16f589b155e71f3dd120a3eb2a475aa43a7ef39e1b0f8bcf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a99bee831aba3c9e8781b413ed4d53c051b47624673296dfbbe94176ae5dd8e54b1130abd767d46e2ec88a473dfc0d813297a12c2f66a9a017ada45997e1091
|
7
|
+
data.tar.gz: 8a05e6d6ea878f4eeba9c032a1b0533e83eafc497bd86b8a51a322b3b2f169059a3df2fb665ca9ff1c799c4df69a01d1a59d094c1d3c8ffd9985124842595770
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-
|
1
|
+
ruby-3.0.3
|
data/Gemfile.lock
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
lazy_api_doc (0.
|
4
|
+
lazy_api_doc (0.2.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
9
|
ast (2.4.0)
|
10
10
|
diff-lcs (1.3)
|
11
|
-
docile (1.
|
11
|
+
docile (1.4.0)
|
12
12
|
jaro_winkler (1.5.4)
|
13
13
|
parallel (1.19.0)
|
14
14
|
parser (2.6.5.0)
|
@@ -38,10 +38,12 @@ GEM
|
|
38
38
|
rubocop-rspec (1.38.1)
|
39
39
|
rubocop (>= 0.68.1)
|
40
40
|
ruby-progressbar (1.10.1)
|
41
|
-
simplecov (0.
|
41
|
+
simplecov (0.21.2)
|
42
42
|
docile (~> 1.1)
|
43
43
|
simplecov-html (~> 0.11)
|
44
|
-
|
44
|
+
simplecov_json_formatter (~> 0.1)
|
45
|
+
simplecov-html (0.12.3)
|
46
|
+
simplecov_json_formatter (0.1.3)
|
45
47
|
unicode-display_width (1.6.0)
|
46
48
|
|
47
49
|
PLATFORMS
|
@@ -56,4 +58,4 @@ DEPENDENCIES
|
|
56
58
|
simplecov
|
57
59
|
|
58
60
|
BUNDLED WITH
|
59
|
-
2.
|
61
|
+
2.2.32
|
data/README.md
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
# LazyApiDoc
|
2
2
|
|
3
|
-
A library to generate OpenAPI V3 documentation from tests.
|
3
|
+
A library to generate OpenAPI V3 documentation from tests. Try out the results
|
4
|
+
[here](https://bguban.github.io/lazy_api_doc/example).
|
4
5
|
|
5
6
|
LazyApiDoc collects requests and responses from your controller and request specs, retrieves data types, optional
|
6
7
|
attributes, endpoint description and then generates OpenAPI documentation.
|
7
8
|
|
9
|
+
![screenshot](./screenshot.png)
|
10
|
+
|
8
11
|
## Installation
|
9
12
|
|
10
13
|
Add this line to your application's Gemfile:
|
@@ -25,6 +28,22 @@ Then run install task
|
|
25
28
|
|
26
29
|
$ rails g lazy_api_doc:install
|
27
30
|
|
31
|
+
## Configuration
|
32
|
+
|
33
|
+
You can customize LazyApiDoc behavior using config file or environment variables.
|
34
|
+
|
35
|
+
```yaml
|
36
|
+
# config/lazy_api_doc.yml
|
37
|
+
|
38
|
+
# base directory for storing layout files and generated documentation
|
39
|
+
path: 'doc/lazy_api_doc' # ENV['LAZY_API_DOC_PATH'] default: 'public/lazy_api_doc'
|
40
|
+
|
41
|
+
# TTL for files generated by running tests in different processes (ParallelTest). Each process generates a file.
|
42
|
+
# After all the processes are done one of them collects all example files and generates the documentation. In case
|
43
|
+
# when the example files were not deleted before running the tests, old files will be ignored.
|
44
|
+
example_file_ttl: 1800 # ENV['LAZY_API_DOC_EXAMPLE_FILE_TTL'] default: 1800 (30 minutes)
|
45
|
+
```
|
46
|
+
|
28
47
|
## Usage
|
29
48
|
|
30
49
|
Update files `public/lazy_api_doc/index.html` and `public/lazy_api_doc/layout.yml`. These files will be
|
@@ -33,11 +52,11 @@ so on.
|
|
33
52
|
|
34
53
|
And just run your tests with `DOC=true` environment variable:
|
35
54
|
|
36
|
-
$
|
55
|
+
$ LAZY_API_DOC=true rspec
|
37
56
|
|
38
57
|
or
|
39
58
|
|
40
|
-
#
|
59
|
+
# LAZY_API_DOC=true rake test
|
41
60
|
|
42
61
|
The documentation will be placed `public/lazy_api_doc/api.yml`. To see it just run server
|
43
62
|
|
@@ -45,6 +64,18 @@ The documentation will be placed `public/lazy_api_doc/api.yml`. To see it just r
|
|
45
64
|
|
46
65
|
and navigate to http://localhost:3000/lazy_api_doc/
|
47
66
|
|
67
|
+
## How does it work under the hood?
|
68
|
+
|
69
|
+
LazyApiDoc gathers your test requests and responses, group them by controllers and actions that were affected, and tries to guess the type of every field.
|
70
|
+
```json
|
71
|
+
user: {
|
72
|
+
id: 1, // Integer
|
73
|
+
name: "John Doe", // String,
|
74
|
+
created_at: "2020-05-17 20:15:47Z -0400" // DateTime
|
75
|
+
}
|
76
|
+
```
|
77
|
+
After that, it just builds an OpenAPI specification based on it.
|
78
|
+
|
48
79
|
## Contributing
|
49
80
|
|
50
81
|
Bug reports and pull requests are welcome on GitHub at https://github.com/bguban/lazy_api_doc. This project is intended
|