module Scorpio::OpenAPI::V2::Operation

Public Instance Methods

body_parameter() click to toggle source

@return [#to_hash] the body parameter @raise [Scorpio::OpenAPI::SemanticError] if there's more than one body param

# 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) click to toggle source

@param media_type unused @return [JSI::Schema] request schema for the given media_type

# 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() click to toggle source

@return [Array<JSI::Schema>]

# File lib/scorpio/openapi/operation.rb, line 292
def request_schemas
  request_schema ? [request_schema] : []
end
response_schema(status: , media_type: nil) click to toggle source

@param status [Integer, String] response status @param media_type unused @return [JSI::Schema]

# 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