Sha256: 2f25e4cdb0846a37fb601c3ce79c71812a1960111ad07fc0d35b22d771b47e5e

Contents?: true

Size: 1.07 KB

Versions: 11

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

require 'oas_objs/helpers'
require 'oas_objs/schema_obj'

module OpenApi
  module DSL
    class ParamObj < Hash
      include Helpers

      attr_accessor :processed, :schema

      def initialize(name, param_type, type, required, schema)
        self.processed = {
            name: name.to_s.delete('!').to_sym,
            in: param_type.to_s.delete('!'),
            required: required.to_s[/req/].present?
        }
        merge!(self.schema = schema)
      end

      def process
        processed[:schema] = schema.process
        desc = schema.processed[:description]
        processed[:description] = desc if desc
        processed
      end

      def name
        processed[:name]
      end
    end
  end
end


__END__

Parameter Object Examples
A header parameter with an array of 64 bit integer numbers:

{
  "name": "token",
  "in": "header",
  "description": "token to be passed as a header",
  "required": true,
  "schema": {
    "type": "array",
    "items": {
      "type": "integer",
      "format": "int64"
    }
  },
  "style": "simple"
}

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
zero-rails_openapi-2.2.0 lib/oas_objs/param_obj.rb
zero-rails_openapi-2.1.5 lib/oas_objs/param_obj.rb
zero-rails_openapi-2.1.4 lib/oas_objs/param_obj.rb
zero-rails_openapi-2.1.3 lib/oas_objs/param_obj.rb
zero-rails_openapi-2.1.2 lib/oas_objs/param_obj.rb
zero-rails_openapi-2.1.1 lib/oas_objs/param_obj.rb
zero-rails_openapi-2.1.0 lib/oas_objs/param_obj.rb
zero-rails_openapi-2.0.3 lib/oas_objs/param_obj.rb
zero-rails_openapi-2.0.2 lib/oas_objs/param_obj.rb
zero-rails_openapi-2.0.1 lib/oas_objs/param_obj.rb
zero-rails_openapi-2.0.0 lib/oas_objs/param_obj.rb