Class: JsonSchemaView::JsonWorldExtensions::MapType
- Inherits:
-
Object
- Object
- JsonSchemaView::JsonWorldExtensions::MapType
- Defined in:
- lib/json_schema_view/json_world_extensions/map_type.rb
Overview
This class implements map type (string keys to values with the given type) in JSON Schema. You can specify the type of values but you cannot specify the type of keys, because JSON and JSON Schema only support String keys in objects.
Defined Under Namespace
Modules: DSL
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #as_json_schema ⇒ Object (also: #as_json_schema_without_links)
-
#initialize(type) ⇒ MapType
constructor
A new instance of MapType.
Constructor Details
#initialize(type) ⇒ MapType
Returns a new instance of MapType.
33 34 35 |
# File 'lib/json_schema_view/json_world_extensions/map_type.rb', line 33 def initialize(type) @type = type end |
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
31 32 33 |
# File 'lib/json_schema_view/json_world_extensions/map_type.rb', line 31 def type @type end |
Instance Method Details
#as_json_schema ⇒ Object Also known as: as_json_schema_without_links
37 38 39 40 41 42 |
# File 'lib/json_schema_view/json_world_extensions/map_type.rb', line 37 def as_json_schema { type: "object", additionalProperties: JsonWorld::PropertyDefinition.new(type: type).as_json_schema } end |