Class: OpenapiController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/openapi_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



4
5
6
7
8
9
10
11
12
13
14
# File 'app/controllers/openapi_controller.rb', line 4

def index
  @specs = Openapi.apis.map do |name, config|
    title = config[:title]
    spec_path = "#{config[:base_path]}/spec"
    [title, spec_path]
  end

  @default_specification_path = @specs.first ? @specs.first[1] : ''

  render 'index', layout: false
end

#specObject



16
17
18
19
20
21
22
23
# File 'app/controllers/openapi_controller.rb', line 16

def spec
  name = params[:name] || :default
  config = Openapi.apis[name]
  controllers = config[:controllers]
  json_schema = Swagger::Blocks.build_root_json(controllers)

  render json: json_schema
end