Module: Jimmy::Macros

Includes:
Declaration
Included in:
Jimmy, Loaders::Ruby
Defined in:
lib/jimmy/macros.rb

Overview

The Macros module includes methods that can be called directly on the Jimmy module for quickly making common types of schemas.

Constant Summary

Constants included from Declaration

Declaration::BOOLEANS, Declaration::FORMATS, Declaration::SIMPLE_TYPES

Instance Method Summary collapse

Methods included from Declaration

#all_of, #any_of, #array, #boolean, #const, #date, #date_time, #default, #define, #definitions, #description, #email, #enum, #examples, #hostname, #idn_email, #idn_hostname, #if, #integer, #ipv4, #ipv6, #iri, #iri_reference, #json_pointer, #multiple_of, #not, #null, #number, #object, #one_of, #pattern, #range, #read_only, #regex, #relative_json_pointer, #string, #struct, #time, #title, #type, #uri, #uri_reference, #uri_template, #write_only

Instance Method Details

#nothingSchema

Make a schema that never validates.

Returns:

  • (Schema)

    The new schema.



20
21
22
# File 'lib/jimmy/macros.rb', line 20

def nothing
  schema.nothing
end

#ref(uri) ⇒ Schema

Make a schema that references another schema by URI.

Parameters:

Returns:

  • (Schema)

    The new schema.



27
28
29
# File 'lib/jimmy/macros.rb', line 27

def ref(uri)
  schema.ref uri
end

#schema {|schema| ... } ⇒ Schema

Make a new schema. Shortcut for Schema.new.

Yield Parameters:

  • schema (Schema)

    The new schema

Returns:

  • (Schema)

    The new schema.



14
15
16
# File 'lib/jimmy/macros.rb', line 14

def schema(&block)
  Schema.new &block
end