Sha256: e195d83d9c8966d2e9f8fd1501ec25f83494af0b6957ed27e67ea984c1e31db2

Contents?: true

Size: 799 Bytes

Versions: 4

Compression:

Stored size: 799 Bytes

Contents

# frozen_string_literal: true

require "openapi3_parser/node_factory/object"

module Openapi3Parser
  module NodeFactory
    class ServerVariable < NodeFactory::Object
      allow_extensions
      field "enum", factory: :enum_factory
      field "default", input_type: String, required: true
      field "description", input_type: String

      private

      def enum_factory(context)
        NodeFactory::Array.new(
          context,
          default: nil,
          value_input_type: String,
          validate: lambda do |validatable|
            return if validatable.input.any?
            validatable.add_error("Expected atleast one value")
          end
        )
      end

      def build_object(data, context)
        Node::ServerVariable.new(data, context)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
openapi3_parser-0.7.0 lib/openapi3_parser/node_factory/server_variable.rb
openapi3_parser-0.6.1 lib/openapi3_parser/node_factory/server_variable.rb
openapi3_parser-0.6.0 lib/openapi3_parser/node_factory/server_variable.rb
openapi3_parser-0.5.2 lib/openapi3_parser/node_factory/server_variable.rb