Class: Docit::Builders::ParameterBuilder
- Inherits:
-
Object
- Object
- Docit::Builders::ParameterBuilder
- Defined in:
- lib/docit/builders/parameter_builder.rb
Overview
Collects query, path, and header parameters for an operation.
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
- #add(name, location:, type: :string, required: false, description: nil, example: nil, enum: nil, **opts) ⇒ Object
-
#initialize ⇒ ParameterBuilder
constructor
A new instance of ParameterBuilder.
Constructor Details
#initialize ⇒ ParameterBuilder
Returns a new instance of ParameterBuilder.
9 10 11 |
# File 'lib/docit/builders/parameter_builder.rb', line 9 def initialize @params = [] end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
7 8 9 |
# File 'lib/docit/builders/parameter_builder.rb', line 7 def params @params end |
Instance Method Details
#add(name, location:, type: :string, required: false, description: nil, example: nil, enum: nil, **opts) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/docit/builders/parameter_builder.rb', line 13 def add(name, location:, type: :string, required: false, description: nil, example: nil, enum: nil, **opts) param = { name: name.to_s, in: location.to_s, required: required, schema: { type: type.to_s } } param[:description] = description if description param[:schema][:enum] = enum if enum param[:schema][:example] = example if example param[:schema].merge!(opts) @params << param end |