oas_core 0.0.1 β 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -37
- data/lib/oas_core/builders/request_body_builder.rb +0 -3
- data/lib/oas_core/builders/responses_builder.rb +0 -12
- data/lib/oas_core/configuration.rb +3 -20
- data/lib/oas_core/version.rb +1 -1
- data/lib/oas_core.rb +4 -3
- metadata +3 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '092cef0cfe920698acf4b55412febd5e0ac30f31ed14e0b77169847c6bcfe1bd'
|
4
|
+
data.tar.gz: 6c2bfbbe7d7b513c7f1f2223a1064c716fd74780515e45d10e11e662ae6bc07d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 568ea83f14c6e19523e2eb8aa70d3b8533f18200824c2e18cbe7e0c858c50f8a987110ece244f107c907d68f2324ae2d4473ae1bd6641122cdc3044c60130b05
|
7
|
+
data.tar.gz: dc35e960540a2a532bb4374662c8b977ead04128425abced1ec22cce64090470fbc5adf8ae41d2d0dd95bbd34bb20ed603c8661faf51e06572fec30a32faaf01
|
data/README.md
CHANGED
@@ -7,43 +7,7 @@
|
|
7
7
|
|
8
8
|
# πOpen API Specification For Rails
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
### π Demo App
|
13
|
-
|
14
|
-
Explore the interactive documentation live:
|
15
|
-
|
16
|
-
π **[Open Demo App](https://paso.fly.dev/api/docs)**
|
17
|
-
π€ **Username**: `oasrails`
|
18
|
-
π **Password**: `oasrails`
|
19
|
-
|
20
|
-
π¬ A Demo Installation/Usage Video:
|
21
|
-
<https://vimeo.com/1013687332>
|
22
|
-
π¬
|
23
|
-
|
24
|
-

|
25
|
-
|
26
|
-
## Related Projects
|
27
|
-
|
28
|
-
- **[ApiPie](https://github.com/Apipie/apipie-rails)**: Doesn't support OAS 3.1, requires learning a DSL, lacks a nice UI
|
29
|
-
- **[swagger_yard-rails](https://github.com/livingsocial/swagger_yard-rails)**: Seems abandoned, but serves as inspiration
|
30
|
-
- **[Rswag](https://github.com/rswag/rswag)**: Not automatic, depends on RSpec; Many developers now use Minitest as it's the default test framework
|
31
|
-
- **[grape-swagger](https://github.com/ruby-grape/grape-swagger)**: Requires Grape
|
32
|
-
- **[rspec_api_documentation](https://github.com/zipmark/rspec_api_documentation)**: Requires RSpec and a command to generate the docs
|
33
|
-
|
34
|
-
## What Sets OasCore Apart?
|
35
|
-
|
36
|
-
- **Dynamic**: No command required to generate docs
|
37
|
-
- **Simple**: Complement default documentation with a few comments; no need to learn a complex DSL
|
38
|
-
- **Pure Ruby on Rails APIs**: No additional frameworks needed (e.g., Grape, RSpec)
|
39
|
-
|
40
|
-
## π½οΈ Motivation
|
41
|
-
|
42
|
-
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.
|
43
|
-
|
44
|
-
**Note: This is not yet a production-ready solution. The code may be rough and behave unexpectedly, but I am actively working on improving it. If you like the idea, please consider contributing to its development.**
|
45
|
-
|
46
|
-
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.
|
10
|
+
Generates OpenAPI Specification (OAS) documents by analyzing and extracting routes from Rails applications.
|
47
11
|
|
48
12
|
## Documentation
|
49
13
|
|
@@ -10,9 +10,6 @@ module OasCore
|
|
10
10
|
|
11
11
|
def from_oas_route(oas_route)
|
12
12
|
tag_request_body = oas_route.tags(:request_body).first
|
13
|
-
# TODO: This is for frameowkr specific.
|
14
|
-
# if tag_request_body.nil? && OasCore.config.autodiscover_request_body
|
15
|
-
# detect_request_body(oas_route) if %w[create update].include? oas_route.method_name
|
16
13
|
return self if tag_request_body.nil?
|
17
14
|
|
18
15
|
from_tags(tag: tag_request_body, examples_tags: oas_route.tags(:request_body_example))
|
@@ -27,18 +27,6 @@ module OasCore
|
|
27
27
|
self
|
28
28
|
end
|
29
29
|
|
30
|
-
# def add_autodiscovered_responses(oas_route)
|
31
|
-
# return self if !OasCore.config.autodiscover_responses || oas_route.tags(:response).any?
|
32
|
-
#
|
33
|
-
# new_responses = Extractors::RenderResponseExtractor.extract_responses_from_source(@specification, source: oas_route.source_string)
|
34
|
-
#
|
35
|
-
# new_responses.each do |new_response|
|
36
|
-
# @responses.add_response(new_response) if @responses.responses[new_response.code].blank?
|
37
|
-
# end
|
38
|
-
#
|
39
|
-
# self
|
40
|
-
# end
|
41
|
-
|
42
30
|
def add_default_responses(oas_route, security)
|
43
31
|
return self unless OasCore.config.set_default_responses
|
44
32
|
|
@@ -3,33 +3,24 @@
|
|
3
3
|
module OasCore
|
4
4
|
class Configuration
|
5
5
|
attr_accessor :info,
|
6
|
-
:layout,
|
7
6
|
:default_tags_from,
|
8
|
-
:autodiscover_request_body,
|
9
|
-
:autodiscover_responses,
|
10
7
|
:api_path,
|
11
|
-
:ignored_actions,
|
12
8
|
:security_schemas,
|
13
9
|
:authenticate_all_routes_by_default,
|
14
10
|
:set_default_responses,
|
15
11
|
:possible_default_responses,
|
16
12
|
:http_verbs,
|
17
|
-
:use_model_names
|
18
|
-
:rapidoc_theme
|
13
|
+
:use_model_names
|
19
14
|
|
20
|
-
attr_reader :servers, :tags, :security_schema, :
|
15
|
+
attr_reader :servers, :tags, :security_schema, :response_body_of_default
|
21
16
|
|
22
17
|
def initialize
|
23
18
|
@info = Spec::Info.new
|
24
|
-
@layout = false
|
25
19
|
@servers = default_servers
|
26
20
|
@tags = []
|
27
21
|
@swagger_version = '3.1.0'
|
28
22
|
@default_tags_from = :namespace
|
29
|
-
@autodiscover_request_body = true
|
30
|
-
@autodiscover_responses = true
|
31
23
|
@api_path = '/'
|
32
|
-
@ignored_actions = []
|
33
24
|
@authenticate_all_routes_by_default = true
|
34
25
|
@security_schema = nil
|
35
26
|
@security_schemas = {}
|
@@ -38,9 +29,8 @@ module OasCore
|
|
38
29
|
unprocessable_entity]
|
39
30
|
@http_verbs = %i[get post put patch delete]
|
40
31
|
@response_body_of_default = 'Hash{ status: !Integer, error: String }'
|
32
|
+
# TODO: What does this config??
|
41
33
|
@use_model_names = false
|
42
|
-
@rapidoc_theme = :rails
|
43
|
-
@include_mode = :all
|
44
34
|
|
45
35
|
@possible_default_responses.each do |response|
|
46
36
|
method_name = "response_body_of_#{response}="
|
@@ -85,13 +75,6 @@ module OasCore
|
|
85
75
|
[]
|
86
76
|
end
|
87
77
|
|
88
|
-
def include_mode=(value)
|
89
|
-
valid_modes = %i[all with_tags explicit]
|
90
|
-
raise ArgumentError, "include_mode must be one of #{valid_modes}" unless valid_modes.include?(value)
|
91
|
-
|
92
|
-
@include_mode = value
|
93
|
-
end
|
94
|
-
|
95
78
|
def response_body_of_default=(value)
|
96
79
|
raise ArgumentError, 'response_body_of_default must be a String With a valid object' unless value.is_a?(String)
|
97
80
|
|
data/lib/oas_core/version.rb
CHANGED
data/lib/oas_core.rb
CHANGED
@@ -57,9 +57,10 @@ module OasCore
|
|
57
57
|
end
|
58
58
|
|
59
59
|
class << self
|
60
|
-
def
|
61
|
-
OasCore.
|
62
|
-
|
60
|
+
def config=(config)
|
61
|
+
raise 'Configuration must be an OasCore::Configuration or its subclass' unless config.is_a?(OasCore::Configuration)
|
62
|
+
|
63
|
+
@config = config
|
63
64
|
end
|
64
65
|
|
65
66
|
def config
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oas_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- a-chacon
|
@@ -38,11 +38,8 @@ dependencies:
|
|
38
38
|
- !ruby/object:Gem::Version
|
39
39
|
version: '0.9'
|
40
40
|
description: OasCore simplifies API documentation by automatically generating OpenAPI
|
41
|
-
Specification (OAS 3.1) documents from your
|
42
|
-
the need for manual documentation, ensuring accuracy and consistency.
|
43
|
-
seamlessly with Rails, providing a hassle-free way to create interactive API documentation.
|
44
|
-
Ideal for developers and teams aiming to maintain up-to-date API specs with minimal
|
45
|
-
effort.
|
41
|
+
Specification (OAS 3.1) documents from your Ruby application routes. It eliminates
|
42
|
+
the need for manual documentation, ensuring accuracy and consistency.
|
46
43
|
email:
|
47
44
|
- andres.ch@protonmail.com
|
48
45
|
executables: []
|