Class: Apipie::Params::Descriptor::JsonSchema
- Inherits:
-
Base
- Object
- Base
- Apipie::Params::Descriptor::JsonSchema
show all
- Defined in:
- lib/apipie/params/descriptor.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#description, find, #initialize, #invalid_param_error, #to_json
Class Method Details
.build(*args) ⇒ Object
63
64
65
66
|
# File 'lib/apipie/params/descriptor.rb', line 63
def self.build(*args)
nil
end
|
.inherited(subclass) ⇒ Object
59
60
61
|
# File 'lib/apipie/params/descriptor.rb', line 59
def self.inherited(subclass)
Base.inherited(subclass)
end
|
Instance Method Details
#json_schema ⇒ Object
68
69
70
|
# File 'lib/apipie/params/descriptor.rb', line 68
def json_schema
{'description' => description}
end
|
#validate!(param_description, value) ⇒ Object
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/apipie/params/descriptor.rb', line 73
def validate!(param_description, value)
encapsulated_value = {'root' => value}
encapsulated_schema = {
'type' => 'object',
'properties' => {'root' => json_schema}
}
require 'json-schema'
errors = JSON::Validator.fully_validate(encapsulated_schema,
encapsulated_value.with_indifferent_access,
:errors_as_objects => true)
if errors.any?
raise invalid_param_error(param_description, value, errors)
else
return true
end
end
|