Sha256: 532bfc7429db7e41d1b96fc8d69334d06c1f3170e8a701c3cdf95304c7c65b69
Contents?: true
Size: 1.02 KB
Versions: 15
Compression:
Stored size: 1.02 KB
Contents
module OasRails module Builders class ParametersBuilder def initialize(specification) @specification = specification @parameters = [] end def from_oas_route(oas_route) parameters_from_tags(tags: oas_route.docstring.tags(: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 def parameters_from_tags(tags:) 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 def build @parameters.map do |p| @specification.components.add_parameter(p) end end end end end
Version data entries
15 entries across 15 versions & 1 rubygems