Class: OasCore::Spec::Parameter

Inherits:
Object
  • Object
show all
Includes:
Hashable, Specable
Defined in:
lib/oas_core/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.



14
15
16
17
18
19
20
21
22
# File 'lib/oas_core/spec/parameter.rb', line 14

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.



11
12
13
# File 'lib/oas_core/spec/parameter.rb', line 11

def description
  @description
end

#inObject

Returns the value of attribute in.



12
13
14
# File 'lib/oas_core/spec/parameter.rb', line 12

def in
  @in
end

#nameObject

Returns the value of attribute name.



11
12
13
# File 'lib/oas_core/spec/parameter.rb', line 11

def name
  @name
end

#requiredObject

Returns the value of attribute required.



11
12
13
# File 'lib/oas_core/spec/parameter.rb', line 11

def required
  @required
end

#schemaObject

Returns the value of attribute schema.



11
12
13
# File 'lib/oas_core/spec/parameter.rb', line 11

def schema
  @schema
end

#styleObject

Returns the value of attribute style.



11
12
13
# File 'lib/oas_core/spec/parameter.rb', line 11

def style
  @style
end

Instance Method Details

#oas_fieldsObject



34
35
36
# File 'lib/oas_core/spec/parameter.rb', line 34

def oas_fields
  %i[name in description required schema style]
end

#required?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/oas_core/spec/parameter.rb', line 30

def required?
  @in == 'path'
end