Class: Apivore::CustomSchemaValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/apivore/custom_schema_validator.rb

Constant Summary collapse

WF_SCHEMA =

This constant is an example custom schema included with the gem

File.expand_path("../../data/custom_schemata/westfield_api_standards.json", File.dirname(__FILE__))

Instance Method Summary collapse

Constructor Details

#initialize(custom_schema) ⇒ CustomSchemaValidator


6
7
8
# File 'lib/apivore/custom_schema_validator.rb', line 6

def initialize(custom_schema)
  @schema = custom_schema
end

Instance Method Details

#descriptionObject


15
16
17
# File 'lib/apivore/custom_schema_validator.rb', line 15

def description
  "additionally conforms to #{@schema}"
end

#failure_messageObject


19
20
21
# File 'lib/apivore/custom_schema_validator.rb', line 19

def failure_message
  @results.join("\n")
end

#matches?(swagger_checker) ⇒ Boolean


10
11
12
13
# File 'lib/apivore/custom_schema_validator.rb', line 10

def matches?(swagger_checker)
  @results = JSON::Validator.fully_validate(@schema, swagger_checker.swagger)
  @results.empty?
end