oas_rails 0.1.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/LICENSE +674 -0
- data/README.md +119 -9
- data/app/controllers/oas_rails/application_controller.rb +1 -0
- data/app/controllers/oas_rails/oas_rails_controller.rb +7 -4
- data/app/views/oas_rails/oas_rails/index.html.erb +1 -1
- data/config/routes.rb +1 -2
- data/lib/generators/oas_rails/config/templates/oas_rails_initializer.rb +45 -6
- data/lib/oas_rails/configuration.rb +54 -4
- data/lib/oas_rails/media_type.rb +1 -1
- data/lib/oas_rails/oas_base.rb +2 -1
- data/lib/oas_rails/oas_route.rb +1 -1
- data/lib/oas_rails/operation.rb +18 -2
- data/lib/oas_rails/specification.rb +26 -6
- data/lib/oas_rails/utils.rb +66 -0
- data/lib/oas_rails/version.rb +1 -1
- data/lib/oas_rails/yard/oas_yard_factory.rb +3 -3
- data/lib/oas_rails.rb +30 -82
- metadata +12 -21
- data/MIT-LICENSE +0 -20
data/lib/oas_rails.rb
CHANGED
@@ -2,30 +2,35 @@ require "yard"
|
|
2
2
|
require "method_source"
|
3
3
|
require "esquema"
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
require_relative 'oas_rails/configuration'
|
9
|
-
require_relative 'oas_rails/specification'
|
10
|
-
require_relative 'oas_rails/route_extractor'
|
11
|
-
require_relative 'oas_rails/oas_route'
|
12
|
-
require_relative 'oas_rails/operation'
|
5
|
+
module OasRails
|
6
|
+
require "oas_rails/version"
|
7
|
+
require "oas_rails/engine"
|
13
8
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
9
|
+
autoload :OasBase, "oas_rails/oas_base"
|
10
|
+
autoload :Configuration, "oas_rails/configuration"
|
11
|
+
autoload :Specification, "oas_rails/specification"
|
12
|
+
autoload :RouteExtractor, "oas_rails/route_extractor"
|
13
|
+
autoload :OasRoute, "oas_rails/oas_route"
|
14
|
+
autoload :Operation, "oas_rails/operation"
|
15
|
+
autoload :Info, "oas_rails/info"
|
16
|
+
autoload :Contact, "oas_rails/contact"
|
17
|
+
autoload :Paths, "oas_rails/paths"
|
18
|
+
autoload :PathItem, "oas_rails/path_item"
|
19
|
+
autoload :Parameter, "oas_rails/parameter"
|
20
|
+
autoload :Tag, "oas_rails/tag"
|
21
|
+
autoload :License, "oas_rails/license"
|
22
|
+
autoload :Server, "oas_rails/server"
|
23
|
+
autoload :RequestBody, "oas_rails/request_body"
|
24
|
+
autoload :MediaType, "oas_rails/media_type"
|
25
|
+
autoload :Response, "oas_rails/response"
|
26
|
+
autoload :Responses, "oas_rails/responses"
|
27
|
+
|
28
|
+
autoload :Utils, "oas_rails/utils"
|
29
|
+
|
30
|
+
module Yard
|
31
|
+
autoload :OasYardFactory, 'oas_rails/yard/oas_yard_factory'
|
32
|
+
end
|
27
33
|
|
28
|
-
module OasRails
|
29
34
|
class << self
|
30
35
|
def configure
|
31
36
|
yield config
|
@@ -43,7 +48,9 @@ module OasRails
|
|
43
48
|
'Parameter' => [:parameter, :with_parameter],
|
44
49
|
'Response' => [:response, :with_response],
|
45
50
|
'Endpoint Tags' => [:tags],
|
46
|
-
'Summary' => [:summary]
|
51
|
+
'Summary' => [:summary],
|
52
|
+
'No Auth' => [:no_auth],
|
53
|
+
'Auth methods' => [:auth, :with_types]
|
47
54
|
}
|
48
55
|
yard_tags.each do |tag_name, (method_name, handler)|
|
49
56
|
::YARD::Tags::Library.define_tag(tag_name, method_name, handler)
|
@@ -57,64 +64,5 @@ module OasRails
|
|
57
64
|
config.excluded_columns = %i[id created_at updated_at deleted_at]
|
58
65
|
end
|
59
66
|
end
|
60
|
-
|
61
|
-
def detect_test_framework
|
62
|
-
if defined?(FactoryBot)
|
63
|
-
:factory_bot
|
64
|
-
elsif ActiveRecord::Base.connection.table_exists?('ar_internal_metadata')
|
65
|
-
:fixtures
|
66
|
-
else
|
67
|
-
:unknown
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
TYPE_MAPPING = {
|
72
|
-
'String' => 'string',
|
73
|
-
'Integer' => 'number',
|
74
|
-
'Float' => 'number',
|
75
|
-
'TrueClass' => 'boolean',
|
76
|
-
'FalseClass' => 'boolean',
|
77
|
-
'Boolean' => 'boolean',
|
78
|
-
'NilClass' => 'null',
|
79
|
-
'Hash' => 'object',
|
80
|
-
'Object' => 'object',
|
81
|
-
'DateTime' => 'string'
|
82
|
-
}.freeze
|
83
|
-
|
84
|
-
def type_to_schema(type_string)
|
85
|
-
if type_string.start_with?('Array<')
|
86
|
-
inner_type = type_string[/Array<(.+)>$/, 1]
|
87
|
-
{
|
88
|
-
"type" => "array",
|
89
|
-
"items" => type_to_schema(inner_type)
|
90
|
-
}
|
91
|
-
else
|
92
|
-
{ "type" => TYPE_MAPPING.fetch(type_string, 'string') }
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
def hash_to_json_schema(hash)
|
97
|
-
{
|
98
|
-
type: 'object',
|
99
|
-
properties: hash_to_properties(hash),
|
100
|
-
required: []
|
101
|
-
}
|
102
|
-
end
|
103
|
-
|
104
|
-
def hash_to_properties(hash)
|
105
|
-
hash.transform_values do |value|
|
106
|
-
if value.is_a?(Hash)
|
107
|
-
hash_to_json_schema(value)
|
108
|
-
elsif value.is_a?(Class)
|
109
|
-
{ type: ruby_type_to_json_type(value.name) }
|
110
|
-
else
|
111
|
-
{ type: ruby_type_to_json_type(value.class.name) }
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
def ruby_type_to_json_type(ruby_type)
|
117
|
-
TYPE_MAPPING.fetch(ruby_type, 'string')
|
118
|
-
end
|
119
67
|
end
|
120
68
|
end
|
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.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- a-chacon
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-07-
|
11
|
+
date: 2024-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: esquema
|
@@ -72,24 +72,15 @@ dependencies:
|
|
72
72
|
- - "~>"
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '0.9'
|
75
|
-
description:
|
76
|
-
|
77
|
-
|
78
|
-
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)**.
|
79
|
-
|
80
|
-
## What Sets OasRails Apart?
|
81
|
-
|
82
|
-
- **Dynamic**: No command required to generate docs
|
83
|
-
- **Simple**: Complement default documentation with a few comments; no need to learn a complex DSL
|
84
|
-
- **Pure Ruby on Rails APIs**: No additional frameworks needed (e.g., Grape, RSpec)
|
85
|
-
|
75
|
+
description: OasRails is a Rails engine for generating automatic interactive documentation
|
76
|
+
for your Rails APIs. It generates an OAS 3.1 document and displays it using RapiDoc.
|
86
77
|
email:
|
87
78
|
- andres.ch@protonmail.com
|
88
79
|
executables: []
|
89
80
|
extensions: []
|
90
81
|
extra_rdoc_files: []
|
91
82
|
files:
|
92
|
-
-
|
83
|
+
- LICENSE
|
93
84
|
- README.md
|
94
85
|
- Rakefile
|
95
86
|
- app/assets/config/oas_rails_manifest.js
|
@@ -128,6 +119,7 @@ files:
|
|
128
119
|
- lib/oas_rails/server.rb
|
129
120
|
- lib/oas_rails/specification.rb
|
130
121
|
- lib/oas_rails/tag.rb
|
122
|
+
- lib/oas_rails/utils.rb
|
131
123
|
- lib/oas_rails/version.rb
|
132
124
|
- lib/oas_rails/yard/oas_yard_factory.rb
|
133
125
|
homepage: https://github.com/a-chacon/oas_rails
|
@@ -135,7 +127,7 @@ licenses:
|
|
135
127
|
- GPL-3.0-only
|
136
128
|
metadata:
|
137
129
|
homepage_uri: https://github.com/a-chacon/oas_rails
|
138
|
-
post_install_message:
|
130
|
+
post_install_message:
|
139
131
|
rdoc_options: []
|
140
132
|
require_paths:
|
141
133
|
- lib
|
@@ -143,17 +135,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
143
135
|
requirements:
|
144
136
|
- - ">="
|
145
137
|
- !ruby/object:Gem::Version
|
146
|
-
version: '3.
|
138
|
+
version: '3.1'
|
147
139
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
140
|
requirements:
|
149
141
|
- - ">="
|
150
142
|
- !ruby/object:Gem::Version
|
151
143
|
version: '0'
|
152
144
|
requirements: []
|
153
|
-
rubygems_version: 3.5.
|
154
|
-
signing_key:
|
145
|
+
rubygems_version: 3.5.9
|
146
|
+
signing_key:
|
155
147
|
specification_version: 4
|
156
148
|
summary: OasRails is a Rails engine for generating automatic interactive documentation
|
157
|
-
for your Rails APIs.
|
149
|
+
for your Rails APIs.
|
158
150
|
test_files: []
|
159
|
-
...
|
data/MIT-LICENSE
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright a-chacon
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|