Sha256: 0e3e5204e06f567ac273f045cb3a60c6a5187d512bbe3a249474db9b7733f775

Contents?: true

Size: 553 Bytes

Versions: 7

Compression:

Stored size: 553 Bytes

Contents

# frozen_string_literal: true

module Openapi3Parser
  module Validators
    # This validates that the keys of an object match the format of those
    # defined for a Components node.
    # As defined: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#components-object
    class ComponentKeys
      REGEX = /\A[a-zA-Z0-9\.\-_]+\Z/

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
openapi3_parser-0.7.0 lib/openapi3_parser/validators/component_keys.rb
openapi3_parser-0.6.1 lib/openapi3_parser/validators/component_keys.rb
openapi3_parser-0.6.0 lib/openapi3_parser/validators/component_keys.rb
openapi3_parser-0.5.2 lib/openapi3_parser/validators/component_keys.rb
openapi3_parser-0.5.1 lib/openapi3_parser/validators/component_keys.rb
openapi3_parser-0.5.0 lib/openapi3_parser/validators/component_keys.rb
openapi3_parser-0.4.0 lib/openapi3_parser/validators/component_keys.rb