Module: Jsapi::Meta::Schema
- Defined in:
- lib/jsapi/meta/schema.rb,
lib/jsapi/meta/schema/base.rb,
lib/jsapi/meta/schema/array.rb,
lib/jsapi/meta/schema/number.rb,
lib/jsapi/meta/schema/object.rb,
lib/jsapi/meta/schema/string.rb,
lib/jsapi/meta/schema/boolean.rb,
lib/jsapi/meta/schema/integer.rb,
lib/jsapi/meta/schema/numeric.rb,
lib/jsapi/meta/schema/boundary.rb,
lib/jsapi/meta/schema/delegator.rb,
lib/jsapi/meta/schema/reference.rb,
lib/jsapi/meta/schema/conversion.rb,
lib/jsapi/meta/schema/discriminator.rb,
lib/jsapi/meta/schema/validation/base.rb,
lib/jsapi/meta/schema/validation/enum.rb,
lib/jsapi/meta/schema/validation/maximum.rb,
lib/jsapi/meta/schema/validation/minimum.rb,
lib/jsapi/meta/schema/validation/pattern.rb,
lib/jsapi/meta/schema/validation/max_items.rb,
lib/jsapi/meta/schema/validation/min_items.rb,
lib/jsapi/meta/schema/validation/max_length.rb,
lib/jsapi/meta/schema/validation/min_length.rb,
lib/jsapi/meta/schema/validation/multiple_of.rb
Defined Under Namespace
Modules: Conversion, Validation Classes: Array, Base, Boolean, Boundary, Delegator, Discriminator, Integer, Number, Numeric, Object, Reference, String
Class Method Summary collapse
-
.new(keywords = {}) ⇒ Object
Creates a new schema model or reference.
Class Method Details
.new(keywords = {}) ⇒ Object
Creates a new schema model or reference. The :type
keyword determines the type of the schema to be created. Possible types are:
-
"array"
-
"boolean"
-
"integer"
-
"number"
-
"object"
-
"string"
The default type is "object"
.
Raises an InvalidArgumentError if the given type is invalid.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/jsapi/meta/schema.rb', line 35 def new(keywords = {}) if keywords.key?(:ref) || keywords.key?(:schema) return Reference.new(keywords) end type = keywords[:type] case type&.to_s when 'array' Array when 'boolean' Boolean when 'integer' Integer when 'number' Number when 'object', nil Object when 'string' String else raise InvalidArgumentError.new('type', type, Base::TYPES) end.new(keywords.except(:type)) end |