Class: OpenapiFirst::Definition

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resolved, filepath) ⇒ Definition

Returns a new instance of Definition.



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

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)
    end
  end
end

Instance Attribute Details

#filepathObject (readonly)

Returns the value of attribute filepath.



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

def filepath
  @filepath
end

#operationsObject (readonly)

Returns the value of attribute operations.



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

def operations
  @operations
end