Sha256: 3dd41135b4c6ce663faa54ff1d67987771234b3df7ac96c74ef9ad84cafc43a7

Contents?: true

Size: 1.14 KB

Versions: 3

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true
module JSONSchemer
  module OpenAPI30
    BASE_URI = URI('json-schemer://openapi30/schema')
    # https://spec.openapis.org/oas/v3.0.3#data-types
    FORMATS = OpenAPI31::FORMATS.merge(
      'byte' => proc { |instance, _value| ContentEncoding::BASE64.call(instance).first },
      'binary' => proc { |instance, _value| instance.is_a?(String) && instance.encoding == Encoding::BINARY },
      'date' => Format::DATE
    )
    SCHEMA = {
      'id' => 'json-schemer://openapi30/schema',
      '$schema' => 'http://json-schema.org/draft-04/schema#',
      'allOf' => [
        { '$ref' => 'http://json-schema.org/draft-04/schema#' },
        {
          'oneOf' => [
            { '$ref' => 'https://spec.openapis.org/oas/3.0/schema/2021-09-28#/definitions/Schema' },
            { '$ref' => 'https://spec.openapis.org/oas/3.0/schema/2021-09-28#/definitions/Reference' }
          ]
        }
      ]
    }

    module Meta
      SCHEMAS = {
        Draft4::BASE_URI.dup.tap { |uri| uri.fragment = nil } => Draft4::SCHEMA,
        URI('https://spec.openapis.org/oas/3.0/schema/2021-09-28') => Document::SCHEMA
      }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
json_schemer-2.3.0 lib/json_schemer/openapi30/meta.rb
json_schemer-2.2.1 lib/json_schemer/openapi30/meta.rb
json_schemer-2.2.0 lib/json_schemer/openapi30/meta.rb