oas_rails 0.8.0 → 0.8.1
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 +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05b39d8ca4348b3da83595a029b436a73ba17a7a6da61ff61b09c02dd6147e7f
|
4
|
+
data.tar.gz: e8ef2175c8824dc45c63ef2aa112a1339ff5c4db779635ea4067d7bfd6dd75b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1cce603fbc0064bc84a3a953026aae6eb914b33872b20ebb1620195a4e4105736965c3816e664a708b4367adacce57d7003fb23646908f0ad5337f6a34fa5ee
|
7
|
+
data.tar.gz: 070ec97c6bb4e46cfcd1f6f5b1d5a71fda212dd8d197c74623900ff057d614f2a387aa79c67eb7fd832bd7b36ae2fefd105b8159991263fd219b7a9718691e7a
|
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.1
|
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-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: method_source
|