oas_rails 0.8.0 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -9
- data/lib/oas_rails/version.rb +1 -1
- metadata +4 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c70c07ca9ad5ffa9227f3364f4df02846b3f713c2deebd06494c18b073efc907
|
4
|
+
data.tar.gz: 9375d6ea03cd901721987b627ded0a0dbdbfb064e83f84bb1a59e4d2c99da3ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 602eecab29188077b177d9db096c4273c100c6ff29c7e2c1d086ca3e0ba500861f89283c687a52ea3fff4ac9a5d096410694133a79da5549a7c7d03193582fef
|
7
|
+
data.tar.gz: 014240210b412a6287b7fc9e17339e719ddca9639225f40cafee860ee5a5aa140e442a5068fd0e0034af53d905739052d8d435810ece7da667b69f9bf4f8e676
|
data/README.md
CHANGED
@@ -5,10 +5,14 @@
|
|
5
5
|
![Static Badge](https://img.shields.io/badge/Rails-%3E%3D7.0.0-%23E9573F)
|
6
6
|
![Static Badge](https://img.shields.io/badge/Ruby-%3E%3D3.1.0-%23E9573F)
|
7
7
|
|
8
|
-
# Open API Specification For Rails
|
8
|
+
# 📃Open API Specification For Rails
|
9
9
|
|
10
10
|
OasRails is a Rails engine for generating **automatic interactive documentation for your Rails APIs**. It generates an **OAS 3.1** document and displays it using **[RapiDoc](https://rapidocweb.com)**.
|
11
11
|
|
12
|
+
🎬 A Demo Video Here:
|
13
|
+
https://vimeo.com/1013687332
|
14
|
+
🎬
|
15
|
+
|
12
16
|
![Screenshot](https://a-chacon.com/assets/images/oas_rails_ui.png)
|
13
17
|
|
14
18
|
## Related Projects
|
@@ -25,7 +29,7 @@ OasRails is a Rails engine for generating **automatic interactive documentation
|
|
25
29
|
- **Simple**: Complement default documentation with a few comments; no need to learn a complex DSL
|
26
30
|
- **Pure Ruby on Rails APIs**: No additional frameworks needed (e.g., Grape, RSpec)
|
27
31
|
|
28
|
-
## Motivation
|
32
|
+
## 📽️ Motivation
|
29
33
|
|
30
34
|
After experiencing the interactive documentation in Python's fast-api framework, I sought similar functionality in Ruby on Rails. Unable to find a suitable solution, I [asked on Stack Overflow](https://stackoverflow.com/questions/71947018/is-there-a-way-to-generate-an-interactive-documentation-for-rails-apis) years ago. Now, with some free time while freelancing as an API developer, I decided to build my own tool.
|
31
35
|
|
@@ -33,7 +37,7 @@ After experiencing the interactive documentation in Python's fast-api framework,
|
|
33
37
|
|
34
38
|
The goal is to minimize the effort required to create comprehensive documentation. By following REST principles in Rails, we believe this is achievable. You can enhance the documentation using [Yard](https://yardoc.org/) tags.
|
35
39
|
|
36
|
-
## Table of Contents
|
40
|
+
## 📋 Table of Contents
|
37
41
|
|
38
42
|
- [Installation](#installation)
|
39
43
|
- [Configuration](#configuration)
|
@@ -74,7 +78,7 @@ The goal is to minimize the effort required to create comprehensive documentatio
|
|
74
78
|
|
75
79
|
You'll now have **basic documentation** based on your routes and automatically gathered information at `localhost:3000/docs`. To enhance it, create an initializer file and add [Yard](https://yardoc.org/) tags to your controller methods.
|
76
80
|
|
77
|
-
## Configuration
|
81
|
+
## ⚙️ Configuration
|
78
82
|
|
79
83
|
To configure OasRails, you MUST create an initializer file including all your settings. The first step is to create your initializer file, which you can easily do with:
|
80
84
|
|
@@ -123,7 +127,7 @@ Then fill it with your data. Below are the available configuration options:
|
|
123
127
|
|
124
128
|
- `config.response_body_of_default`: body for use in default responses. It must be a String hash like the used in request body tags. Default: "{ message: String }"
|
125
129
|
|
126
|
-
## Usage
|
130
|
+
## 📓 Usage
|
127
131
|
|
128
132
|
In addition to the information provided in the initializer file and the data that can be extracted from the routes and methods automatically, it is essential to document your API in the following way. The documentation is created **with the help of YARD**, so the methods are documented with **comment tags**.
|
129
133
|
|
@@ -148,11 +152,11 @@ Used to add a summary to the endpoint. It replaces the default summary/title of
|
|
148
152
|
|
149
153
|
**Structure**: `@parameter name(position) [type] text`
|
150
154
|
|
151
|
-
Represents a parameter for the endpoint. The position can be: `header`, `path`, `cookie`, or `query`. The type should be a valid Ruby class: `String`, `Integer`, `Array<String>`, etc. Add a `!`
|
155
|
+
Represents a parameter for the endpoint. The position can be: `header`, `path`, `cookie`, or `query`. The type should be a valid Ruby class: `String`, `Integer`, `Array<String>`, etc. Add a `!` before the class to indicate a required parameter.
|
152
156
|
|
153
157
|
**Examples**:
|
154
158
|
`# @parameter page(query) [Integer] The page number.`
|
155
|
-
`# @parameter slug(path) [String
|
159
|
+
`# @parameter slug(path) [!String] Slug of the Project.`
|
156
160
|
|
157
161
|
</details>
|
158
162
|
|
@@ -334,7 +338,7 @@ class UsersController < ApplicationController
|
|
334
338
|
end
|
335
339
|
```
|
336
340
|
|
337
|
-
## Securing the OasRails Engine
|
341
|
+
## 🔒Securing the OasRails Engine
|
338
342
|
|
339
343
|
To secure the OasRails engine, which exposes an endpoint for showing the OAS definition, you can configure authentication to ensure that only authorized users have access. Here are a few methods to achieve this:
|
340
344
|
|
@@ -383,7 +387,7 @@ ActiveSupport.on_load(:oas_rails_application_controller) do
|
|
383
387
|
end
|
384
388
|
```
|
385
389
|
|
386
|
-
## Customizing the View
|
390
|
+
## ⛏️ Customizing the View
|
387
391
|
|
388
392
|
The OasRails engine provides an easy way to display your OpenAPI Specification (OAS) within your Rails application. By default, it includes an `index` view in the `OasRailsController` that displays [RapiDoc](https://rapidocweb.com/) through a CDN with default configurations. You can easily override this view to replace RapiDoc entirely or configure it differently.
|
389
393
|
|
data/lib/oas_rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oas_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- a-chacon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: method_source
|
@@ -30,28 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.1.
|
33
|
+
version: 0.1.2
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.1.
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rails
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '7.0'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '7.0'
|
40
|
+
version: 0.1.2
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: yard
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|