Class: Fakeit::Openapi::Operation
- Inherits:
-
Object
- Object
- Fakeit::Openapi::Operation
- Defined in:
- lib/fakeit/openapi/operation.rb
Instance Method Summary collapse
- #body ⇒ Object
- #headers ⇒ Object
-
#initialize(request_operation, app_options) ⇒ Operation
constructor
A new instance of Operation.
- #status ⇒ Object
- #validate(**request_parts) ⇒ Object
Constructor Details
#initialize(request_operation, app_options) ⇒ Operation
Returns a new instance of Operation.
4 5 6 7 8 |
# File 'lib/fakeit/openapi/operation.rb', line 4 def initialize(request_operation, ) @request_operation = request_operation @validator = Fakeit::Validation::Validator.new(request_operation) @app_options = end |
Instance Method Details
#body ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/fakeit/openapi/operation.rb', line 21 def body response_schema &.schema &.to_example() &.then(&JSON.method(:generate)) .to_s end |
#headers ⇒ Object
14 15 16 17 18 19 |
# File 'lib/fakeit/openapi/operation.rb', line 14 def headers response_headers .to_h .transform_values { _1.schema.to_example() } .tap { _1['Content-Type'] = response_content_type if response_content_type } end |
#status ⇒ Object
10 11 12 |
# File 'lib/fakeit/openapi/operation.rb', line 10 def status response.first.to_i end |
#validate(**request_parts) ⇒ Object
29 30 31 |
# File 'lib/fakeit/openapi/operation.rb', line 29 def validate(**request_parts) @validator.validate(**request_parts) end |