Class: ActionDispatch::Routing::OpenAPI3Formatter

Inherits:
Object
  • Object
show all
Defined in:
lib/openapi3_definition_generator/rails/openapi3_formatter.rb

Instance Method Summary collapse

Constructor Details

#initializeOpenAPI3Formatter

Returns a new instance of OpenAPI3Formatter.



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/openapi3_definition_generator/rails/openapi3_formatter.rb', line 7

def initialize()
  @view  = nil
  @buffer = []
  @openapi_structute = {
    'openapi' => '3.0.0',
    'info' => {
      'title' => '',
      'description' => '',
      'version' => '0.1.0'
    },
    'paths' => {}
  }
end

Instance Method Details

#header(routes) ⇒ Object



38
39
# File 'lib/openapi3_definition_generator/rails/openapi3_formatter.rb', line 38

def header(routes)
end

#no_routesObject



41
42
# File 'lib/openapi3_definition_generator/rails/openapi3_formatter.rb', line 41

def no_routes(*)
end

#resultObject



44
45
46
# File 'lib/openapi3_definition_generator/rails/openapi3_formatter.rb', line 44

def result
  YAML.dump @openapi_structute
end

#section(routes) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/openapi3_definition_generator/rails/openapi3_formatter.rb', line 24

def section(routes)
  routes.filter do |r|
    !r[:verb].empty?
  end.each do |r|
    @openapi_structute['paths'][r[:path]] ||= {}
    @openapi_structute['paths'][r[:path]][r[:verb].downcase] = {}
    @openapi_structute['paths'][r[:path]][r[:verb].downcase] = {
      'summary' => r[:name],
      'description' => r[:reqs],
      'responses' => nil
    }
  end
end

#section_title(title) ⇒ Object



21
22
# File 'lib/openapi3_definition_generator/rails/openapi3_formatter.rb', line 21

def section_title(title)
end