jsapi 0.7.3 → 0.9.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/lib/jsapi/controller/{error_result.rb → error.rb} +1 -1
- data/lib/jsapi/controller/methods.rb +49 -38
- data/lib/jsapi/controller/parameters.rb +4 -2
- data/lib/jsapi/controller/response.rb +82 -64
- data/lib/jsapi/controller.rb +1 -1
- data/lib/jsapi/dsl/base.rb +55 -0
- data/lib/jsapi/dsl/callback.rb +21 -0
- data/lib/jsapi/dsl/class_methods.rb +116 -10
- data/lib/jsapi/dsl/definitions.rb +173 -33
- data/lib/jsapi/dsl/examples.rb +30 -0
- data/lib/jsapi/dsl/operation.rb +60 -32
- data/lib/jsapi/dsl/parameter.rb +2 -2
- data/lib/jsapi/dsl/request_body.rb +2 -2
- data/lib/jsapi/dsl/response.rb +35 -11
- data/lib/jsapi/dsl/schema.rb +16 -16
- data/lib/jsapi/dsl.rb +4 -4
- data/lib/jsapi/{helpers/invalid_value_helper.rb → invalid_value_helper.rb} +1 -1
- data/lib/jsapi/json/array.rb +7 -7
- data/lib/jsapi/json/object.rb +6 -6
- data/lib/jsapi/json.rb +4 -4
- data/lib/jsapi/meta/base/attributes.rb +21 -19
- data/lib/jsapi/meta/base/model.rb +15 -7
- data/lib/jsapi/meta/callback/model.rb +34 -0
- data/lib/jsapi/meta/callback/reference.rb +14 -0
- data/lib/jsapi/meta/callback.rb +19 -0
- data/lib/jsapi/meta/contact.rb +30 -0
- data/lib/jsapi/meta/defaults.rb +2 -2
- data/lib/jsapi/meta/definitions.rb +230 -124
- data/lib/jsapi/meta/example/model.rb +43 -0
- data/lib/jsapi/meta/example/reference.rb +14 -0
- data/lib/jsapi/meta/example.rb +19 -0
- data/lib/jsapi/meta/external_documentation.rb +25 -0
- data/lib/jsapi/meta/header/model.rb +81 -0
- data/lib/jsapi/meta/header/reference.rb +14 -0
- data/lib/jsapi/meta/header.rb +19 -0
- data/lib/jsapi/meta/info.rb +52 -0
- data/lib/jsapi/meta/license.rb +25 -0
- data/lib/jsapi/meta/link/model.rb +48 -0
- data/lib/jsapi/meta/link/reference.rb +14 -0
- data/lib/jsapi/meta/link.rb +19 -0
- data/lib/jsapi/meta/oauth_flow.rb +52 -0
- data/lib/jsapi/meta/openapi.rb +0 -28
- data/lib/jsapi/meta/operation.rb +19 -18
- data/lib/jsapi/meta/parameter/model.rb +6 -4
- data/lib/jsapi/meta/parameter/reference.rb +6 -4
- data/lib/jsapi/meta/parameter/to_openapi.rb +13 -0
- data/lib/jsapi/meta/parameter.rb +2 -1
- data/lib/jsapi/meta/property.rb +1 -1
- data/lib/jsapi/meta/request_body/model.rb +6 -5
- data/lib/jsapi/meta/request_body.rb +1 -1
- data/lib/jsapi/meta/response/model.rb +16 -13
- data/lib/jsapi/meta/response.rb +1 -1
- data/lib/jsapi/meta/schema/array.rb +1 -1
- data/lib/jsapi/meta/schema/base.rb +5 -5
- data/lib/jsapi/meta/schema/discriminator.rb +2 -2
- data/lib/jsapi/meta/schema/object.rb +3 -3
- data/lib/jsapi/meta/schema/reference.rb +1 -1
- data/lib/jsapi/meta/schema.rb +2 -2
- data/lib/jsapi/meta/security_requirement.rb +25 -0
- data/lib/jsapi/meta/security_scheme/api_key.rb +38 -0
- data/lib/jsapi/meta/security_scheme/base.rb +14 -0
- data/lib/jsapi/meta/security_scheme/http/basic.rb +34 -0
- data/lib/jsapi/meta/security_scheme/http/bearer.rb +36 -0
- data/lib/jsapi/meta/security_scheme/http/other.rb +36 -0
- data/lib/jsapi/meta/security_scheme/http.rb +29 -0
- data/lib/jsapi/meta/security_scheme/oauth2.rb +44 -0
- data/lib/jsapi/meta/security_scheme/open_id_connect.rb +32 -0
- data/lib/jsapi/meta/security_scheme.rb +49 -0
- data/lib/jsapi/meta/server.rb +34 -0
- data/lib/jsapi/meta/server_variable.rb +34 -0
- data/lib/jsapi/meta/tag.rb +34 -0
- data/lib/jsapi/meta.rb +15 -1
- data/lib/jsapi/model/base.rb +5 -5
- data/lib/jsapi/version.rb +1 -1
- data/lib/jsapi.rb +1 -1
- metadata +40 -44
- data/lib/jsapi/dsl/node.rb +0 -62
- data/lib/jsapi/dsl/openapi/callback.rb +0 -23
- data/lib/jsapi/dsl/openapi/callbacks.rb +0 -34
- data/lib/jsapi/dsl/openapi/examples.rb +0 -32
- data/lib/jsapi/dsl/openapi/root.rb +0 -126
- data/lib/jsapi/dsl/openapi.rb +0 -6
- data/lib/jsapi/meta/openapi/callback/model.rb +0 -34
- data/lib/jsapi/meta/openapi/callback/reference.rb +0 -16
- data/lib/jsapi/meta/openapi/callback.rb +0 -21
- data/lib/jsapi/meta/openapi/contact.rb +0 -32
- data/lib/jsapi/meta/openapi/example/model.rb +0 -44
- data/lib/jsapi/meta/openapi/example/reference.rb +0 -16
- data/lib/jsapi/meta/openapi/example.rb +0 -21
- data/lib/jsapi/meta/openapi/external_documentation.rb +0 -27
- data/lib/jsapi/meta/openapi/header/model.rb +0 -82
- data/lib/jsapi/meta/openapi/header/reference.rb +0 -16
- data/lib/jsapi/meta/openapi/header.rb +0 -21
- data/lib/jsapi/meta/openapi/info.rb +0 -54
- data/lib/jsapi/meta/openapi/license.rb +0 -27
- data/lib/jsapi/meta/openapi/link/model.rb +0 -50
- data/lib/jsapi/meta/openapi/link/reference.rb +0 -16
- data/lib/jsapi/meta/openapi/link.rb +0 -21
- data/lib/jsapi/meta/openapi/oauth_flow.rb +0 -52
- data/lib/jsapi/meta/openapi/root.rb +0 -132
- data/lib/jsapi/meta/openapi/security_requirement.rb +0 -27
- data/lib/jsapi/meta/openapi/security_scheme/api_key.rb +0 -40
- data/lib/jsapi/meta/openapi/security_scheme/base.rb +0 -16
- data/lib/jsapi/meta/openapi/security_scheme/http/basic.rb +0 -36
- data/lib/jsapi/meta/openapi/security_scheme/http/bearer.rb +0 -39
- data/lib/jsapi/meta/openapi/security_scheme/http/other.rb +0 -39
- data/lib/jsapi/meta/openapi/security_scheme/http.rb +0 -31
- data/lib/jsapi/meta/openapi/security_scheme/oauth2.rb +0 -46
- data/lib/jsapi/meta/openapi/security_scheme/open_id_connect.rb +0 -34
- data/lib/jsapi/meta/openapi/security_scheme.rb +0 -51
- data/lib/jsapi/meta/openapi/server.rb +0 -36
- data/lib/jsapi/meta/openapi/server_variable.rb +0 -36
- data/lib/jsapi/meta/openapi/tag.rb +0 -36
data/lib/jsapi/dsl/schema.rb
CHANGED
@@ -2,13 +2,13 @@
|
|
2
2
|
|
3
3
|
module Jsapi
|
4
4
|
module DSL
|
5
|
-
# Used to
|
6
|
-
class Schema <
|
5
|
+
# Used to define a schema.
|
6
|
+
class Schema < Base
|
7
7
|
|
8
8
|
# Includes all of the properties from +schemas+. Each argument must be the name of
|
9
9
|
# a schema defined by ClassMethods#api_schema or Definitions#schema.
|
10
10
|
def all_of(*schemas)
|
11
|
-
schemas.each { |schema|
|
11
|
+
schemas.each { |schema| @meta_model.add_all_of({ ref: schema }) }
|
12
12
|
end
|
13
13
|
|
14
14
|
##
|
@@ -57,7 +57,7 @@ module Jsapi
|
|
57
57
|
#
|
58
58
|
# example 'foo'
|
59
59
|
def example(example)
|
60
|
-
|
60
|
+
@meta_model.add_example(example)
|
61
61
|
end
|
62
62
|
|
63
63
|
##
|
@@ -77,7 +77,7 @@ module Jsapi
|
|
77
77
|
#
|
78
78
|
# See Meta::Schema::String#format for further information.
|
79
79
|
def format(format)
|
80
|
-
|
80
|
+
keyword(:format, format)
|
81
81
|
end
|
82
82
|
|
83
83
|
# Defines the kind of items that can be contained in an array.
|
@@ -88,12 +88,12 @@ module Jsapi
|
|
88
88
|
#
|
89
89
|
# Raises an Error if type is other than <code>"array"</code>.
|
90
90
|
def items(**keywords, &block)
|
91
|
-
unless
|
92
|
-
raise Error, "items isn't supported for '#{
|
91
|
+
unless @meta_model.respond_to?(:items=)
|
92
|
+
raise Error, "items isn't supported for '#{@meta_model.type}'"
|
93
93
|
end
|
94
94
|
|
95
|
-
|
96
|
-
Schema.new(
|
95
|
+
@meta_model.items = keywords
|
96
|
+
Schema.new(@meta_model.items, &block) if block
|
97
97
|
end
|
98
98
|
|
99
99
|
##
|
@@ -159,15 +159,15 @@ module Jsapi
|
|
159
159
|
#
|
160
160
|
# Raises an Error if type is other than <code>"object"</code>.
|
161
161
|
def model(klass = nil, &block)
|
162
|
-
unless
|
163
|
-
raise Error, "model isn't supported for '#{
|
162
|
+
unless @meta_model.respond_to?(:model=)
|
163
|
+
raise Error, "model isn't supported for '#{@meta_model.type}'"
|
164
164
|
end
|
165
165
|
|
166
166
|
if block
|
167
167
|
klass = Class.new(klass || Model::Base)
|
168
168
|
klass.class_eval(&block)
|
169
169
|
end
|
170
|
-
|
170
|
+
@meta_model.model = klass
|
171
171
|
end
|
172
172
|
|
173
173
|
##
|
@@ -194,12 +194,12 @@ module Jsapi
|
|
194
194
|
#
|
195
195
|
# Raises an Error if type is other than <code>"object"</code>.
|
196
196
|
def property(name, **keywords, &block)
|
197
|
-
|
198
|
-
unless
|
199
|
-
raise Error, "property isn't supported for '#{
|
197
|
+
define('property', name.inspect) do
|
198
|
+
unless @meta_model.respond_to?(:add_property)
|
199
|
+
raise Error, "property isn't supported for '#{@meta_model.type}'"
|
200
200
|
end
|
201
201
|
|
202
|
-
property_model =
|
202
|
+
property_model = @meta_model.add_property(name, keywords)
|
203
203
|
Schema.new(property_model, &block) if block
|
204
204
|
end
|
205
205
|
end
|
data/lib/jsapi/dsl.rb
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'dsl/error'
|
4
|
-
require_relative 'dsl/
|
5
|
-
require_relative 'dsl/
|
4
|
+
require_relative 'dsl/base'
|
5
|
+
require_relative 'dsl/examples'
|
6
6
|
require_relative 'dsl/schema'
|
7
7
|
require_relative 'dsl/parameter'
|
8
8
|
require_relative 'dsl/request_body'
|
9
9
|
require_relative 'dsl/response'
|
10
|
+
require_relative 'dsl/callback'
|
10
11
|
require_relative 'dsl/operation'
|
11
12
|
require_relative 'dsl/definitions'
|
12
13
|
require_relative 'dsl/class_methods'
|
13
14
|
|
14
15
|
module Jsapi
|
15
|
-
#
|
16
|
-
# See ClassMethods for details.
|
16
|
+
# The \DSL to define API components.
|
17
17
|
module DSL
|
18
18
|
def self.included(base) # :nodoc:
|
19
19
|
base.extend(ClassMethods)
|
data/lib/jsapi/json/array.rb
CHANGED
@@ -4,30 +4,30 @@ module Jsapi
|
|
4
4
|
module JSON
|
5
5
|
# Represents a JSON array.
|
6
6
|
class Array < Value
|
7
|
-
def initialize(
|
7
|
+
def initialize(array, schema, definitions, context: nil)
|
8
8
|
super(schema)
|
9
|
-
@
|
10
|
-
JSON.wrap(
|
9
|
+
@json_values = Array(array).map do |item|
|
10
|
+
JSON.wrap(item, schema.items, definitions, context: context)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
# Returns true if it contains no elements, false otherwise.
|
15
15
|
def empty?
|
16
|
-
@
|
16
|
+
@json_values.empty?
|
17
17
|
end
|
18
18
|
|
19
19
|
def inspect # :nodoc:
|
20
|
-
"#<#{self.class.name} [#{@
|
20
|
+
"#<#{self.class.name} [#{@json_values.map(&:inspect).join(', ')}]>"
|
21
21
|
end
|
22
22
|
|
23
23
|
def validate(errors) # :nodoc:
|
24
24
|
return false unless super
|
25
25
|
|
26
|
-
@
|
26
|
+
@json_values.map { |element| element.validate(errors) }.all?
|
27
27
|
end
|
28
28
|
|
29
29
|
def value
|
30
|
-
@value ||= @
|
30
|
+
@value ||= @json_values.map(&:value)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
data/lib/jsapi/json/object.rb
CHANGED
@@ -8,20 +8,20 @@ module Jsapi
|
|
8
8
|
|
9
9
|
attr_reader :raw_additional_attributes, :raw_attributes
|
10
10
|
|
11
|
-
def initialize(
|
12
|
-
schema = schema.resolve_schema(
|
13
|
-
properties = schema.resolve_properties(definitions, context:
|
11
|
+
def initialize(hash, schema, definitions, context: nil)
|
12
|
+
schema = schema.resolve_schema(hash, definitions, context: context)
|
13
|
+
properties = schema.resolve_properties(definitions, context: context)
|
14
14
|
|
15
15
|
@raw_attributes = properties.transform_values do |property|
|
16
|
-
JSON.wrap(
|
16
|
+
JSON.wrap(hash[property.name], property.schema, definitions, context: context)
|
17
17
|
end
|
18
18
|
|
19
19
|
@raw_additional_attributes =
|
20
20
|
if (additional_properties = schema.additional_properties)
|
21
21
|
additional_properties_schema = additional_properties.schema.resolve(definitions)
|
22
22
|
|
23
|
-
|
24
|
-
JSON.wrap(value, additional_properties_schema, definitions)
|
23
|
+
hash.except(*properties.keys).transform_values do |value|
|
24
|
+
JSON.wrap(value, additional_properties_schema, definitions, context: context)
|
25
25
|
end
|
26
26
|
end || {}
|
27
27
|
|
data/lib/jsapi/json.rb
CHANGED
@@ -13,15 +13,15 @@ module Jsapi
|
|
13
13
|
# Provides a DOM for JSON values.
|
14
14
|
module JSON
|
15
15
|
class << self
|
16
|
-
def wrap(object, schema, definitions = nil)
|
16
|
+
def wrap(object, schema, definitions = nil, context: nil)
|
17
17
|
schema = schema.resolve(definitions) unless definitions.nil?
|
18
18
|
|
19
|
-
object = schema.default_value(definitions, context:
|
19
|
+
object = schema.default_value(definitions, context: context) if object.nil?
|
20
20
|
return Null.new(schema) if object.nil?
|
21
21
|
|
22
22
|
case schema.type
|
23
23
|
when 'array'
|
24
|
-
Array.new(object, schema, definitions)
|
24
|
+
Array.new(object, schema, definitions, context: context)
|
25
25
|
when 'boolean'
|
26
26
|
Boolean.new(object, schema)
|
27
27
|
when 'integer'
|
@@ -29,7 +29,7 @@ module Jsapi
|
|
29
29
|
when 'number'
|
30
30
|
Number.new(object, schema)
|
31
31
|
when 'object'
|
32
|
-
Object.new(object, schema, definitions)
|
32
|
+
Object.new(object, schema, definitions, context: context)
|
33
33
|
when 'string'
|
34
34
|
String.new(object, schema)
|
35
35
|
else
|
@@ -4,9 +4,11 @@ module Jsapi
|
|
4
4
|
module Meta
|
5
5
|
module Base
|
6
6
|
module Attributes
|
7
|
+
DEFAULT_ARRAY = [].freeze
|
8
|
+
DEFAULT_HASH = {}.freeze
|
9
|
+
|
7
10
|
# Defines an attribute.
|
8
11
|
def attribute(name, type = Object,
|
9
|
-
add_method: nil,
|
10
12
|
default: nil,
|
11
13
|
default_key: nil,
|
12
14
|
keys: nil,
|
@@ -17,26 +19,20 @@ module Jsapi
|
|
17
19
|
|
18
20
|
instance_variable_name = "@#{name}"
|
19
21
|
|
20
|
-
# Attribute reader
|
21
|
-
define_method(name) do
|
22
|
-
value = instance_variable_get(instance_variable_name)
|
23
|
-
value.nil? ? default : value
|
24
|
-
end
|
25
|
-
|
26
22
|
case type
|
27
23
|
when Array
|
24
|
+
# General default
|
25
|
+
default ||= DEFAULT_ARRAY
|
26
|
+
|
28
27
|
unless read_only
|
29
28
|
singular_name = name.to_s.singularize
|
30
|
-
add_method = "add_#{singular_name}"
|
29
|
+
add_method = "add_#{singular_name}"
|
31
30
|
|
32
31
|
type_caster = TypeCaster.new(type.first, values: values, name: singular_name)
|
33
32
|
|
34
33
|
# Attribute writer
|
35
34
|
define_method("#{name}=") do |argument|
|
36
|
-
|
37
|
-
instance_variable_set(instance_variable_name, nil)
|
38
|
-
else
|
39
|
-
instance_variable_set(instance_variable_name, [])
|
35
|
+
instance_variable_set(instance_variable_name, []).tap do
|
40
36
|
Array.wrap(argument).each { |element| send(add_method, element) }
|
41
37
|
end
|
42
38
|
end
|
@@ -59,24 +55,24 @@ module Jsapi
|
|
59
55
|
key_type, value_type = type.first
|
60
56
|
key_type_caster = TypeCaster.new(key_type, values: keys, name: 'key')
|
61
57
|
|
58
|
+
# General default
|
59
|
+
default ||= DEFAULT_HASH
|
60
|
+
|
62
61
|
# Lookup method
|
63
62
|
define_method(singular_name) do |key = nil|
|
64
63
|
key = default_key if key.to_s.empty?
|
65
|
-
send(name)
|
64
|
+
send(name)[key_type_caster.cast(key)]
|
66
65
|
end
|
67
66
|
|
68
67
|
unless read_only
|
69
|
-
add_method = "add_#{singular_name}"
|
68
|
+
add_method = "add_#{singular_name}"
|
70
69
|
|
71
70
|
value_type_caster = TypeCaster.new(value_type, values: values)
|
72
71
|
|
73
72
|
# Attribute writer
|
74
73
|
define_method("#{name}=") do |argument|
|
75
|
-
|
76
|
-
|
77
|
-
else
|
78
|
-
instance_variable_set(instance_variable_name, {})
|
79
|
-
argument.each { |key, value| send(add_method, key, value) }
|
74
|
+
instance_variable_set(instance_variable_name, {}).tap do
|
75
|
+
Hash(argument).each { |key, value| send(add_method, key, value) }
|
80
76
|
end
|
81
77
|
end
|
82
78
|
|
@@ -123,6 +119,12 @@ module Jsapi
|
|
123
119
|
end
|
124
120
|
end
|
125
121
|
end
|
122
|
+
|
123
|
+
# Attribute reader
|
124
|
+
define_method(name) do
|
125
|
+
value = instance_variable_get(instance_variable_name)
|
126
|
+
value.nil? ? default : value
|
127
|
+
end
|
126
128
|
end
|
127
129
|
|
128
130
|
def attribute_names
|
@@ -11,13 +11,7 @@ module Jsapi
|
|
11
11
|
#
|
12
12
|
# Raises an +ArgumentError+ if at least one keyword is not supported.
|
13
13
|
def initialize(keywords = {})
|
14
|
-
keywords
|
15
|
-
if respond_to?(method = "#{key}=")
|
16
|
-
public_send(method, value)
|
17
|
-
else
|
18
|
-
raise ArgumentError, "unsupported keyword: #{key}"
|
19
|
-
end
|
20
|
-
end
|
14
|
+
merge!(keywords)
|
21
15
|
end
|
22
16
|
|
23
17
|
def inspect(*attributes) # :nodoc:
|
@@ -30,6 +24,20 @@ module Jsapi
|
|
30
24
|
}>"
|
31
25
|
end
|
32
26
|
|
27
|
+
# Merges +keywords+ into the model.
|
28
|
+
#
|
29
|
+
# Raises an +ArgumentError+ if at least one keyword is not supported.
|
30
|
+
def merge!(keywords = {})
|
31
|
+
keywords.each do |key, value|
|
32
|
+
if respond_to?(method = "#{key}=")
|
33
|
+
public_send(method, value)
|
34
|
+
else
|
35
|
+
raise ArgumentError, "unsupported keyword: #{key}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
self
|
39
|
+
end
|
40
|
+
|
33
41
|
# Returns false.
|
34
42
|
def reference?
|
35
43
|
false
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jsapi
|
4
|
+
module Meta
|
5
|
+
class Operation < Base::Model; end
|
6
|
+
|
7
|
+
module Callback
|
8
|
+
# Specifies a callback object. Applies to \OpenAPI 3.0 and higher.
|
9
|
+
class Model < Base::Model
|
10
|
+
##
|
11
|
+
# :attr: operations
|
12
|
+
attribute :operations, { String => Operation }
|
13
|
+
|
14
|
+
undef add_operation
|
15
|
+
|
16
|
+
# Adds a callback operation.
|
17
|
+
#
|
18
|
+
# Raises an +ArgumentError+ if +expression+ is blank.
|
19
|
+
def add_operation(expression, keywords = {})
|
20
|
+
raise ArgumentError, "expression can't be blank" if expression.blank?
|
21
|
+
|
22
|
+
(@operations ||= {})[expression.to_s] = Operation.new(nil, keywords)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Returns a hash representing the \OpenAPI callback object.
|
26
|
+
def to_openapi(version, definitions)
|
27
|
+
operations.transform_values do |operation|
|
28
|
+
{ operation.method => operation.to_openapi(version, definitions) }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jsapi
|
4
|
+
module Meta
|
5
|
+
module Callback
|
6
|
+
class Reference < Base::Reference
|
7
|
+
# Returns a hash representing the \OpenAPI reference object.
|
8
|
+
def to_openapi(*)
|
9
|
+
{ '$ref': "#/components/callbacks/#{ref}" }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'callback/model'
|
4
|
+
require_relative 'callback/reference'
|
5
|
+
|
6
|
+
module Jsapi
|
7
|
+
module Meta
|
8
|
+
module Callback
|
9
|
+
class << self
|
10
|
+
# Creates a Model or Reference.
|
11
|
+
def new(keywords = {})
|
12
|
+
return Reference.new(keywords) if keywords.key?(:ref)
|
13
|
+
|
14
|
+
Model.new(keywords)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jsapi
|
4
|
+
module Meta
|
5
|
+
# Specifies a contact object.
|
6
|
+
class Contact < Base::Model
|
7
|
+
include OpenAPI::Extensions
|
8
|
+
|
9
|
+
##
|
10
|
+
# :attr: email
|
11
|
+
# The email address of the contact.
|
12
|
+
attribute :email, String
|
13
|
+
|
14
|
+
##
|
15
|
+
# :attr: name
|
16
|
+
# The name of the contact.
|
17
|
+
attribute :name, String
|
18
|
+
|
19
|
+
##
|
20
|
+
# :attr: url
|
21
|
+
# The URL of the contact.
|
22
|
+
attribute :url, String
|
23
|
+
|
24
|
+
# Returns a hash representing the \OpenAPI contact object.
|
25
|
+
def to_openapi(*)
|
26
|
+
with_openapi_extensions(name: name, url: url, email: email)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/jsapi/meta/defaults.rb
CHANGED
@@ -5,12 +5,12 @@ module Jsapi
|
|
5
5
|
# Holds the default values for a particular Schema type.
|
6
6
|
class Defaults < Base::Model
|
7
7
|
##
|
8
|
-
# :attr:
|
8
|
+
# :attr: within_requests
|
9
9
|
# The default value of parameters and properties when reading requests.
|
10
10
|
attribute :within_requests
|
11
11
|
|
12
12
|
##
|
13
|
-
# :attr:
|
13
|
+
# :attr: within_responses
|
14
14
|
# The default value of properties when writing responses.
|
15
15
|
attribute :within_responses
|
16
16
|
|