Sha256: c2bcdc00145ae7d8637a62e9284e31e1d167b4ffa92177f3364ddc1a6dcfd694

Contents?: true

Size: 1.01 KB

Versions: 3

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

module Yori
  module Schema
    module V3
      # Discriminator
      #   When request bodies or response payloads may be one of a number of different schemas,
      #   a discriminator object can be used to aid in serialization, deserialization, and validation.
      #   The discriminator is a specific object in a schema which is used to inform the consumer of the specification of an alternative schema based on the value associated with it.
      #   When using the discriminator, inline schemas will not be considered.
      class Discriminator < Yori::SchemaBase
        # @!method propertyName
        #   REQUIRED. The name of the property in the payload that will hold the discriminator value.
        fields :propertyName
        # @!method mapping
        #   An object to hold mappings between payload values and schema names or references.
        hash_field :mapping, :map

        def validate!
          validate_require_fields!('propertyName')
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
yori-0.1.2 lib/yori/schema/v3/discriminator.rb
yori-0.1.1 lib/yori/schema/v3/discriminator.rb
yori-0.1.0 lib/yori/schema/v3/discriminator.rb