Sha256: 935268a513fd06e37bed9578354590df306d10ce2cd6a890f79856841ee8b7b2
Contents?: true
Size: 1.25 KB
Versions: 2
Compression:
Stored size: 1.25 KB
Contents
module Fakeit module Openapi class Operation def initialize(request_operation, options) @request_operation = request_operation @validator = Fakeit::Validation::Validator.new(request_operation) @options = options end def status response.first.to_i end def headers response_headers &.map { |k, v| [k, v.schema.to_example(@options.use_example)] } &.tap { |headers| headers.push(['Content-Type', response_content_type]) if response_content_type } .to_h end def body response_schema &.schema &.to_example(@options.use_example) &.then(&JSON.method(:generate)) .to_s end def validate(**request_parts) @validator.validate(request_parts) end private def response_content response.last.content&.find { |k, _| k =~ %r{^application/.*json} } end def response_schema response_content&.last end def response_content_type response_content&.first end def response_headers response.last.headers end def response @request_operation.operation_object.responses.response.min end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fakeit-0.1.3 | lib/fakeit/openapi/operation.rb |
fakeit-0.1.2 | lib/fakeit/openapi/operation.rb |