Class: DynApiGen::Parameter

Inherits:
Object
  • Object
show all
Defined in:
lib/dyn_api_gen/parameter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(openapi_definition) ⇒ Parameter

Returns a new instance of Parameter.



7
8
9
10
# File 'lib/dyn_api_gen/parameter.rb', line 7

def initialize(openapi_definition)
  @name, @in, @required = openapi_definition.fetch_values('name', 'in', 'required')
  @default = openapi_definition['default']
end

Instance Attribute Details

#defaultObject (readonly)

Returns the value of attribute default.



5
6
7
# File 'lib/dyn_api_gen/parameter.rb', line 5

def default
  @default
end

#inObject (readonly)

Returns the value of attribute in.



5
6
7
# File 'lib/dyn_api_gen/parameter.rb', line 5

def in
  @in
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/dyn_api_gen/parameter.rb', line 5

def name
  @name
end

#requiredObject (readonly)

Returns the value of attribute required.



5
6
7
# File 'lib/dyn_api_gen/parameter.rb', line 5

def required
  @required
end

Instance Method Details

#header?Boolean

Returns:

  • (Boolean)


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

def header?
  @in == 'header'
end

#to_method_nameObject



16
17
18
# File 'lib/dyn_api_gen/parameter.rb', line 16

def to_method_name
  @name.gsub(/(\[|\])/, '[' => '_', ']' => '').downcase
end