Class: AcosOpenApiHelper::PageEngine

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

Instance Method Summary collapse

Constructor Details

#initialize(data, basePath, output_path, swaggerfile) ⇒ PageEngine

Returns a new instance of PageEngine.



46
47
48
49
50
51
52
# File 'lib/acos_jekyll_openapi.rb', line 46

def initialize(data, basePath, output_path, swaggerfile)
    @data = data
    @output_path = output_path
    #@sidebar = sidebar
    @swaggerfile = swaggerfile
    @basePath = basePath
end

Instance Method Details

#generateObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/acos_jekyll_openapi.rb', line 54

def generate
    puts "generating pages..."
    cnt = 0
    puts "Open API version %s" % @data['openapi']
    docTitle = @data["info"]["title"]
    sidebar =  "%s_sidebar" % docTitle
    menu = AcosOpenApiHelper::SidebarMenu.new()
    @data['paths'].each do |path|
        #puts "Prop: %s at counter %s" % [path, cnt]
        _path = path[0] #path of swagger method
        _methods = @data['paths'][_path]
        #puts "Path: %s has methods: %s " % [_path, _methods]
        puts "Methods: %s" % _methods
        puts "Path: %s" % [_path]
        #Should not need this. yet...
        # _methods.each do | _method |
        #     puts "Method: %s " % _method
        #     _md = _methods[_method]
        #     puts "Method description: %s" % [_md]
        # end
        #@prop = @data['paths'][cnt]
        #puts "Found property %s" [@prop]
        #puts "Constants: %s, %s, %s, %s" % [_path, @output_path, @swaggerfile, @sidebar]
        writer =  AcosOpenApiHelper::PageCreator.new(_path, @basePath, @output_path, @swaggerfile, sidebar)
        writer.write
        _permalink =AcosOpenApiHelper::PermalinkGenerator.create(_path, @swaggerfile)
        _menuItem = AcosOpenApiHelper::MenuItem.new(_path, _permalink)
        menu.add(_menuItem)
        cnt = cnt + 1

    end
    puts "Done generating %s pages..." % cnt
    puts "Writing menu"
    menu.write("%s/_data/sidebars" % @basePath, sidebar, docTitle)
end