Sha256: 090b03fb656fb666c7de30bd8f5e01e0124186c3dba7e135f119f1cd11218f46
Contents?: true
Size: 1.08 KB
Versions: 1
Compression:
Stored size: 1.08 KB
Contents
# frozen_string_literal: true require "openapi3_parser/node_factory/map" module Openapi3Parser module NodeFactory class Responses < NodeFactory::Map KEY_REGEX = / \A ( default | [1-5]([0-9][0-9]|XX) ) \Z /x def initialize(context) factory = NodeFactory::OptionalReference.new(NodeFactory::Response) super(context, allow_extensions: true, value_factory: factory, validate: :validate_keys) end private def build_node(data) Node::Responses.new(data, context) end def validate_keys(validatable) invalid = validatable.input.keys.reject do |key| NodeFactory::EXTENSION_REGEX.match(key) || KEY_REGEX.match(key) end return if invalid.empty? codes = invalid.map { |k| "'#{k}'" }.join(", ") validatable.add_error("Invalid responses keys: #{codes} - default, "\ "status codes and status code ranges allowed") end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
openapi3_parser-0.5.2 | lib/openapi3_parser/node_factory/responses.rb |