Sha256: 4357a0eb092a5bf98ce7ed45b6d5970ed519249b3580d4b2fe9f5c6d8102362c
Contents?: true
Size: 1.52 KB
Versions: 3
Compression:
Stored size: 1.52 KB
Contents
# frozen_string_literal: true require 'yori/schema/v3/schema' require 'yori/schema/v3/example' require 'yori/schema/v3/media_type' module Yori module Schema module V3 # Parameter: Describes a single operation parameter. class Parameter < Yori::SchemaBase fields :name, :description, :required, :deprecated, :allowEmptyValue def in_query self['in'] = 'query' end def in_header self['in'] = 'header' end def in_path self['in'] = 'path' end def in_cookie self['in'] = 'cookie' end fields :style, :explode, :allowReserved field_block :schema, Yori::Schema::V3::Schema def example_any(value) self['example'] = value end hash_field_block :examples, :example, Yori::Schema::V3::Example hash_field_block :content, :content_type, Yori::Schema::V3::MediaType def validate! validate_require_fields!('name', 'in') validate_in! validate_schema_or_content! end def validate_in! validate_limit_field_values!('in', 'query', 'header', 'path', 'cookie') in_value = self['in'] case in_value when 'path' validate_require_fields!('required') validate_limit_field_values!('required', true) end end def validate_schema_or_content! validate_mutually_exclusive_fields!('schema', 'content') 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/parameter.rb |
yori-0.1.1 | lib/yori/schema/v3/parameter.rb |
yori-0.1.0 | lib/yori/schema/v3/parameter.rb |