Class: OpenapiBlocks::SpecController

Inherits:
ActionController::API
  • Object
show all
Defined in:
app/controllers/openapi_blocks/spec_controller.rb

Overview

rubocop:disable Style/Documentation

Constant Summary collapse

SWAGGER_UI_CSS =
"https://unpkg.com/swagger-ui-dist@5.11.0/swagger-ui.css"
SWAGGER_UI_STANDALONE_JS =
"https://unpkg.com/swagger-ui-dist@5.11.0/swagger-ui-standalone-preset.js"
SWAGGER_UI_JS =
"https://unpkg.com/swagger-ui-dist@5.11.0/swagger-ui-bundle.js"

Instance Method Summary collapse

Instance Method Details

#showObject



15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/openapi_blocks/spec_controller.rb', line 15

def show
  spec = OpenapiBlocks::Builder.build.deep_stringify_keys
  spec["servers"] = swagger_ui_servers(spec)

  if request.format.yaml?
    render plain: spec.to_yaml, content_type: "application/yaml"
  else
    render json: spec
  end
end

#uiObject



11
12
13
# File 'app/controllers/openapi_blocks/spec_controller.rb', line 11

def ui
  render html: swagger_ui_html.html_safe
end