Class: JSON::SchemaDsl::Renderers::Alias
- Defined in:
- lib/json/schema_dsl/renderers/alias.rb
Overview
Aliases certain attributes and camel-cases all others. The only exception are property names which are set by the user and will not be camel-cased.
Constant Summary collapse
- ALIASES =
{ 'ref' => '$ref' }.freeze
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#visit(entity) ⇒ Object
Camel-case and/or alias the attribute names of the given structure.
Methods inherited from Base
Constructor Details
This class inherits a constructor from JSON::SchemaDsl::Renderers::Base
Instance Method Details
#visit(entity) ⇒ Object
Camel-case and/or alias the attribute names of the given structure.
15 16 17 18 19 |
# File 'lib/json/schema_dsl/renderers/alias.rb', line 15 def visit(entity) traverse(entity .transform_keys { |key| ALIASES[key.to_s]&.to_sym || key } .transform_keys { |key| camelize_snake_cased(key) }) end |