Skip to content

Commit 541a602

Browse files
committed
Style
1 parent 8bb1767 commit 541a602

File tree

10 files changed

+35
-8
lines changed

10 files changed

+35
-8
lines changed

Gemfile

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
source 'https://rubygems.org'
24

35
gemspec

Rakefile

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
begin
24
require 'bundler/setup'
35
rescue LoadError

app/controllers/swagger_ui_engine/application_controller.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module SwaggerUiEngine
24
class ApplicationController < ActionController::Base
35
protect_from_forgery with: :exception

app/controllers/swagger_ui_engine/docs_controller.rb

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module SwaggerUiEngine
24
class DocsController < ApplicationController
35
before_action :set_configs
@@ -9,17 +11,18 @@ def index
911
def show
1012
swagger_url = @swagger_urls[params[:id].to_sym]
1113
@swagger_config = engine_config.doc_config.merge(
12-
'spec-url': swagger_url,
14+
'spec-url': swagger_url
1315
).map do |attribute, value|
1416
"#{attribute}='#{value}'"
15-
end.join(' ').html_safe
17+
end.join(' ').html_safe # rubocop:disable Rails/OutputSafety
1618
render action: :show, layout: 'layouts/swagger'
1719
end
1820

1921
private
2022

2123
def set_configs
22-
@swagger_urls = engine_config.swagger_urls || engine_config.default_swagger_urls
24+
@swagger_urls =
25+
engine_config.swagger_urls || engine_config.default_swagger_urls
2326
end
2427

2528
def single_doc_url_hash?

config/routes.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
SwaggerUiEngine::Engine.routes.draw do
24
scope format: false do
35
resources :docs, only: %i(index show) do

lib/swagger_ui_engine.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'rails/engine'
24
require 'action_controller/railtie'
35
require 'swagger_ui_engine/engine'

lib/swagger_ui_engine/configuration.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module SwaggerUiEngine
24
class Configuration
35
OPTIONS = %i(
@@ -9,7 +11,7 @@ class Configuration
911
attr_accessor(*OPTIONS)
1012

1113
def default_swagger_urls
12-
{ v1: 'http://petstore.swagger.io/v2/swagger.json' }
14+
{v1: 'http://petstore.swagger.io/v2/swagger.json'}
1315
end
1416

1517
def doc_config

lib/swagger_ui_engine/engine.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module SwaggerUiEngine
24
class Engine < ::Rails::Engine
35
isolate_namespace SwaggerUiEngine

lib/swagger_ui_engine/version.rb

+12-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
1+
# frozen_string_literal: true
2+
13
module SwaggerUiEngine
2-
VERSION = '1.0.2'.freeze
3-
def self.swagger_ui_version
4-
@swagger_ui_version ||=
4+
VERSION = '1.0.2' unless const_defined?(:VERSION)
5+
def self.version
6+
VERSION
7+
end
8+
9+
def self.redoc_version
10+
@redoc_version ||=
511
begin
612
require 'json'
713
lib = File.expand_path('..', __FILE__)
814
root = File.expand_path File.join(lib, '..', '..')
915
file = File.join(root, 'package.json')
10-
JSON.parse(File.read(file)).fetch("dependencies").fetch("swagger-ui-dist")
16+
JSON.parse(File.read(file))
17+
.fetch("dependencies")
18+
.fetch("redoc")
1119
end
1220
end
1321
end

lib/tasks/rubocop.rake

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
begin
24
require "rubocop"
35
require "rubocop/rake_task"

0 commit comments

Comments
 (0)