Class: Gitlab::GrapeOpenapi::SchemaRegistry
- Inherits:
-
Object
- Object
- Gitlab::GrapeOpenapi::SchemaRegistry
- Defined in:
- lib/gitlab/grape_openapi/schema_registry.rb
Instance Attribute Summary collapse
-
#schemas ⇒ Object
readonly
Returns the value of attribute schemas.
Instance Method Summary collapse
-
#initialize ⇒ SchemaRegistry
constructor
A new instance of SchemaRegistry.
- #normalize_entity_class(entity_class) ⇒ Object
- #register(entity_class, schema) ⇒ Object
Constructor Details
#initialize ⇒ SchemaRegistry
Returns a new instance of SchemaRegistry.
8 9 10 |
# File 'lib/gitlab/grape_openapi/schema_registry.rb', line 8 def initialize @schemas = {} end |
Instance Attribute Details
#schemas ⇒ Object (readonly)
Returns the value of attribute schemas.
6 7 8 |
# File 'lib/gitlab/grape_openapi/schema_registry.rb', line 6 def schemas @schemas end |
Instance Method Details
#normalize_entity_class(entity_class) ⇒ Object
21 22 23 |
# File 'lib/gitlab/grape_openapi/schema_registry.rb', line 21 def normalize_entity_class(entity_class) entity_class.name.delete(':') end |
#register(entity_class, schema) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/gitlab/grape_openapi/schema_registry.rb', line 12 def register(entity_class, schema) normalized_name = normalize_entity_class(entity_class) return normalized_name if @schemas.key?(normalized_name) return normalized_name unless schema.is_a?(Models::Schema) @schemas[normalized_name] = schema normalized_name end |