Class: OpenapiFirst::Definition

Inherits:
Object
  • Object
show all
Defined in:
lib/openapi_first/definition.rb

Overview

Represents an OpenAPI API Description document

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resolved, filepath) ⇒ Definition

Returns a new instance of Definition.



10
11
12
13
14
15
16
17
18
# File 'lib/openapi_first/definition.rb', line 10

def initialize(resolved, filepath)
  @filepath = filepath
  methods = %w[get head post put patch delete trace options]
  @operations = resolved['paths'].flat_map do |path, path_item|
    path_item.slice(*methods).map do |request_method, _operation_object|
      Operation.new(path, request_method, path_item, openapi_version: detect_version(resolved))
    end
  end
end

Instance Attribute Details

#filepathObject (readonly)

Returns the value of attribute filepath.



8
9
10
# File 'lib/openapi_first/definition.rb', line 8

def filepath
  @filepath
end

#operationsObject (readonly)

Returns the value of attribute operations.



8
9
10
# File 'lib/openapi_first/definition.rb', line 8

def operations
  @operations
end