Sha256: 72330597a363099dc0163def1cd890352a5a8a84842f801d68dc3b7b584febba

Contents?: true

Size: 559 Bytes

Versions: 4

Compression:

Stored size: 559 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/.freeze

      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

4 entries across 4 versions & 2 rubygems

Version Path
openapi3_parser-0.9.2 lib/openapi3_parser/validators/component_keys.rb
mountapi-0.11.1 vendor/bundle/ruby/2.7.0/gems/openapi3_parser-0.9.1/lib/openapi3_parser/validators/component_keys.rb
openapi3_parser-0.9.1 lib/openapi3_parser/validators/component_keys.rb
openapi3_parser-0.9.0 lib/openapi3_parser/validators/component_keys.rb