Class: GrapeOAS::Introspectors::EntityIntrospectorSupport::PropertyExtractor
- Inherits:
-
Object
- Object
- GrapeOAS::Introspectors::EntityIntrospectorSupport::PropertyExtractor
- Defined in:
- lib/grape_oas/introspectors/entity_introspector_support/property_extractor.rb
Overview
Utility class for extracting properties from entity documentation hashes. All methods are stateless and can be called directly on the class.
Class Method Summary collapse
-
.apply_entity_level_properties(schema, doc) ⇒ Object
Applies entity-level properties to a schema.
-
.extract_description(hash) ⇒ String?
Extracts description from a documentation hash.
-
.extract_merge_flag(exposure, doc, opts) ⇒ Boolean?
Extracts merge flag from exposure options and documentation.
-
.extract_nullable(doc) ⇒ Boolean
Extracts nullable flag from a documentation hash.
Class Method Details
.apply_entity_level_properties(schema, doc) ⇒ Object
Applies entity-level properties to a schema.
41 42 43 44 45 46 47 48 49 |
# File 'lib/grape_oas/introspectors/entity_introspector_support/property_extractor.rb', line 41 def apply_entity_level_properties(schema, doc) schema.additional_properties = doc[:additional_properties] if doc.key?(:additional_properties) schema.unevaluated_properties = doc[:unevaluated_properties] if doc.key?(:unevaluated_properties) defs = doc[:defs] || doc[:$defs] schema.defs = defs if defs.is_a?(Hash) rescue NoMethodError # Silently handle errors when schema doesn't respond to setters end |
.extract_description(hash) ⇒ String?
Extracts description from a documentation hash.
14 15 16 17 |
# File 'lib/grape_oas/introspectors/entity_introspector_support/property_extractor.rb', line 14 def extract_description(hash) desc = hash[:description] || hash[:desc] desc.is_a?(String) ? desc : nil end |
.extract_merge_flag(exposure, doc, opts) ⇒ Boolean?
Extracts merge flag from exposure options and documentation.
33 34 35 |
# File 'lib/grape_oas/introspectors/entity_introspector_support/property_extractor.rb', line 33 def extract_merge_flag(exposure, doc, opts) opts[:merge] || doc[:merge] || (exposure.respond_to?(:for_merge) && exposure.for_merge) end |
.extract_nullable(doc) ⇒ Boolean
Extracts nullable flag from a documentation hash.
23 24 25 |
# File 'lib/grape_oas/introspectors/entity_introspector_support/property_extractor.rb', line 23 def extract_nullable(doc) doc[:nullable] || doc["nullable"] || false end |