Class: JSON::Oas::Validator
- Inherits:
-
Validator
- Object
- Validator
- JSON::Oas::Validator
- Defined in:
- lib/json-schema-oas/validator.rb
Overview
Validator to validate data against a OpenAPI schema
Class Method Summary collapse
Class Method Details
.compute_fragment(version, opts) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/json-schema-oas/validator.rb', line 23 def compute_fragment(version, opts) = Hash(opts) return if [:fragment] if [:with_schema] [:fragment] = Fragment.schema_for(version, [:with_schema].to_s) elsif [:with_response] [:fragment] = Fragment.response_schema_for(version, *Array([:with_response])) end end |
.valid_schema?(schema, version) ⇒ Boolean
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/json-schema-oas/validator.rb', line 11 def valid_schema?(schema, version) specs = case version when Version::OAS2 OAS2_SCHEMA_PATH when Version::OAS3 OAS3_SCHEMA_PATH else raise Error, Error::UNKNOWN_VERSION_ERROR end JSON::Validator.fully_validate(specs, schema).empty? end |