oas_rails 0.2.3 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -1
- data/app/controllers/oas_rails/oas_rails_controller.rb +1 -1
- data/lib/generators/oas_rails/config/templates/oas_rails_initializer.rb +11 -0
- data/lib/oas_rails/builders/content_builder.rb +55 -0
- data/lib/oas_rails/builders/operation_builder.rb +32 -0
- data/lib/oas_rails/builders/parameter_builder.rb +28 -0
- data/lib/oas_rails/builders/parameters_builder.rb +39 -0
- data/lib/oas_rails/builders/path_item_builder.rb +22 -0
- data/lib/oas_rails/builders/request_body_builder.rb +60 -0
- data/lib/oas_rails/builders/response_builder.rb +40 -0
- data/lib/oas_rails/builders/responses_builder.rb +58 -0
- data/lib/oas_rails/configuration.rb +25 -5
- data/lib/oas_rails/esquema_builder.rb +37 -0
- data/lib/oas_rails/extractors/oas_route_extractor.rb +66 -0
- data/lib/oas_rails/extractors/render_response_extractor.rb +148 -0
- data/lib/oas_rails/extractors/route_extractor.rb +125 -0
- data/lib/oas_rails/oas_route.rb +1 -99
- data/lib/oas_rails/spec/components.rb +85 -0
- data/lib/oas_rails/spec/contact.rb +18 -0
- data/lib/oas_rails/spec/hashable.rb +39 -0
- data/lib/oas_rails/{info.rb → spec/info.rb} +30 -24
- data/lib/oas_rails/spec/license.rb +18 -0
- data/lib/oas_rails/spec/media_type.rb +84 -0
- data/lib/oas_rails/spec/operation.rb +25 -0
- data/lib/oas_rails/spec/parameter.rb +34 -0
- data/lib/oas_rails/spec/path_item.rb +33 -0
- data/lib/oas_rails/spec/paths.rb +26 -0
- data/lib/oas_rails/spec/reference.rb +16 -0
- data/lib/oas_rails/spec/request_body.rb +21 -0
- data/lib/oas_rails/spec/response.rb +20 -0
- data/lib/oas_rails/spec/responses.rb +25 -0
- data/lib/oas_rails/spec/server.rb +17 -0
- data/lib/oas_rails/spec/specable.rb +51 -0
- data/lib/oas_rails/spec/specification.rb +50 -0
- data/lib/oas_rails/spec/tag.rb +18 -0
- data/lib/oas_rails/utils.rb +39 -0
- data/lib/oas_rails/version.rb +1 -1
- data/lib/oas_rails.rb +47 -26
- metadata +32 -18
- data/lib/oas_rails/contact.rb +0 -12
- data/lib/oas_rails/license.rb +0 -11
- data/lib/oas_rails/media_type.rb +0 -76
- data/lib/oas_rails/oas_base.rb +0 -30
- data/lib/oas_rails/operation.rb +0 -134
- data/lib/oas_rails/parameter.rb +0 -47
- data/lib/oas_rails/path_item.rb +0 -25
- data/lib/oas_rails/paths.rb +0 -19
- data/lib/oas_rails/request_body.rb +0 -29
- data/lib/oas_rails/response.rb +0 -12
- data/lib/oas_rails/responses.rb +0 -20
- data/lib/oas_rails/route_extractor.rb +0 -119
- data/lib/oas_rails/server.rb +0 -10
- data/lib/oas_rails/specification.rb +0 -72
- data/lib/oas_rails/tag.rb +0 -17
@@ -0,0 +1,84 @@
|
|
1
|
+
module OasRails
|
2
|
+
module Spec
|
3
|
+
class MediaType
|
4
|
+
include Specable
|
5
|
+
|
6
|
+
attr_accessor :schema, :example, :examples, :encoding
|
7
|
+
|
8
|
+
@context = :incoming
|
9
|
+
@factory_examples = {}
|
10
|
+
|
11
|
+
# Initializes a new MediaType object.
|
12
|
+
#
|
13
|
+
# @param schema [Hash] the schema of the media type.
|
14
|
+
# @param kwargs [Hash] additional keyword arguments.
|
15
|
+
def initialize(specification)
|
16
|
+
@specification = specification
|
17
|
+
@schema = {}
|
18
|
+
@example = {}
|
19
|
+
@examples = {}
|
20
|
+
end
|
21
|
+
|
22
|
+
def oas_fields
|
23
|
+
[:schema, :example, :examples, :encoding]
|
24
|
+
end
|
25
|
+
|
26
|
+
class << self
|
27
|
+
# Searches for examples in test files based on the provided class and test framework.
|
28
|
+
#
|
29
|
+
# @param klass [Class] the class to search examples for.
|
30
|
+
# @param utils [Module] a utility module that provides the `detect_test_framework` method. Defaults to `Utils`.
|
31
|
+
# @return [Hash] a hash containing examples data or an empty hash if no examples are found.
|
32
|
+
def search_for_examples_in_tests(klass, context: :incoming, utils: Utils)
|
33
|
+
@context = context
|
34
|
+
case utils.detect_test_framework
|
35
|
+
when :factory_bot
|
36
|
+
fetch_factory_bot_examples(klass:)
|
37
|
+
when :fixtures
|
38
|
+
fetch_fixture_examples(klass:)
|
39
|
+
else
|
40
|
+
{}
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
# Fetches examples from FactoryBot for the provided class.
|
47
|
+
#
|
48
|
+
# @param klass [Class] the class to fetch examples for.
|
49
|
+
# @return [Hash] a hash containing examples data or an empty hash if no examples are found.
|
50
|
+
def fetch_factory_bot_examples(klass:)
|
51
|
+
klass_sym = Utils.class_to_symbol(klass)
|
52
|
+
|
53
|
+
begin
|
54
|
+
@factory_examples[klass_sym] = FactoryBot.build_stubbed_list(klass_sym, 1) if @factory_examples[klass_sym].nil?
|
55
|
+
|
56
|
+
@factory_examples[klass_sym].each_with_index.to_h do |obj, index|
|
57
|
+
["#{klass_sym}#{index + 1}", { value: { klass_sym => clean_example_object(obj: obj.as_json) } }]
|
58
|
+
end
|
59
|
+
rescue KeyError
|
60
|
+
{}
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
# Fetches examples from fixtures for the provided class.
|
65
|
+
#
|
66
|
+
# @param klass [Class] the class to fetch examples for.
|
67
|
+
# @return [Hash] a hash containing examples data or an empty hash if no examples are found.
|
68
|
+
def fetch_fixture_examples(klass:)
|
69
|
+
fixture_file = Rails.root.join('test', 'fixtures', "#{klass.to_s.pluralize.downcase}.yml")
|
70
|
+
begin
|
71
|
+
fixture_data = YAML.load_file(fixture_file).with_indifferent_access
|
72
|
+
rescue Errno::ENOENT
|
73
|
+
return {}
|
74
|
+
end
|
75
|
+
fixture_data.transform_values { |attributes| { value: { klass.to_s.downcase => clean_example_object(obj: attributes) } } }
|
76
|
+
end
|
77
|
+
|
78
|
+
def clean_example_object(obj:)
|
79
|
+
obj.reject { |key, _| OasRails.config.send("excluded_columns_#{@context}").include?(key.to_sym) }
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module OasRails
|
2
|
+
module Spec
|
3
|
+
class Operation
|
4
|
+
include Specable
|
5
|
+
|
6
|
+
attr_accessor :specification, :tags, :summary, :description, :operation_id, :parameters, :request_body, :responses, :security
|
7
|
+
|
8
|
+
def initialize(specification)
|
9
|
+
@specification = specification
|
10
|
+
@summary = ""
|
11
|
+
@operation_id = ""
|
12
|
+
@tags = []
|
13
|
+
@description = @summary
|
14
|
+
@parameters = []
|
15
|
+
@request_body = {}
|
16
|
+
@responses = Spec::Responses.new(specification)
|
17
|
+
@security = []
|
18
|
+
end
|
19
|
+
|
20
|
+
def oas_fields
|
21
|
+
[:tags, :summary, :description, :operation_id, :parameters, :request_body, :responses, :security]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module OasRails
|
2
|
+
module Spec
|
3
|
+
class Parameter
|
4
|
+
include Specable
|
5
|
+
include Hashable
|
6
|
+
|
7
|
+
STYLE_DEFAULTS = { query: 'form', path: 'simple', header: 'simple', cookie: 'form' }.freeze
|
8
|
+
|
9
|
+
attr_accessor :name, :in, :style, :description, :required, :schema
|
10
|
+
|
11
|
+
def initialize(specification)
|
12
|
+
@specification = specification
|
13
|
+
@name = ""
|
14
|
+
@in = ""
|
15
|
+
@description = ""
|
16
|
+
@required = false
|
17
|
+
@style = ""
|
18
|
+
@schema = { type: 'string' }
|
19
|
+
end
|
20
|
+
|
21
|
+
def default_from_in
|
22
|
+
STYLE_DEFAULTS[@in.to_sym]
|
23
|
+
end
|
24
|
+
|
25
|
+
def required?
|
26
|
+
@in == 'path'
|
27
|
+
end
|
28
|
+
|
29
|
+
def oas_fields
|
30
|
+
[:name, :in, :description, :required, :schema, :style]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module OasRails
|
2
|
+
module Spec
|
3
|
+
class PathItem
|
4
|
+
include Specable
|
5
|
+
attr_reader :get, :post, :put, :patch, :delete
|
6
|
+
|
7
|
+
def initialize(specification)
|
8
|
+
@specification = specification
|
9
|
+
@get = nil
|
10
|
+
@post = nil
|
11
|
+
@put = nil
|
12
|
+
@patch = nil
|
13
|
+
@delete = nil
|
14
|
+
end
|
15
|
+
|
16
|
+
def fill_from(path, route_extractor: Extractors::RouteExtractor)
|
17
|
+
route_extractor.host_routes_by_path(path).each do |oas_route|
|
18
|
+
add_operation(oas_route.verb.downcase, Spec::Operation.new(@specification).fill_from(oas_route))
|
19
|
+
end
|
20
|
+
|
21
|
+
self
|
22
|
+
end
|
23
|
+
|
24
|
+
def add_operation(http_method, operation)
|
25
|
+
instance_variable_set("@#{http_method}", operation)
|
26
|
+
end
|
27
|
+
|
28
|
+
def oas_fields
|
29
|
+
[:get, :post, :put, :patch, :delete]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module OasRails
|
2
|
+
module Spec
|
3
|
+
class Paths
|
4
|
+
include Specable
|
5
|
+
|
6
|
+
attr_accessor :path_items
|
7
|
+
|
8
|
+
def initialize(specification)
|
9
|
+
@specification = specification
|
10
|
+
@path_items = {}
|
11
|
+
end
|
12
|
+
|
13
|
+
def add_path(path)
|
14
|
+
@path_items[path] = Builders::PathItemBuilder.new(@specification).from_path(path).build
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_spec
|
18
|
+
paths_hash = {}
|
19
|
+
@path_items.each do |path, path_object|
|
20
|
+
paths_hash[path] = path_object.to_spec
|
21
|
+
end
|
22
|
+
paths_hash
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module OasRails
|
2
|
+
module Spec
|
3
|
+
class RequestBody
|
4
|
+
include Specable
|
5
|
+
include Hashable
|
6
|
+
|
7
|
+
attr_accessor :description, :content, :required
|
8
|
+
|
9
|
+
def initialize(specification)
|
10
|
+
@specification = specification
|
11
|
+
@description = ""
|
12
|
+
@content = {} # a hash with media type objects
|
13
|
+
@required = false
|
14
|
+
end
|
15
|
+
|
16
|
+
def oas_fields
|
17
|
+
[:description, :content, :required]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module OasRails
|
2
|
+
module Spec
|
3
|
+
class Response
|
4
|
+
include Specable
|
5
|
+
include Hashable
|
6
|
+
|
7
|
+
attr_accessor :code, :description, :content
|
8
|
+
|
9
|
+
def initialize(specification)
|
10
|
+
@specification = specification
|
11
|
+
@description = ""
|
12
|
+
@content = {} # Hash with {content: MediaType}
|
13
|
+
end
|
14
|
+
|
15
|
+
def oas_fields
|
16
|
+
[:description, :content]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module OasRails
|
2
|
+
module Spec
|
3
|
+
class Responses
|
4
|
+
include Specable
|
5
|
+
attr_accessor :responses
|
6
|
+
|
7
|
+
def initialize(specification)
|
8
|
+
@specification = specification
|
9
|
+
@responses = {}
|
10
|
+
end
|
11
|
+
|
12
|
+
def add_response(response)
|
13
|
+
@responses[response.code] = @specification.components.add_response(response)
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_spec
|
17
|
+
spec = {}
|
18
|
+
@responses.each do |key, value|
|
19
|
+
spec[key] = value.to_spec
|
20
|
+
end
|
21
|
+
spec
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module OasRails
|
2
|
+
module Spec
|
3
|
+
class Server
|
4
|
+
include Specable
|
5
|
+
attr_accessor :url, :description
|
6
|
+
|
7
|
+
def initialize(url:, description:)
|
8
|
+
@url = url
|
9
|
+
@description = description
|
10
|
+
end
|
11
|
+
|
12
|
+
def oas_fields
|
13
|
+
[:url, :description]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module OasRails
|
2
|
+
module Spec
|
3
|
+
module Specable
|
4
|
+
def oas_fields
|
5
|
+
[]
|
6
|
+
end
|
7
|
+
|
8
|
+
def to_spec
|
9
|
+
hash = {}
|
10
|
+
oas_fields.each do |var|
|
11
|
+
key = var.to_s
|
12
|
+
|
13
|
+
camel_case_key = key.camelize(:lower).to_sym
|
14
|
+
value = send(var)
|
15
|
+
|
16
|
+
processed_value = if value.respond_to?(:to_spec)
|
17
|
+
value.to_spec
|
18
|
+
elsif value.is_a?(Array) && value.all? { |elem| elem.respond_to?(:to_spec) }
|
19
|
+
value.map(&:to_spec)
|
20
|
+
# elsif value.is_a?(Hash)
|
21
|
+
# p "Here"
|
22
|
+
# p value
|
23
|
+
# hash = {}
|
24
|
+
# value.each do |key, object|
|
25
|
+
# hash[key] = object.to_spec
|
26
|
+
# end
|
27
|
+
# hash
|
28
|
+
else
|
29
|
+
value
|
30
|
+
end
|
31
|
+
|
32
|
+
# hash[camel_case_key] = processed_value unless (processed_value.is_a?(Hash) || processed_value.is_a?(Array)) && processed_value.empty?
|
33
|
+
hash[camel_case_key] = processed_value unless processed_value.nil?
|
34
|
+
end
|
35
|
+
hash
|
36
|
+
end
|
37
|
+
|
38
|
+
def as_json
|
39
|
+
to_spec
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def snake_to_camel(snake_str)
|
45
|
+
words = snake_str.to_s.split('_')
|
46
|
+
words[1..].map!(&:capitalize)
|
47
|
+
(words[0] + words[1..].join).to_sym
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module OasRails
|
4
|
+
module Spec
|
5
|
+
class Specification
|
6
|
+
include Specable
|
7
|
+
attr_accessor :components, :info, :openapi, :servers, :tags, :external_docs, :paths
|
8
|
+
|
9
|
+
# Initializes a new Specification object.
|
10
|
+
# Clears the cache if running in the development environment.
|
11
|
+
def initialize
|
12
|
+
clear_cache unless Rails.env.production?
|
13
|
+
|
14
|
+
@components = Components.new(self)
|
15
|
+
@info = OasRails.config.info
|
16
|
+
@openapi = '3.1.0'
|
17
|
+
@servers = OasRails.config.servers
|
18
|
+
@tags = OasRails.config.tags
|
19
|
+
@external_docs = {}
|
20
|
+
@paths = Spec::Paths.new(self)
|
21
|
+
end
|
22
|
+
|
23
|
+
def build(route_extractor: Extractors::RouteExtractor)
|
24
|
+
route_extractor.host_paths.each do |path|
|
25
|
+
@paths.add_path(path)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# Clears the cache for MethodSource and RouteExtractor.
|
30
|
+
#
|
31
|
+
# @return [void]
|
32
|
+
def clear_cache
|
33
|
+
MethodSource.clear_cache
|
34
|
+
Extractors::RouteExtractor.clear_cache
|
35
|
+
end
|
36
|
+
|
37
|
+
def oas_fields
|
38
|
+
[:openapi, :info, :servers, :paths, :components, :security, :tags, :external_docs]
|
39
|
+
end
|
40
|
+
|
41
|
+
# Create the Security Requirement Object.
|
42
|
+
# @see https://spec.openapis.org/oas/latest.html#security-requirement-object
|
43
|
+
def security
|
44
|
+
return [] unless OasRails.config.authenticate_all_routes_by_default
|
45
|
+
|
46
|
+
OasRails.config.security_schemas.map { |key, _| { key => [] } }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module OasRails
|
2
|
+
module Spec
|
3
|
+
class Tag
|
4
|
+
include Specable
|
5
|
+
|
6
|
+
attr_accessor :name, :description
|
7
|
+
|
8
|
+
def initialize(name:, description:)
|
9
|
+
@name = name.titleize
|
10
|
+
@description = description
|
11
|
+
end
|
12
|
+
|
13
|
+
def oas_fields
|
14
|
+
[:name, :description]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/oas_rails/utils.rb
CHANGED
@@ -13,6 +13,14 @@ module OasRails
|
|
13
13
|
'DateTime' => 'string'
|
14
14
|
}.freeze
|
15
15
|
|
16
|
+
HTTP_STATUS_DEFINITIONS = {
|
17
|
+
404 => "The requested resource could not be found.",
|
18
|
+
401 => "You are not authorized to access this resource. You need to authenticate yourself first.",
|
19
|
+
403 => "You are not allowed to access this resource. You do not have the necessary permissions.",
|
20
|
+
500 => "An unexpected error occurred on the server. The server was unable to process the request.",
|
21
|
+
422 => "The server could not process the request due to semantic errors. Please check your input and try again."
|
22
|
+
}.freeze
|
23
|
+
|
16
24
|
class << self
|
17
25
|
# Method for detect test framework of the Rails App
|
18
26
|
# It is used for generate examples in operations
|
@@ -61,6 +69,37 @@ module OasRails
|
|
61
69
|
def ruby_type_to_json_type(ruby_type)
|
62
70
|
TYPE_MAPPING.fetch(ruby_type, 'string')
|
63
71
|
end
|
72
|
+
|
73
|
+
# Converts a status symbol or string to an integer.
|
74
|
+
#
|
75
|
+
# @param status [String, Symbol, nil] The status to convert.
|
76
|
+
# @return [Integer] The status code as an integer.
|
77
|
+
def status_to_integer(status)
|
78
|
+
return 200 if status.nil?
|
79
|
+
|
80
|
+
if status.to_s =~ /^\d+$/
|
81
|
+
status.to_i
|
82
|
+
else
|
83
|
+
status = "unprocessable_content" if status == "unprocessable_entity"
|
84
|
+
Rack::Utils::SYMBOL_TO_STATUS_CODE[status.to_sym]
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
# Converts a status code to its corresponding text description.
|
89
|
+
#
|
90
|
+
# @param status_code [Integer] The status code.
|
91
|
+
# @return [String] The text description of the status code.
|
92
|
+
def status_code_to_text(status_code)
|
93
|
+
Rack::Utils::HTTP_STATUS_CODES[status_code] || "Unknown Status Code"
|
94
|
+
end
|
95
|
+
|
96
|
+
def get_definition(status_code)
|
97
|
+
HTTP_STATUS_DEFINITIONS[status_code] || "Definition not found for status code #{status_code}"
|
98
|
+
end
|
99
|
+
|
100
|
+
def class_to_symbol(klass)
|
101
|
+
klass.name.underscore.to_sym
|
102
|
+
end
|
64
103
|
end
|
65
104
|
end
|
66
105
|
end
|
data/lib/oas_rails/version.rb
CHANGED
data/lib/oas_rails.rb
CHANGED
@@ -6,35 +6,64 @@ module OasRails
|
|
6
6
|
require "oas_rails/version"
|
7
7
|
require "oas_rails/engine"
|
8
8
|
|
9
|
-
autoload :OasBase, "oas_rails/oas_base"
|
10
9
|
autoload :Configuration, "oas_rails/configuration"
|
11
|
-
autoload :Specification, "oas_rails/specification"
|
12
|
-
autoload :RouteExtractor, "oas_rails/route_extractor"
|
13
10
|
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
11
|
autoload :Utils, "oas_rails/utils"
|
12
|
+
autoload :EsquemaBuilder, "oas_rails/esquema_builder"
|
13
|
+
|
14
|
+
module Builders
|
15
|
+
autoload :OperationBuilder, "oas_rails/builders/operation_builder"
|
16
|
+
autoload :PathItemBuilder, "oas_rails/builders/path_item_builder"
|
17
|
+
autoload :ResponseBuilder, "oas_rails/builders/response_builder"
|
18
|
+
autoload :ResponsesBuilder, "oas_rails/builders/responses_builder"
|
19
|
+
autoload :ContentBuilder, "oas_rails/builders/content_builder"
|
20
|
+
autoload :ParametersBuilder, "oas_rails/builders/parameters_builder"
|
21
|
+
autoload :ParameterBuilder, "oas_rails/builders/parameter_builder"
|
22
|
+
autoload :RequestBodyBuilder, "oas_rails/builders/request_body_builder"
|
23
|
+
end
|
24
|
+
|
25
|
+
# This module contains all the clases that represent a part of the OAS file.
|
26
|
+
module Spec
|
27
|
+
autoload :Hashable, "oas_rails/spec/hashable"
|
28
|
+
autoload :Specable, "oas_rails/spec/specable"
|
29
|
+
autoload :Components, "oas_rails/spec/components"
|
30
|
+
autoload :Parameter, "oas_rails/spec/parameter"
|
31
|
+
autoload :License, "oas_rails/spec/license"
|
32
|
+
autoload :Response, "oas_rails/spec/response"
|
33
|
+
autoload :PathItem, "oas_rails/spec/path_item"
|
34
|
+
autoload :Operation, "oas_rails/spec/operation"
|
35
|
+
autoload :RequestBody, "oas_rails/spec/request_body"
|
36
|
+
autoload :Responses, "oas_rails/spec/responses"
|
37
|
+
autoload :MediaType, "oas_rails/spec/media_type"
|
38
|
+
autoload :Paths, "oas_rails/spec/paths"
|
39
|
+
autoload :Contact, "oas_rails/spec/contact"
|
40
|
+
autoload :Info, "oas_rails/spec/info"
|
41
|
+
autoload :Server, "oas_rails/spec/server"
|
42
|
+
autoload :Tag, "oas_rails/spec/tag"
|
43
|
+
autoload :Specification, "oas_rails/spec/specification"
|
44
|
+
autoload :Reference, "oas_rails/spec/reference"
|
45
|
+
end
|
29
46
|
|
30
47
|
module YARD
|
31
48
|
autoload :OasYARDFactory, 'oas_rails/yard/oas_yard_factory'
|
32
49
|
end
|
33
50
|
|
51
|
+
module Extractors
|
52
|
+
autoload :RenderResponseExtractor, 'oas_rails/extractors/render_response_extractor'
|
53
|
+
autoload :RouteExtractor, "oas_rails/extractors/route_extractor"
|
54
|
+
autoload :OasRouteExtractor, "oas_rails/extractors/oas_route_extractor"
|
55
|
+
end
|
56
|
+
|
34
57
|
class << self
|
58
|
+
def build
|
59
|
+
oas = Spec::Specification.new
|
60
|
+
oas.build
|
61
|
+
|
62
|
+
oas.to_spec
|
63
|
+
end
|
64
|
+
|
35
65
|
# Configurations for make the OasRails engine Work.
|
36
66
|
def configure
|
37
|
-
OasRails.configure_esquema!
|
38
67
|
OasRails.configure_yard!
|
39
68
|
yield config
|
40
69
|
end
|
@@ -59,13 +88,5 @@ module OasRails
|
|
59
88
|
::YARD::Tags::Library.define_tag(tag_name, method_name, handler)
|
60
89
|
end
|
61
90
|
end
|
62
|
-
|
63
|
-
def configure_esquema!
|
64
|
-
Esquema.configure do |config|
|
65
|
-
config.exclude_associations = true
|
66
|
-
config.exclude_foreign_keys = true
|
67
|
-
config.excluded_columns = %i[id created_at updated_at deleted_at]
|
68
|
-
end
|
69
|
-
end
|
70
91
|
end
|
71
92
|
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.4.0
|
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-08-
|
11
|
+
date: 2024-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: esquema
|
@@ -100,25 +100,39 @@ files:
|
|
100
100
|
- lib/generators/oas_rails/config/config_generator.rb
|
101
101
|
- lib/generators/oas_rails/config/templates/oas_rails_initializer.rb
|
102
102
|
- lib/oas_rails.rb
|
103
|
+
- lib/oas_rails/builders/content_builder.rb
|
104
|
+
- lib/oas_rails/builders/operation_builder.rb
|
105
|
+
- lib/oas_rails/builders/parameter_builder.rb
|
106
|
+
- lib/oas_rails/builders/parameters_builder.rb
|
107
|
+
- lib/oas_rails/builders/path_item_builder.rb
|
108
|
+
- lib/oas_rails/builders/request_body_builder.rb
|
109
|
+
- lib/oas_rails/builders/response_builder.rb
|
110
|
+
- lib/oas_rails/builders/responses_builder.rb
|
103
111
|
- lib/oas_rails/configuration.rb
|
104
|
-
- lib/oas_rails/contact.rb
|
105
112
|
- lib/oas_rails/engine.rb
|
106
|
-
- lib/oas_rails/
|
107
|
-
- lib/oas_rails/
|
108
|
-
- lib/oas_rails/
|
109
|
-
- lib/oas_rails/
|
113
|
+
- lib/oas_rails/esquema_builder.rb
|
114
|
+
- lib/oas_rails/extractors/oas_route_extractor.rb
|
115
|
+
- lib/oas_rails/extractors/render_response_extractor.rb
|
116
|
+
- lib/oas_rails/extractors/route_extractor.rb
|
110
117
|
- lib/oas_rails/oas_route.rb
|
111
|
-
- lib/oas_rails/
|
112
|
-
- lib/oas_rails/
|
113
|
-
- lib/oas_rails/
|
114
|
-
- lib/oas_rails/
|
115
|
-
- lib/oas_rails/
|
116
|
-
- lib/oas_rails/
|
117
|
-
- lib/oas_rails/
|
118
|
-
- lib/oas_rails/
|
119
|
-
- lib/oas_rails/
|
120
|
-
- lib/oas_rails/
|
121
|
-
- lib/oas_rails/
|
118
|
+
- lib/oas_rails/spec/components.rb
|
119
|
+
- lib/oas_rails/spec/contact.rb
|
120
|
+
- lib/oas_rails/spec/hashable.rb
|
121
|
+
- lib/oas_rails/spec/info.rb
|
122
|
+
- lib/oas_rails/spec/license.rb
|
123
|
+
- lib/oas_rails/spec/media_type.rb
|
124
|
+
- lib/oas_rails/spec/operation.rb
|
125
|
+
- lib/oas_rails/spec/parameter.rb
|
126
|
+
- lib/oas_rails/spec/path_item.rb
|
127
|
+
- lib/oas_rails/spec/paths.rb
|
128
|
+
- lib/oas_rails/spec/reference.rb
|
129
|
+
- lib/oas_rails/spec/request_body.rb
|
130
|
+
- lib/oas_rails/spec/response.rb
|
131
|
+
- lib/oas_rails/spec/responses.rb
|
132
|
+
- lib/oas_rails/spec/server.rb
|
133
|
+
- lib/oas_rails/spec/specable.rb
|
134
|
+
- lib/oas_rails/spec/specification.rb
|
135
|
+
- lib/oas_rails/spec/tag.rb
|
122
136
|
- lib/oas_rails/utils.rb
|
123
137
|
- lib/oas_rails/version.rb
|
124
138
|
- lib/oas_rails/yard/oas_yard_factory.rb
|
data/lib/oas_rails/contact.rb
DELETED