Module: Scorpio::OpenAPI::Operation::V2Methods

Includes:
Scorpio::OpenAPI::Operation, Configurables
Included in:
V2::Operation
Defined in:
lib/scorpio/openapi/operation.rb

Defined Under Namespace

Modules: Configurables

Instance Attribute Summary

Attributes included from Configurables

#accept, #authorization, #base_url, #faraday_adapter, #faraday_builder, #logger, #request_headers, #user_agent

Attributes included from Configurables

#request_media_type, #scheme

Instance Method Summary collapse

Methods included from Scorpio::OpenAPI::Operation

#build_request, #delete?, #each_link_page, #get?, #head?, #http_method, #human_id, #inferred_parameters, #inherited_parameters, #oa_response, #options?, #patch?, #path_template, #path_template_str, #post?, #put?, #run, #run_ur, #tagged?, #trace?, #uri_template, #v2?, #v3?

Methods included from Document::Descendent

#openapi_document

Methods included from Configurables

#server, #server_variables

Instance Method Details

#body_parameter#to_hash

the body parameter

Returns:

  • (#to_hash)

Raises:



370
371
372
373
374
375
376
377
378
379
380
# File 'lib/scorpio/openapi/operation.rb', line 370

def body_parameter
  body_parameters = inherited_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

request schema for the given media_type

Parameters:

  • media_type (defaults to: nil)

    unused

Returns:

  • (JSI::Schema)


385
386
387
388
389
390
391
# File 'lib/scorpio/openapi/operation.rb', line 385

def request_schema(media_type: nil)
  if body_parameter && body_parameter['schema']
    JSI::Schema.ensure_schema(body_parameter['schema'])
  else
    nil
  end
end

#request_schemasJSI::SchemaSet

Returns:

  • (JSI::SchemaSet)


394
395
396
# File 'lib/scorpio/openapi/operation.rb', line 394

def request_schemas
  request_schema ? JSI::SchemaSet[request_schema] : JSI::SchemaSet[]
end

#response_schema(status:, media_type: nil) ⇒ JSI::Schema

Parameters:

  • status (Integer, String)

    response status

  • media_type (defaults to: nil)

    unused

Returns:

  • (JSI::Schema)


401
402
403
404
405
# File 'lib/scorpio/openapi/operation.rb', line 401

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.ensure_schema(oa_response_schema) : nil
end

#response_schemasJSI::SchemaSet

Returns:

  • (JSI::SchemaSet)


408
409
410
411
412
413
414
415
416
417
418
# File 'lib/scorpio/openapi/operation.rb', line 408

def response_schemas
  JSI::SchemaSet.build do |schemas|
    if responses
      responses.each_value do |oa_response|
        if oa_response['schema']
          schemas << oa_response['schema']
        end
      end
    end
  end
end