Class: Yori::Schema::V3::Components
Overview
Components
Holds a set of reusable objects for different aspects of the OAS.
All objects defined within the components object will have no effect on the API
unless they are explicitly referenced from properties outside the components object.
Constant Summary
collapse
- VALID_COMPONENTS =
%w[schema response parameter example requestBody header securityScheme link callback].freeze
Instance Attribute Summary
#id
Class Method Summary
collapse
Instance Method Summary
collapse
eval_class!, eval_hash!, eval_input!, #ref, #validate!, #validator
Class Method Details
.register_component(id, component, key, value = nil, &block) ⇒ Object
60
61
62
63
64
65
|
# File 'lib/yori/schema/v3/components.rb', line 60
def register_component(id, component, key, value = nil, &block)
@registered_components ||= {}
@registered_components[id] ||= {}
@registered_components[id][component.to_s] ||= {}
@registered_components[id][component.to_s][key.to_s] = proc { check_and_send!(component, key, value, &block) }
end
|
.registered_components ⇒ Object
56
57
58
|
# File 'lib/yori/schema/v3/components.rb', line 56
def registered_components
@registered_components ||= {}
end
|
Instance Method Details
#callbacks(AnobjecttoholdreusableCallbackObjects.) ⇒ Object
38
|
# File 'lib/yori/schema/v3/components.rb', line 38
hash_field_block :callbacks, :callback, Yori::Schema::V3::Callback
|
#check_and_send!(component, key, value, &block) ⇒ Object
50
51
52
53
|
# File 'lib/yori/schema/v3/components.rb', line 50
def check_and_send!(component, key, value, &block)
raise Yori::Errors::UnknownComponentError, "Unknown component: #{component}" unless VALID_COMPONENTS.include?(component.to_s)
send(component, key, value, &block)
end
|
#examples(AnobjecttoholdreusableExampleObjects.) ⇒ Object
28
|
# File 'lib/yori/schema/v3/components.rb', line 28
hash_field_block :examples, :example, Yori::Schema::V3::Example
|
32
|
# File 'lib/yori/schema/v3/components.rb', line 32
hash_field_block :headers, :header, Yori::Schema::V3::Header
|
#links(AnobjecttoholdreusableLinkObjects.) ⇒ Object
36
|
# File 'lib/yori/schema/v3/components.rb', line 36
hash_field_block :links, :link, Yori::Schema::V3::Link
|
#merge_registered! ⇒ Object
40
41
42
43
44
45
46
|
# File 'lib/yori/schema/v3/components.rb', line 40
def merge_registered!
components ||= self.class.registered_components[id]
components.flat_map { |_component, procs| procs.values }
.each do |block|
instance_eval(&block)
end
end
|
#parameters(AnobjecttoholdreusableParameterObjects.) ⇒ Object
26
|
# File 'lib/yori/schema/v3/components.rb', line 26
hash_field_block :parameters, :parameter, Yori::Schema::V3::Parameter
|
#requestBodies(AnobjecttoholdreusableRequestBodyObjects.) ⇒ Object
30
|
# File 'lib/yori/schema/v3/components.rb', line 30
hash_field_block :requestBodies, :requestBody, Yori::Schema::V3::RequestBody
|
#responses(AnobjecttoholdreusableResponseObjects.) ⇒ Object
24
|
# File 'lib/yori/schema/v3/components.rb', line 24
hash_field_block :responses, :response, Yori::Schema::V3::Response
|
#schemas(AnobjecttoholdreusableSchemaObjects.) ⇒ Object
22
|
# File 'lib/yori/schema/v3/components.rb', line 22
hash_field_block :schemas, :schema, Yori::Schema::V3::Schema
|
#securitySchemes(AnobjecttoholdreusableSecuritySchemeObjects.) ⇒ Object
34
|
# File 'lib/yori/schema/v3/components.rb', line 34
hash_field_block :securitySchemes, :securityScheme, Yori::Schema::V3::SecurityScheme
|