Class: Committee::Drivers::HyperSchema

Inherits:
Driver
  • Object
show all
Defined in:
lib/committee/drivers/hyper_schema.rb

Defined Under Namespace

Classes: Link, Schema

Instance Method Summary collapse

Instance Method Details

#default_coerce_form_paramsObject

Whether parameters that were form-encoded will be coerced by default.



4
5
6
# File 'lib/committee/drivers/hyper_schema.rb', line 4

def default_coerce_form_params
  false
end

#default_path_paramsObject

Whether parameters in a request’s path will be considered and coerced by default.



10
11
12
# File 'lib/committee/drivers/hyper_schema.rb', line 10

def default_path_params
  false
end

#default_query_paramsObject

Whether parameters in a request’s query string will be considered and coerced by default.



16
17
18
# File 'lib/committee/drivers/hyper_schema.rb', line 16

def default_query_params
  false
end

#nameObject



20
21
22
# File 'lib/committee/drivers/hyper_schema.rb', line 20

def name
  :hyper_schema
end

#parse(schema) ⇒ Object

Parses an API schema and builds a set of route definitions for use with Committee.

The expected input format is a data hash with keys as strings (as opposed to symbols) like the kind produced by JSON.parse or YAML.load.



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/committee/drivers/hyper_schema.rb', line 29

def parse(schema)
  # Really we'd like to only have data hashes passed into drivers these
  # days, but here we handle a JsonSchema::Schema for now to maintain
  # backward compatibility (this library used to be hyper-schema only).
  if schema.is_a?(JsonSchema::Schema)
    hyper_schema = schema
  else
    hyper_schema = JsonSchema.parse!(schema)
    hyper_schema.expand_references!
  end

  schema = Schema.new
  schema.driver = self
  schema.routes = build_routes(hyper_schema)
  schema
end

#schema_classObject



46
47
48
# File 'lib/committee/drivers/hyper_schema.rb', line 46

def schema_class
  Committee::Drivers::HyperSchema::Schema
end