Sha256: 70d115e8fdf7b2904edc5524603fe4d33e9b01b0d975b888f953747d39feaad7
Contents?: true
Size: 1.38 KB
Versions: 10
Compression:
Stored size: 1.38 KB
Contents
module Fakeit module Openapi class Operation def initialize(request_operation, app_options) @request_operation = request_operation @validator = Fakeit::Validation::Validator.new(request_operation) @app_options = app_options end def status response.first.to_i end def headers response_headers .to_h .transform_values { _1.schema.to_example(example_options) } .tap { _1['Content-Type'] = response_content_type if response_content_type } end def body response_schema &.schema &.to_example(example_options) &.then(&JSON.method(:generate)) .to_s end def validate(**request_parts) @validator.validate(**request_parts) end private def example_options { use_example: @app_options.use_example, use_static: @app_options.method(:use_static?), depth: 0 } end 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
10 entries across 10 versions & 1 rubygems