Sha256: 7073b302a39476ff5317ba0ca40a5007fa5ff40ab5beabf343f66ff73e4097cb

Contents?: true

Size: 798 Bytes

Versions: 3

Compression:

Stored size: 798 Bytes

Contents

# TODO: support examples

module OpenAPIParser::Schemas
  class Parameter < Base
    openapi_attr_values :name, :in, :description, :required, :deprecated, :style, :explode, :example

    openapi_attr_value :allow_empty_value, schema_key: :allowEmptyValue
    openapi_attr_value :allow_reserved, schema_key: :allowReserved

    # @!attribute [r] schema
    #   @return [Schema, Reference, nil]
    openapi_attr_object :schema, Schema, reference: true

    def in_query?
      self.in == "query"
    end

    def in_path?
      self.in == "path"
    end

    # @return [Object] coerced or original params
    # @param [OpenAPIParser::SchemaValidator::Options] options
    def validate_params(params, options)
      ::OpenAPIParser::SchemaValidator.validate(params, schema, options)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
openapi_parser-0.1.5 lib/openapi_parser/schemas/parameter.rb
openapi_parser-0.1.4 lib/openapi_parser/schemas/parameter.rb
openapi_parser-0.1.3 lib/openapi_parser/schemas/parameter.rb