Class: Gitlab::GrapeOpenapi::Models::Parameter
- Inherits:
-
Object
- Object
- Gitlab::GrapeOpenapi::Models::Parameter
- Defined in:
- lib/gitlab/grape_openapi/models/parameter.rb
Instance Attribute Summary collapse
- #description ⇒ Object readonly
- #example ⇒ Object readonly
-
#explode ⇒ Object
Returns the value of attribute explode.
- #in_value ⇒ Object readonly
- #name ⇒ Object readonly
- #options ⇒ Object readonly
- #required ⇒ Object readonly
- #schema ⇒ Object readonly
-
#style ⇒ Object
Returns the value of attribute style.
Instance Method Summary collapse
-
#initialize(name, options:, schema:, in_value:) ⇒ Parameter
constructor
A new instance of Parameter.
- #to_h ⇒ Object
Constructor Details
#initialize(name, options:, schema:, in_value:) ⇒ Parameter
Returns a new instance of Parameter.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/gitlab/grape_openapi/models/parameter.rb', line 11 def initialize(name, options:, schema:, in_value:) @options = @name = name # From https://spec.openapis.org/oas/v3.2.0.html#common-fixed-fields: "If the parameter # location is 'path', this property is REQUIRED and its value MUST be true. @required = in_value == 'path' ? true : [:required] @description = [:desc] @schema = schema @in_value = in_value @example = .dig(:documentation, :example) @default = .dig(:documentation, :default) @style = nil @explode = nil end |
Instance Attribute Details
#description ⇒ Object (readonly)
8 9 10 |
# File 'lib/gitlab/grape_openapi/models/parameter.rb', line 8 def description @description end |
#example ⇒ Object (readonly)
8 9 10 |
# File 'lib/gitlab/grape_openapi/models/parameter.rb', line 8 def example @example end |
#explode ⇒ Object
Returns the value of attribute explode.
9 10 11 |
# File 'lib/gitlab/grape_openapi/models/parameter.rb', line 9 def explode @explode end |
#in_value ⇒ Object (readonly)
8 9 10 |
# File 'lib/gitlab/grape_openapi/models/parameter.rb', line 8 def in_value @in_value end |
#name ⇒ Object (readonly)
8 9 10 |
# File 'lib/gitlab/grape_openapi/models/parameter.rb', line 8 def name @name end |
#options ⇒ Object (readonly)
8 9 10 |
# File 'lib/gitlab/grape_openapi/models/parameter.rb', line 8 def @options end |
#required ⇒ Object (readonly)
8 9 10 |
# File 'lib/gitlab/grape_openapi/models/parameter.rb', line 8 def required @required end |
#schema ⇒ Object (readonly)
8 9 10 |
# File 'lib/gitlab/grape_openapi/models/parameter.rb', line 8 def schema @schema end |
#style ⇒ Object
Returns the value of attribute style.
9 10 11 |
# File 'lib/gitlab/grape_openapi/models/parameter.rb', line 9 def style @style end |
Instance Method Details
#to_h ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/gitlab/grape_openapi/models/parameter.rb', line 26 def to_h result = { name: name, required: required, description: description, schema: schema, in: in_value, example: example } result[:style] = style if style result[:explode] = explode unless explode.nil? result.compact end |