Class: Serega::SeregaPlugins::OpenAPI::OpenAPIConfig
- Inherits:
-
Object
- Object
- Serega::SeregaPlugins::OpenAPI::OpenAPIConfig
- Defined in:
- lib/serega/plugins/openapi/lib/openapi_config.rb
Overview
OpenAPI plugin config
Instance Attribute Summary collapse
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
-
#serializer_class ⇒ Object
readonly
Returns the value of attribute serializer_class.
Instance Method Summary collapse
-
#initialize(serializer_class, opts) ⇒ OpenAPIConfig
constructor
A new instance of OpenAPIConfig.
-
#properties(new_properties = FROZEN_EMPTY_HASH) ⇒ Hash
Saves new properties.
-
#ref_builder ⇒ #call
Builder of ‘$ref` attribute.
-
#ref_builder=(builder) ⇒ Object
Sets new $ref option builder.
-
#schema_name_builder ⇒ #call
Builder of schema name.
-
#schema_name_builder=(builder) ⇒ Object
Sets new schema_name_builder.
Constructor Details
#initialize(serializer_class, opts) ⇒ OpenAPIConfig
Returns a new instance of OpenAPIConfig.
12 13 14 15 |
# File 'lib/serega/plugins/openapi/lib/openapi_config.rb', line 12 def initialize(serializer_class, opts) @serializer_class = serializer_class @opts = opts end |
Instance Attribute Details
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
10 11 12 |
# File 'lib/serega/plugins/openapi/lib/openapi_config.rb', line 10 def opts @opts end |
#serializer_class ⇒ Object (readonly)
Returns the value of attribute serializer_class.
10 11 12 |
# File 'lib/serega/plugins/openapi/lib/openapi_config.rb', line 10 def serializer_class @serializer_class end |
Instance Method Details
#properties(new_properties = FROZEN_EMPTY_HASH) ⇒ Hash
Saves new properties
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/serega/plugins/openapi/lib/openapi_config.rb', line 24 def properties(new_properties = FROZEN_EMPTY_HASH) properties = opts[:properties] return properties if new_properties.empty? new_properties = SeregaUtils::EnumDeepDup.call(new_properties) symbolize_keys!(new_properties) new_properties.each do |attribute_name, new_attribute_properties| check_attribute_exists(attribute_name) check_properties_is_a_hash(attribute_name, new_attribute_properties) properties[attribute_name] = symbolize_keys!(new_attribute_properties) end end |
#ref_builder ⇒ #call
Returns builder of ‘$ref` attribute.
42 43 44 |
# File 'lib/serega/plugins/openapi/lib/openapi_config.rb', line 42 def ref_builder opts[:ref_builder] end |
#ref_builder=(builder) ⇒ Object
Sets new $ref option builder
53 54 55 56 |
# File 'lib/serega/plugins/openapi/lib/openapi_config.rb', line 53 def ref_builder=(builder) raise SeregaError, "ref_builder must respond to #call" unless builder.respond_to?(:call) opts[:ref_builder] = builder end |
#schema_name_builder ⇒ #call
Returns builder of schema name.
61 62 63 |
# File 'lib/serega/plugins/openapi/lib/openapi_config.rb', line 61 def schema_name_builder opts[:schema_name_builder] end |
#schema_name_builder=(builder) ⇒ Object
Sets new schema_name_builder
73 74 75 76 |
# File 'lib/serega/plugins/openapi/lib/openapi_config.rb', line 73 def schema_name_builder=(builder) raise SeregaError, "schema_name_builder must respond to #call" unless builder.respond_to?(:call) opts[:schema_name_builder] = builder end |