class SoberSwag::Reporting::Output::Pattern
Output
with a particular pattern.
Attributes
output[R]
@return [Interface]
pattern[R]
@return [Regexp]
Public Class Methods
new(output, pattern)
click to toggle source
# File lib/sober_swag/reporting/output/pattern.rb, line 7 def initialize(output, pattern) @output = output @pattern = pattern end
Public Instance Methods
call(input)
click to toggle source
# File lib/sober_swag/reporting/output/pattern.rb, line 20 def call(input) output.call(input) end
serialize_report(value)
click to toggle source
# File lib/sober_swag/reporting/output/pattern.rb, line 24 def serialize_report(value) base = output.serialize_report(value) return base if base.is_a?(Report::Error) if pattern.match?(base) base else Report::Value.new(['did not match pattern']) end end
swagger_schema()
click to toggle source
# File lib/sober_swag/reporting/output/pattern.rb, line 36 def swagger_schema schema, defs = output.swagger_schema merged = if schema.key?(:$ref) { oneOf: [schema] } else schema end.merge(pattern: pattern.to_s.gsub('?-mix:', '')) [merged, defs] end