Module: OpenAPIArrangement::Schema

Defined in:
lib/openapi/arrangement/schema.rb

Overview

Schema ordering.

Defined Under Namespace

Classes: Info, Orderer

Class Method Summary collapse

Class Method Details

.alphabetical(doc, path = nil) ⇒ Object

Arranges schemas in alphabetical order.



13
14
15
16
17
18
19
# File 'lib/openapi/arrangement/schema.rb', line 13

def self.alphabetical(doc, path = nil)
  cands = path_candidates(path)
  schemas, path = get_schemas(doc, cands)
  return nil if schemas.nil?
  ord = Orderer.new(path, schemas)
  ord.sort!('@name')
end

.dependencies_first(doc, path = nil) ⇒ Object

Arranges schemas to minimize forward declarations.



22
23
24
25
26
27
28
# File 'lib/openapi/arrangement/schema.rb', line 22

def self.dependencies_first(doc, path = nil)
  cands = path_candidates(path)
  schemas, path = get_schemas(doc, cands)
  return nil if schemas.nil?
  ord = Orderer.new(path, schemas)
  ord.sort!
end