Sha256: 28a8323fbb479aea2ee81a8f67b833feb0059d5c0b7879917fd20c3d05d6b524
Contents?: true
Size: 1.11 KB
Versions: 1
Compression:
Stored size: 1.11 KB
Contents
module Fakeit module Openapi class Operation def initialize(request_operation) @request_operation = request_operation @validator = Fakeit::Validation::Validator.new(request_operation) end def status openapi_response.first.to_i end def headers openapi_headers &.map { |k, v| [k, v.schema.to_example] } &.push(['Content-Type', openapi_content_type]) .to_h end def body openapi_schema&.schema&.to_example&.then(&JSON.method(:generate)).to_s end def validate(**request_parts) @validator.validate(request_parts) end private def openapi_content openapi_response.last.content&.find { |k, _| k =~ %r{^application/.*json} } end def openapi_schema openapi_content&.last end def openapi_content_type openapi_content&.first end def openapi_headers openapi_response.last.headers end def openapi_response @request_operation.operation_object.responses.response.min end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fakeit-0.1.1 | lib/fakeit/openapi/operation.rb |