Class: OasRails::Spec::Parameter

Inherits:
Object
  • Object
show all
Includes:
Hashable, Specable
Defined in:
lib/oas_rails/spec/parameter.rb

Constant Summary collapse

STYLE_DEFAULTS =
{ query: 'form', path: 'simple', header: 'simple', cookie: 'form' }.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Hashable

generate_hash, #hash_key, #hash_representation, hash_representation_recursive, #public_instance_variables

Methods included from Specable

#as_json, #to_spec

Constructor Details

#initialize(specification) ⇒ Parameter

Returns a new instance of Parameter.



12
13
14
15
16
17
18
19
20
# File 'lib/oas_rails/spec/parameter.rb', line 12

def initialize(specification)
  @specification = specification
  @name = ""
  @in = ""
  @description = ""
  @required = false
  @style = ""
  @schema = { type: 'string' }
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



9
10
11
# File 'lib/oas_rails/spec/parameter.rb', line 9

def description
  @description
end

#inObject

Returns the value of attribute in.



10
11
12
# File 'lib/oas_rails/spec/parameter.rb', line 10

def in
  @in
end

#nameObject

Returns the value of attribute name.



9
10
11
# File 'lib/oas_rails/spec/parameter.rb', line 9

def name
  @name
end

#requiredObject

Returns the value of attribute required.



9
10
11
# File 'lib/oas_rails/spec/parameter.rb', line 9

def required
  @required
end

#schemaObject

Returns the value of attribute schema.



9
10
11
# File 'lib/oas_rails/spec/parameter.rb', line 9

def schema
  @schema
end

#styleObject

Returns the value of attribute style.



9
10
11
# File 'lib/oas_rails/spec/parameter.rb', line 9

def style
  @style
end

Instance Method Details

#oas_fieldsObject



32
33
34
# File 'lib/oas_rails/spec/parameter.rb', line 32

def oas_fields
  [:name, :in, :description, :required, :schema, :style]
end

#required?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/oas_rails/spec/parameter.rb', line 28

def required?
  @in == 'path'
end