class Scorpio::OpenAPI::OperationsScope
OperationsScope
acts as an Enumerable of the Operations for an openapi_document
, and offers subscripting by operationId.
Attributes
openapi_document[R]
Public Class Methods
new(openapi_document)
click to toggle source
@param openapi_document
[Scorpio::OpenAPI::Document]
# File lib/scorpio/openapi/operations_scope.rb, line 9 def initialize(openapi_document) @openapi_document = openapi_document end
Public Instance Methods
[](operationId)
click to toggle source
@param operationId @return [Scorpio::OpenAPI::Operation] the operation with the given operationId @raise [::KeyError] if the given operationId does not exist
# File lib/scorpio/openapi/operations_scope.rb, line 29 def [](operationId) jsi_memoize(:[], operationId) do |operationId_| detect { |operation| operation.operationId == operationId_ }.tap do |op| unless op raise(::KeyError, "operationId not found: #{operationId_.inspect}") end end end end
each() { |operation| ... }
click to toggle source
@yield [Scorpio::OpenAPI::Operation]
# File lib/scorpio/openapi/operations_scope.rb, line 15 def each openapi_document.paths.each do |path, path_item| path_item.each do |http_method, operation| if operation.is_a?(Scorpio::OpenAPI::Operation) yield operation end end end end