Class: Eazypi::Parameter

Inherits:
Object
  • Object
show all
Includes:
SpecObject
Defined in:
lib/eazypi/parameter.rb

Overview

OpenAPI spec ParameterObject

Instance Method Summary collapse

Methods included from SpecObject

included, #load

Constructor Details

#initialize(name:, location:, &block) ⇒ Parameter

Returns a new instance of Parameter.



18
19
20
21
22
23
# File 'lib/eazypi/parameter.rb', line 18

def initialize(name:, location:, &block)
  @name = name
  @location = location

  super(&block)
end

Instance Method Details

#to_openapi_specObject



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/eazypi/parameter.rb', line 25

def to_openapi_spec
  {
    "name" => name.to_s,
    "in" => location, # using location as in is a ruby keywork
    "description" => description,
    "required" => location == "path" ? true : required,
    "deprecated" => depcrecated,
    "allowEmptyValue" => allow_empty_value,
    "schema" => schema ? Schema.from_object(schema).to_openapi_spec : nil
  }.compact
end