Module: Tina4::Swagger

Defined in:
lib/tina4/swagger.rb

Class Method Summary collapse

Class Method Details

.enabled?Boolean

TINA4_SWAGGER_ENABLED — defaults to TINA4_DEBUG. When false, callers can choose to skip mounting /swagger entirely in production.

Returns:

  • (Boolean)


18
19
20
21
22
23
24
# File 'lib/tina4/swagger.rb', line 18

def enabled?
  explicit = ENV["TINA4_SWAGGER_ENABLED"]
  if explicit && !explicit.empty?
    return %w[true 1 yes on].include?(explicit.to_s.strip.downcase)
  end
  %w[true 1 yes on].include?(ENV.fetch("TINA4_DEBUG", "").to_s.strip.downcase)
end

.generate(routes = []) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/tina4/swagger.rb', line 7

def generate(routes = [])
  spec = base_spec
  route_list = routes.empty? ? Tina4::Router.routes : routes
  route_list.each do |route|
    add_route_to_spec(spec, route)
  end
  spec
end