Sha256: 2f3863d4c09432b3c6007e0920f7bd15de1a7cc2c243de5f2c61d90d37702eca

Contents?: true

Size: 800 Bytes

Versions: 8

Compression:

Stored size: 800 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

8 entries across 8 versions & 2 rubygems

Version Path
openapi3_parser-0.10.1 lib/openapi3_parser/node_factory/server_variable.rb
openapi3_parser-0.9.2 lib/openapi3_parser/node_factory/server_variable.rb
mountapi-0.11.1 vendor/bundle/ruby/2.7.0/gems/openapi3_parser-0.9.1/lib/openapi3_parser/node_factory/server_variable.rb
openapi3_parser-0.9.1 lib/openapi3_parser/node_factory/server_variable.rb
openapi3_parser-0.9.0 lib/openapi3_parser/node_factory/server_variable.rb
openapi3_parser-0.8.2 lib/openapi3_parser/node_factory/server_variable.rb
openapi3_parser-0.8.1 lib/openapi3_parser/node_factory/server_variable.rb
openapi3_parser-0.8.0 lib/openapi3_parser/node_factory/server_variable.rb