jsapi 0.5.0 → 0.6.1
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/lib/jsapi/controller/methods.rb +39 -13
- data/lib/jsapi/controller/parameters.rb +25 -23
- data/lib/jsapi/controller/response.rb +35 -22
- data/lib/jsapi/dsl/class_methods.rb +18 -10
- data/lib/jsapi/dsl/definitions.rb +11 -0
- data/lib/jsapi/dsl/openapi/callbacks.rb +34 -0
- data/lib/jsapi/dsl/openapi/examples.rb +32 -0
- data/lib/jsapi/dsl/openapi.rb +2 -0
- data/lib/jsapi/dsl/operation.rb +1 -1
- data/lib/jsapi/dsl/parameter.rb +1 -1
- data/lib/jsapi/dsl/request_body.rb +1 -1
- data/lib/jsapi/dsl/response.rb +1 -1
- data/lib/jsapi/dsl.rb +1 -3
- data/lib/jsapi/helpers/invalid_value_helper.rb +17 -0
- data/lib/jsapi/invalid_argument_error.rb +12 -0
- data/lib/jsapi/invalid_value_error.rb +12 -0
- data/lib/jsapi/json/object.rb +15 -14
- data/lib/jsapi/json.rb +1 -1
- data/lib/jsapi/meta/{attributes/class_methods.rb → base/attributes.rb} +2 -2
- data/lib/jsapi/meta/base/model.rb +44 -0
- data/lib/jsapi/meta/base/reference.rb +36 -0
- data/lib/jsapi/meta/{attributes → base}/type_caster.rb +2 -2
- data/lib/jsapi/meta/base.rb +4 -40
- data/lib/jsapi/meta/callable/symbol_evaluator.rb +30 -0
- data/lib/jsapi/meta/callable/symbol_sequence_evaluator.rb +29 -0
- data/lib/jsapi/meta/callable.rb +28 -0
- data/lib/jsapi/meta/defaults.rb +28 -0
- data/lib/jsapi/meta/definitions.rb +35 -29
- data/lib/jsapi/meta/openapi/callback/model.rb +1 -1
- data/lib/jsapi/meta/openapi/callback/reference.rb +1 -1
- data/lib/jsapi/meta/openapi/contact.rb +1 -1
- data/lib/jsapi/meta/openapi/example/model.rb +1 -1
- data/lib/jsapi/meta/openapi/example/reference.rb +1 -1
- data/lib/jsapi/meta/openapi/external_documentation.rb +1 -1
- data/lib/jsapi/meta/openapi/header/model.rb +17 -2
- data/lib/jsapi/meta/openapi/header/reference.rb +1 -1
- data/lib/jsapi/meta/openapi/info.rb +1 -1
- data/lib/jsapi/meta/openapi/license.rb +1 -1
- data/lib/jsapi/meta/openapi/link/model.rb +1 -1
- data/lib/jsapi/meta/openapi/link/reference.rb +1 -1
- data/lib/jsapi/meta/openapi/oauth_flow.rb +2 -2
- data/lib/jsapi/meta/openapi/root.rb +6 -20
- data/lib/jsapi/meta/openapi/security_requirement.rb +2 -2
- data/lib/jsapi/meta/openapi/security_scheme/base.rb +1 -1
- data/lib/jsapi/meta/openapi/security_scheme.rb +1 -1
- data/lib/jsapi/meta/openapi/server.rb +1 -1
- data/lib/jsapi/meta/openapi/server_variable.rb +1 -1
- data/lib/jsapi/meta/openapi/tag.rb +1 -1
- data/lib/jsapi/meta/operation.rb +21 -24
- data/lib/jsapi/meta/parameter/model.rb +4 -3
- data/lib/jsapi/meta/parameter/reference.rb +1 -1
- data/lib/jsapi/meta/property.rb +9 -3
- data/lib/jsapi/meta/request_body/model.rb +8 -3
- data/lib/jsapi/meta/request_body/reference.rb +1 -1
- data/lib/jsapi/meta/response/model.rb +9 -4
- data/lib/jsapi/meta/response/reference.rb +1 -1
- data/lib/jsapi/meta/schema/additional_properties.rb +5 -6
- data/lib/jsapi/meta/schema/base.rb +13 -7
- data/lib/jsapi/meta/schema/discriminator.rb +1 -9
- data/lib/jsapi/meta/schema/object.rb +27 -4
- data/lib/jsapi/meta/schema/reference.rb +1 -1
- data/lib/jsapi/meta/schema.rb +12 -5
- data/lib/jsapi/meta.rb +3 -5
- data/lib/jsapi/model/attributes.rb +10 -4
- data/lib/jsapi/model/base.rb +1 -1
- data/lib/jsapi/model/nestable.rb +25 -10
- data/lib/jsapi/version.rb +1 -1
- data/lib/jsapi.rb +4 -0
- metadata +15 -11
- data/lib/jsapi/dsl/callbacks.rb +0 -32
- data/lib/jsapi/dsl/examples.rb +0 -30
- data/lib/jsapi/meta/attributes.rb +0 -4
- data/lib/jsapi/meta/base_reference.rb +0 -34
- data/lib/jsapi/meta/invalid_argument_error.rb +0 -12
- data/lib/jsapi/meta/method_chain.rb +0 -32
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jsapi
|
4
|
+
module Meta
|
5
|
+
module Base
|
6
|
+
# The base meta model class.
|
7
|
+
class Model
|
8
|
+
extend Attributes
|
9
|
+
|
10
|
+
# Creates a new meta model.
|
11
|
+
#
|
12
|
+
# Raises an +ArgumentError+ if at least one keyword is not supported.
|
13
|
+
def initialize(keywords = {})
|
14
|
+
keywords.each do |key, value|
|
15
|
+
if respond_to?(method = "#{key}=")
|
16
|
+
public_send(method, value)
|
17
|
+
else
|
18
|
+
raise ArgumentError, "unsupported keyword: #{key}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def inspect # :nodoc:
|
24
|
+
klass = self.class
|
25
|
+
"#<#{klass.name} #{
|
26
|
+
klass.attribute_names.map do |name|
|
27
|
+
"#{name}: #{send(name).inspect}"
|
28
|
+
end.join(', ')
|
29
|
+
}>"
|
30
|
+
end
|
31
|
+
|
32
|
+
# Returns false.
|
33
|
+
def reference?
|
34
|
+
false
|
35
|
+
end
|
36
|
+
|
37
|
+
# Returns itself.
|
38
|
+
def resolve(*)
|
39
|
+
self
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jsapi
|
4
|
+
module Meta
|
5
|
+
module Base
|
6
|
+
# The base reference class.
|
7
|
+
class Reference < Model
|
8
|
+
##
|
9
|
+
# :attr: ref
|
10
|
+
# The name of the referred object.
|
11
|
+
attribute :ref, String
|
12
|
+
|
13
|
+
# Returns the name of the method to be called to look up the referred object
|
14
|
+
# in a Definitions instance.
|
15
|
+
def self.lookup_method_name
|
16
|
+
@lookup_method_name ||= name.delete_suffix('::Reference').demodulize.underscore
|
17
|
+
end
|
18
|
+
|
19
|
+
# Returns true.
|
20
|
+
def reference?
|
21
|
+
true
|
22
|
+
end
|
23
|
+
|
24
|
+
# Resolves +ref+ by looking up the object with that name in +definitions+.
|
25
|
+
#
|
26
|
+
# Raises a ReferenceError if +ref+ could not be resolved.
|
27
|
+
def resolve(definitions)
|
28
|
+
object = definitions.send(self.class.lookup_method_name, ref)
|
29
|
+
raise ReferenceError, ref if object.nil?
|
30
|
+
|
31
|
+
object.resolve(definitions)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Jsapi
|
4
4
|
module Meta
|
5
|
-
module
|
5
|
+
module Base
|
6
6
|
class TypeCaster
|
7
7
|
STRING_CASTER = ->(arg) { arg&.to_s } # :nodoc:
|
8
8
|
|
@@ -41,7 +41,7 @@ module Jsapi
|
|
41
41
|
casted_value = @caster.call(value)
|
42
42
|
return casted_value unless @values&.exclude?(casted_value)
|
43
43
|
|
44
|
-
raise InvalidArgumentError.new(@name, casted_value, @values)
|
44
|
+
raise InvalidArgumentError.new(@name, casted_value, valid_values: @values)
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
data/lib/jsapi/meta/base.rb
CHANGED
@@ -1,42 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
extend Attributes::ClassMethods
|
8
|
-
|
9
|
-
# Creates a new meta model.
|
10
|
-
#
|
11
|
-
# Raises an +ArgumentError+ if at least one keyword is not supported.
|
12
|
-
def initialize(keywords = {})
|
13
|
-
keywords.each do |key, value|
|
14
|
-
if respond_to?(method = "#{key}=")
|
15
|
-
public_send(method, value)
|
16
|
-
else
|
17
|
-
raise ArgumentError, "unsupported keyword: #{key}"
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def inspect # :nodoc:
|
23
|
-
klass = self.class
|
24
|
-
"#<#{klass.name} #{
|
25
|
-
klass.attribute_names.map do |name|
|
26
|
-
"#{name}: #{send(name).inspect}"
|
27
|
-
end.join(', ')
|
28
|
-
}>"
|
29
|
-
end
|
30
|
-
|
31
|
-
# Returns true if and only if this is a reference.
|
32
|
-
def reference?
|
33
|
-
false
|
34
|
-
end
|
35
|
-
|
36
|
-
# Returns itself.
|
37
|
-
def resolve(*)
|
38
|
-
self
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
3
|
+
require_relative 'base/type_caster'
|
4
|
+
require_relative 'base/attributes'
|
5
|
+
require_relative 'base/model'
|
6
|
+
require_relative 'base/reference'
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jsapi
|
4
|
+
module Meta
|
5
|
+
module Callable
|
6
|
+
class SymbolEvaluator
|
7
|
+
attr_reader :symbol
|
8
|
+
|
9
|
+
def initialize(symbol)
|
10
|
+
@symbol = symbol
|
11
|
+
@keys = [@symbol, @symbol.to_s]
|
12
|
+
end
|
13
|
+
|
14
|
+
def inspect # :nodoc:
|
15
|
+
"#<#{self.class.name} #{@symbol.inspect}>"
|
16
|
+
end
|
17
|
+
|
18
|
+
# Evaluates the symbol within the context of +object+.
|
19
|
+
def call(object)
|
20
|
+
if object.respond_to?(@symbol)
|
21
|
+
object.public_send(@symbol)
|
22
|
+
elsif object.respond_to?(:[]) && object.respond_to?(:key?)
|
23
|
+
@keys.each { |key| return object[key] if object.key?(key) }
|
24
|
+
nil
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jsapi
|
4
|
+
module Meta
|
5
|
+
module Callable
|
6
|
+
class SymbolSequenceEvaluator
|
7
|
+
attr_reader :symbols
|
8
|
+
|
9
|
+
def initialize(*symbols)
|
10
|
+
@symbols = symbols
|
11
|
+
@callables = symbols.map { |symbol| SymbolEvaluator.new(symbol) }
|
12
|
+
end
|
13
|
+
|
14
|
+
def inspect # :nodoc:
|
15
|
+
"#<#{self.class.name} #{@symbols.inspect}>"
|
16
|
+
end
|
17
|
+
|
18
|
+
# Evaluates the symbols in sequence starting within the context of +object+.
|
19
|
+
def call(object)
|
20
|
+
@callables.each do |callable|
|
21
|
+
object = callable.call(object)
|
22
|
+
break if object.nil?
|
23
|
+
end
|
24
|
+
object
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'callable/symbol_evaluator'
|
4
|
+
require_relative 'callable/symbol_sequence_evaluator'
|
5
|
+
|
6
|
+
module Jsapi
|
7
|
+
module Meta
|
8
|
+
module Callable
|
9
|
+
class << self
|
10
|
+
def from(arg)
|
11
|
+
raise ArgumentError, "argument can't be blank" if arg.blank?
|
12
|
+
|
13
|
+
return arg if arg.respond_to?(:call) # e.g. a Proc
|
14
|
+
|
15
|
+
symbols = Array.wrap(arg).flat_map do |symbol|
|
16
|
+
next symbol if symbol.is_a?(Symbol)
|
17
|
+
|
18
|
+
symbol.to_s.split('.')
|
19
|
+
end.map(&:to_sym)
|
20
|
+
|
21
|
+
return SymbolEvaluator.new(symbols.first) if symbols.one?
|
22
|
+
|
23
|
+
SymbolSequenceEvaluator.new(*symbols)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jsapi
|
4
|
+
module Meta
|
5
|
+
# Holds the default values for a particular Schema type.
|
6
|
+
class Defaults < Base::Model
|
7
|
+
##
|
8
|
+
# :attr: read
|
9
|
+
# The default value of parameters and properties when reading requests.
|
10
|
+
attribute :within_requests, Object
|
11
|
+
|
12
|
+
##
|
13
|
+
# :attr: write
|
14
|
+
# The default value of properties when writing responses.
|
15
|
+
attribute :within_responses, Object
|
16
|
+
|
17
|
+
# Returns the default value within +context+.
|
18
|
+
def value(context:)
|
19
|
+
case context
|
20
|
+
when :request
|
21
|
+
within_requests
|
22
|
+
when :response
|
23
|
+
within_responses
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -3,26 +3,33 @@
|
|
3
3
|
module Jsapi
|
4
4
|
module Meta
|
5
5
|
class Definitions
|
6
|
-
|
7
|
-
|
6
|
+
extend Base::Attributes
|
7
|
+
|
8
|
+
##
|
9
|
+
# :attr: defaults
|
10
|
+
# The general default values.
|
11
|
+
attribute :defaults, { String => Defaults }, keys: Schema::TYPES, default: {}
|
12
|
+
|
13
|
+
##
|
14
|
+
# :attr: openapi_root
|
15
|
+
# The OpenAPI::Root.
|
16
|
+
attribute :openapi_root, OpenAPI::Root
|
17
|
+
|
18
|
+
attr_reader :callbacks, :operations, :parameters, :request_bodies,
|
19
|
+
:rescue_handlers, :responses, :schemas
|
8
20
|
|
9
21
|
def initialize(owner = nil)
|
10
|
-
@callbacks = { on_rescue: [] }
|
11
22
|
@owner = owner
|
12
|
-
@
|
23
|
+
@callbacks = { on_rescue: [] }
|
13
24
|
@operations = {}
|
14
25
|
@parameters = {}
|
15
26
|
@request_bodies = {}
|
27
|
+
@rescue_handlers = []
|
16
28
|
@responses = {}
|
17
29
|
@schemas = {}
|
18
|
-
@rescue_handlers = []
|
19
30
|
@self_and_included = [self]
|
20
31
|
end
|
21
32
|
|
22
|
-
def add_example(name, keywords = {})
|
23
|
-
@examples[name.to_s] = OpenAPI::Example.new(keywords)
|
24
|
-
end
|
25
|
-
|
26
33
|
def add_on_rescue(method_or_proc)
|
27
34
|
@callbacks[:on_rescue] << method_or_proc
|
28
35
|
end
|
@@ -55,11 +62,14 @@ module Jsapi
|
|
55
62
|
@schemas[name] = Schema.new(keywords)
|
56
63
|
end
|
57
64
|
|
58
|
-
def
|
59
|
-
return unless (
|
65
|
+
def default_value(type, context: nil)
|
66
|
+
return unless (type = type.to_s).present?
|
60
67
|
|
61
|
-
|
62
|
-
|
68
|
+
@self_and_included.each do |definitions|
|
69
|
+
default = definitions.default(type)
|
70
|
+
return default.value(context: context) if default
|
71
|
+
end
|
72
|
+
nil
|
63
73
|
end
|
64
74
|
|
65
75
|
def include(definitions)
|
@@ -71,13 +81,13 @@ module Jsapi
|
|
71
81
|
def inspect # :nodoc:
|
72
82
|
"#<#{self.class.name} #{
|
73
83
|
%i[owner operations parameters request_bodies responses schemas
|
74
|
-
|
84
|
+
openapi_root rescue_handlers].map do |name|
|
75
85
|
"#{name}: #{instance_variable_get("@#{name}").inspect}"
|
76
86
|
end.join(', ')
|
77
87
|
}>"
|
78
88
|
end
|
79
89
|
|
80
|
-
# Returns the JSON Schema document for
|
90
|
+
# Returns a hash representing the \JSON \Schema document for +name+.
|
81
91
|
def json_schema_document(name)
|
82
92
|
schema(name)&.to_json_schema&.tap do |hash|
|
83
93
|
definitions =
|
@@ -97,7 +107,8 @@ module Jsapi
|
|
97
107
|
end
|
98
108
|
end
|
99
109
|
|
100
|
-
# Returns a hash representing the OpenAPI document for +version+.
|
110
|
+
# Returns a hash representing the \OpenAPI document for +version+.
|
111
|
+
|
101
112
|
# Raises an +ArgumentError+ if +version+ is not supported.
|
102
113
|
def openapi_document(version = nil)
|
103
114
|
version = OpenAPI::Version.from(version)
|
@@ -111,22 +122,24 @@ module Jsapi
|
|
111
122
|
parameters: openapi_parameters(version),
|
112
123
|
responses: openapi_responses(version)
|
113
124
|
)
|
125
|
+
operations = @self_and_included.map(&:operations).reduce(&:reverse_merge).values
|
126
|
+
|
127
|
+
consumes = operations.filter_map { |operation| operation.consumes(self) }
|
128
|
+
h[:consumes] = consumes.uniq.sort if consumes.present?
|
129
|
+
|
130
|
+
produces = operations.flat_map { |operation| operation.produces(self) }
|
131
|
+
h[:produces] = produces.uniq.sort if produces.present?
|
114
132
|
else
|
115
133
|
h[:components] = (h[:components] || {}).merge(
|
116
134
|
schemas: openapi_schemas(version),
|
117
135
|
parameters: openapi_parameters(version),
|
118
136
|
requestBodies: openapi_request_bodies(version),
|
119
|
-
responses: openapi_responses(version)
|
120
|
-
examples: openapi_examples
|
137
|
+
responses: openapi_responses(version)
|
121
138
|
).compact.presence
|
122
139
|
end
|
123
140
|
end.compact
|
124
141
|
end
|
125
142
|
|
126
|
-
def openapi_root=(keywords = {})
|
127
|
-
@openapi_root = OpenAPI::Root.new(**keywords)
|
128
|
-
end
|
129
|
-
|
130
143
|
def operation(name = nil)
|
131
144
|
if (name = name.to_s).present?
|
132
145
|
definitions = @self_and_included.find { |d| d.operations.key?(name) }
|
@@ -185,13 +198,6 @@ module Jsapi
|
|
185
198
|
@default_path ||= "/#{default_operation_name}"
|
186
199
|
end
|
187
200
|
|
188
|
-
def openapi_examples
|
189
|
-
@self_and_included
|
190
|
-
.map(&:examples).reduce(&:merge)
|
191
|
-
.transform_values(&:to_openapi)
|
192
|
-
.presence
|
193
|
-
end
|
194
|
-
|
195
201
|
def openapi_parameters(version)
|
196
202
|
@self_and_included
|
197
203
|
.map(&:parameters).reduce(&:merge)
|
@@ -4,7 +4,7 @@ module Jsapi
|
|
4
4
|
module Meta
|
5
5
|
module OpenAPI
|
6
6
|
module Callback
|
7
|
-
class Reference <
|
7
|
+
class Reference < Meta::Base::Reference
|
8
8
|
# Returns a hash representing the \OpenAPI reference object.
|
9
9
|
def to_openapi(*)
|
10
10
|
{ '$ref': "#/components/callbacks/#{ref}" }
|
@@ -4,11 +4,23 @@ module Jsapi
|
|
4
4
|
module Meta
|
5
5
|
module OpenAPI
|
6
6
|
module Header
|
7
|
-
class Model < Base
|
7
|
+
class Model < Meta::Base::Model
|
8
8
|
include Extensions
|
9
9
|
|
10
10
|
delegate_missing_to :schema
|
11
11
|
|
12
|
+
##
|
13
|
+
# :attr: collection_format
|
14
|
+
# The collection format of a header whose values are arrays. Possible values are:
|
15
|
+
#
|
16
|
+
# - <code>"csv"</code> - comma separated values
|
17
|
+
# - <code>"pipes"</code> - pipe separated values
|
18
|
+
# - <code>"ssv"</code> - space separated values
|
19
|
+
# - <code>"tsv"</code> - tab separated values
|
20
|
+
#
|
21
|
+
# Applies to \OpenAPI 2.0.
|
22
|
+
attribute :collection_format, values: %w[csv pipes ssv tsv]
|
23
|
+
|
12
24
|
##
|
13
25
|
# :attr: deprecated
|
14
26
|
# Specifies whether or not the header is deprecated.
|
@@ -30,8 +42,10 @@ module Jsapi
|
|
30
42
|
attribute :schema, writer: false
|
31
43
|
|
32
44
|
def initialize(keywords = {})
|
45
|
+
raise ArgumentError, "type can't be object" if keywords[:type] == 'object'
|
46
|
+
|
33
47
|
keywords = keywords.dup
|
34
|
-
super(keywords.extract!(:deprecated, :description, :examples))
|
48
|
+
super(keywords.extract!(:collection_format, :deprecated, :description, :examples))
|
35
49
|
|
36
50
|
add_example(value: keywords.delete(:example)) if keywords.key?(:example)
|
37
51
|
|
@@ -45,6 +59,7 @@ module Jsapi
|
|
45
59
|
with_openapi_extensions(
|
46
60
|
if version.major == 2
|
47
61
|
schema.to_openapi(version).merge(
|
62
|
+
collection_format: (collection_format if array?),
|
48
63
|
description: description
|
49
64
|
)
|
50
65
|
else
|
@@ -4,10 +4,10 @@ module Jsapi
|
|
4
4
|
module Meta
|
5
5
|
module OpenAPI
|
6
6
|
# Represents an OAuth flow object.
|
7
|
-
class OAuthFlow < Base
|
7
|
+
class OAuthFlow < Base::Model
|
8
8
|
include Extensions
|
9
9
|
|
10
|
-
class Scope < Base
|
10
|
+
class Scope < Meta::Base::Model
|
11
11
|
##
|
12
12
|
# :attr: description
|
13
13
|
# The optional description of the scope.
|
@@ -4,7 +4,7 @@ module Jsapi
|
|
4
4
|
module Meta
|
5
5
|
module OpenAPI
|
6
6
|
# Represents an \OpenAPI object.
|
7
|
-
class Root < Base
|
7
|
+
class Root < Meta::Base::Model
|
8
8
|
include Extensions
|
9
9
|
|
10
10
|
##
|
@@ -18,17 +18,13 @@ module Jsapi
|
|
18
18
|
attribute :base_path, String
|
19
19
|
|
20
20
|
##
|
21
|
-
# :attr:
|
22
|
-
# The
|
23
|
-
attribute :
|
24
|
-
|
25
|
-
alias :consumes :consumed_mime_types
|
26
|
-
alias :consumes= :consumed_mime_types=
|
27
|
-
alias :add_consumes :add_consumed_mime_type
|
21
|
+
# :attr: examples
|
22
|
+
# The reusable Example objects. Applies to \OpenAPI 3.0 and higher.
|
23
|
+
attribute :examples, { String => Example }
|
28
24
|
|
29
25
|
##
|
30
26
|
# :attr: external_docs
|
31
|
-
# The
|
27
|
+
# The ExternalDocumentation object.
|
32
28
|
attribute :external_docs, ExternalDocumentation
|
33
29
|
|
34
30
|
##
|
@@ -51,15 +47,6 @@ module Jsapi
|
|
51
47
|
# The reusable Link objects. Applies to \OpenAPI 3.0 and higher.
|
52
48
|
attribute :links, { String => Link }
|
53
49
|
|
54
|
-
##
|
55
|
-
# :attr: produces
|
56
|
-
# The MIME types the API can produce. Applies to \OpenAPI 2.0.
|
57
|
-
attribute :produced_mime_types, [String]
|
58
|
-
|
59
|
-
alias :produces :produced_mime_types
|
60
|
-
alias :produces= :produced_mime_types=
|
61
|
-
alias :add_produces :add_produced_mime_type
|
62
|
-
|
63
50
|
##
|
64
51
|
# :attr: schemes
|
65
52
|
# The array of transfer protocols supported by the API. Possible values are:
|
@@ -111,8 +98,6 @@ module Jsapi
|
|
111
98
|
host: host || uri&.hostname,
|
112
99
|
basePath: base_path || uri&.path,
|
113
100
|
schemes: schemes || uri&.scheme&.then { |scheme| [scheme] },
|
114
|
-
consumes: consumed_mime_types,
|
115
|
-
produces: produced_mime_types,
|
116
101
|
securityDefinitions: security_schemes,
|
117
102
|
security: security_requirements&.map(&:to_openapi),
|
118
103
|
tags: tags&.map(&:to_openapi),
|
@@ -127,6 +112,7 @@ module Jsapi
|
|
127
112
|
callbacks: callbacks&.transform_values do |callback|
|
128
113
|
callback.to_openapi(version, definitions)
|
129
114
|
end,
|
115
|
+
examples: examples&.transform_values(&:to_openapi),
|
130
116
|
headers: headers&.transform_values do |header|
|
131
117
|
header.to_openapi(version)
|
132
118
|
end,
|
@@ -4,8 +4,8 @@ module Jsapi
|
|
4
4
|
module Meta
|
5
5
|
module OpenAPI
|
6
6
|
# Represents a security requirement object.
|
7
|
-
class SecurityRequirement < Base
|
8
|
-
class Scheme < Base
|
7
|
+
class SecurityRequirement < Meta::Base::Model
|
8
|
+
class Scheme < Meta::Base::Model
|
9
9
|
##
|
10
10
|
# :attr: scopes
|
11
11
|
# The array of scopes.
|