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"
SCALAR_JS =
"https://cdn.jsdelivr.net/npm/@scalar/api-reference"

Instance Method Summary collapse

Instance Method Details

#scalarObject



16
17
18
# File 'app/controllers/openapi_blocks/spec_controller.rb', line 16

def scalar
  render html: scalar_html.html_safe
end

#showObject



20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/openapi_blocks/spec_controller.rb', line 20

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



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

def ui
  render html: swagger_ui_html.html_safe
end