Class: OasRails::Builders::ParametersBuilder
- Inherits:
-
Object
- Object
- OasRails::Builders::ParametersBuilder
- Defined in:
- lib/oas_rails/builders/parameters_builder.rb
Instance Method Summary collapse
- #build ⇒ Object
- #from_oas_route(oas_route) ⇒ Object
-
#initialize(specification) ⇒ ParametersBuilder
constructor
A new instance of ParametersBuilder.
- #parameters_from_tags(tags:) ⇒ Object
Constructor Details
#initialize(specification) ⇒ ParametersBuilder
Returns a new instance of ParametersBuilder.
4 5 6 7 |
# File 'lib/oas_rails/builders/parameters_builder.rb', line 4 def initialize(specification) @specification = specification @parameters = [] end |
Instance Method Details
#build ⇒ Object
32 33 34 35 36 |
# File 'lib/oas_rails/builders/parameters_builder.rb', line 32 def build @parameters.map do |p| @specification.components.add_parameter(p) end end |
#from_oas_route(oas_route) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/oas_rails/builders/parameters_builder.rb', line 9 def from_oas_route(oas_route) (tags: oas_route.docstring.(:parameter)) oas_route.path_params.try(:map) do |p| @parameters << ParameterBuilder.new(@specification).from_path(oas_route.path, p).build unless @parameters.any? { |param| param.name.to_s == p.to_s } end self end |
#parameters_from_tags(tags:) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/oas_rails/builders/parameters_builder.rb', line 18 def (tags:) .each do |t| parameter = Spec::Parameter.new(@specification) parameter.name = t.name parameter.in = t.location parameter.required = t.required parameter.schema = t.schema parameter.description = t.text @parameters << parameter end self end |