Module: Scorpio::OpenAPI::V2::Operation
- Includes:
- Operation, Configurables
- Defined in:
- lib/scorpio/openapi.rb,
lib/scorpio/openapi/operation.rb
Defined Under Namespace
Modules: Configurables
Instance Attribute Summary
Attributes included from Configurables
Attributes included from Operation::Configurables
#base_url, #faraday_adapter, #faraday_builder, #logger, #request_headers, #user_agent
Instance Method Summary collapse
-
#body_parameter ⇒ #to_hash
The body parameter.
-
#request_schema(media_type: nil) ⇒ JSI::Schema
Request schema for the given media_type.
- #request_schemas ⇒ Array<JSI::Schema>
- #response_schema(status:, media_type: nil) ⇒ JSI::Schema
Methods included from Configurables
Methods included from Operation
#build_request, #http_method, #human_id, #inferred_parameters, #oa_response, #openapi_document, #path_template, #path_template_str, #request_accessor_module, #run, #run_ur, #uri_template, #v2?, #v3?
Instance Method Details
#body_parameter ⇒ #to_hash
Returns the body parameter.
269 270 271 272 273 274 275 276 277 278 279 |
# File 'lib/scorpio/openapi/operation.rb', line 269 def body_parameter body_parameters = (parameters || []).select { |parameter| parameter['in'] == 'body' } if body_parameters.size == 0 nil elsif body_parameters.size == 1 body_parameters.first else # TODO blame raise(OpenAPI::SemanticError, "multiple body parameters on operation #{operation.pretty_inspect.chomp}") end end |
#request_schema(media_type: nil) ⇒ JSI::Schema
Returns request schema for the given media_type.
283 284 285 286 287 288 289 |
# File 'lib/scorpio/openapi/operation.rb', line 283 def request_schema(media_type: nil) if body_parameter && body_parameter['schema'] JSI::Schema.new(body_parameter['schema']) else nil end end |
#request_schemas ⇒ Array<JSI::Schema>
292 293 294 |
# File 'lib/scorpio/openapi/operation.rb', line 292 def request_schemas request_schema ? [request_schema] : [] end |
#response_schema(status:, media_type: nil) ⇒ JSI::Schema
299 300 301 302 303 |
# File 'lib/scorpio/openapi/operation.rb', line 299 def response_schema(status: , media_type: nil) oa_response = self.oa_response(status: status) oa_response_schema = oa_response ? oa_response['schema'] : nil # Scorpio::OpenAPI::V2::Schema oa_response_schema ? JSI::Schema.new(oa_response_schema) : nil end |