Class: Committee::Drivers::HyperSchema::Driver
- Defined in:
- lib/committee/drivers/hyper_schema/driver.rb
Instance Method Summary collapse
- #default_allow_get_body ⇒ Object
- #default_coerce_date_times ⇒ Object
-
#default_coerce_form_params ⇒ Object
Whether parameters that were form-encoded will be coerced by default.
-
#default_path_params ⇒ Object
Whether parameters in a request’s path will be considered and coerced by default.
-
#default_query_params ⇒ Object
Whether parameters in a request’s query string will be considered and coerced by default.
- #default_validate_success_only ⇒ Object
- #name ⇒ Object
-
#parse(schema) ⇒ Object
Parses an API schema and builds a set of route definitions for use with Committee.
- #schema_class ⇒ Object
Instance Method Details
#default_allow_get_body ⇒ Object
16 17 18 |
# File 'lib/committee/drivers/hyper_schema/driver.rb', line 16 def default_allow_get_body true end |
#default_coerce_date_times ⇒ Object
7 8 9 |
# File 'lib/committee/drivers/hyper_schema/driver.rb', line 7 def default_coerce_date_times false end |
#default_coerce_form_params ⇒ Object
Whether parameters that were form-encoded will be coerced by default.
12 13 14 |
# File 'lib/committee/drivers/hyper_schema/driver.rb', line 12 def default_coerce_form_params false end |
#default_path_params ⇒ Object
Whether parameters in a request’s path will be considered and coerced by default.
22 23 24 |
# File 'lib/committee/drivers/hyper_schema/driver.rb', line 22 def default_path_params false end |
#default_query_params ⇒ Object
Whether parameters in a request’s query string will be considered and coerced by default.
28 29 30 |
# File 'lib/committee/drivers/hyper_schema/driver.rb', line 28 def default_query_params false end |
#default_validate_success_only ⇒ Object
32 33 34 |
# File 'lib/committee/drivers/hyper_schema/driver.rb', line 32 def default_validate_success_only true end |
#name ⇒ Object
36 37 38 |
# File 'lib/committee/drivers/hyper_schema/driver.rb', line 36 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.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/committee/drivers/hyper_schema/driver.rb', line 45 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. end schema = Schema.new schema.driver = self schema.routes = build_routes(hyper_schema) schema end |
#schema_class ⇒ Object
62 63 64 |
# File 'lib/committee/drivers/hyper_schema/driver.rb', line 62 def schema_class Committee::Drivers::HyperSchema::Schema end |