Class: Openapi3Parser::Validators::ComponentKeys

Inherits:
Object
  • Object
show all
Defined in:
lib/openapi3_parser/validators/component_keys.rb

Overview

This validates that the keys of an object match the format of those defined for a Components node. As defined: github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#components-object

Constant Summary collapse

REGEX =
/\A[a-zA-Z0-9.\-_]+\Z/

Class Method Summary collapse

Class Method Details

.call(input) ⇒ Object



11
12
13
14
# File 'lib/openapi3_parser/validators/component_keys.rb', line 11

def self.call(input)
  invalid = input.keys.reject { |key| REGEX.match(key) }
  "Contains invalid keys: #{invalid.join(', ')}" unless invalid.empty?
end