Sha256: e1f609c2d4efe376c4c37a8981fbbecb9ade66f0acfef2fa01cf2efab74ef9f2

Contents?: true

Size: 1015 Bytes

Versions: 4

Compression:

Stored size: 1015 Bytes

Contents

# frozen_string_literal: true

module Openapi3Parser
  module NodeFactory
    module ParameterLike
      def default_explode
        context.input["style"] == "form"
      end

      def schema_factory(context)
        factory = NodeFactory::OptionalReference.new(NodeFactory::Schema)
        factory.call(context)
      end

      def examples_factory(context)
        factory = NodeFactory::OptionalReference.new(NodeFactory::Example)
        NodeFactory::Map.new(context,
                             default: nil,
                             value_factory: factory)
      end

      def content_factory(context)
        NodeFactory::Map.new(context,
                             default: nil,
                             value_factory: NodeFactory::MediaType,
                             validate: method(:validate_content))
      end

      def validate_content(validatable)
        return if validatable.input.size == 1

        validatable.add_error("Must only have one item")
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

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