Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.1.4 version #38

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## master

## 1.1.4
* Support to Rails 6.1

## 1.1.3
* Turns compatible with sprockets 4
* Application Controller inheritance
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Include [swagger-ui](https://github.com/swagger-api/swagger-ui) as Rails engine

Swagger UI version | Rails version
------------------ | ----------------
2.2.10 | >= 4.2, <6
2.2.10 | >= 4.2, <= 6.1.x

## Features
* Supports API documentation versioning / multiple APIs documentation
Expand Down
5 changes: 2 additions & 3 deletions app/controllers/swagger_ui_engine/swagger_docs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ class SwaggerDocsController < SwaggerUiEngine::ApplicationController
include SwaggerUiEngine::ConfigParser
include SwaggerUiEngine::OauthConfigParser

add_template_helper SwaggerUiEngine::TranslationHelper
helper SwaggerUiEngine::TranslationHelper
layout 'swagger_ui_engine/layouts/swagger', except: %w(oauth2)

before_action :set_configs, :set_oauth_configs

def oauth2
end
def oauth2; end

def index
# backward compatibility for defining single doc url in strings
Expand Down
6 changes: 5 additions & 1 deletion app/views/swagger_ui_engine/swagger_docs/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<% content_for(:head) do %>
<script type="text/javascript">
function validationUrl(url) {
return url === 'null' ? null : url;
}

$(function () {
var url = window.location.search.match(/url=([^&]+)/);
if (url && url.length > 1) {
Expand All @@ -18,7 +22,7 @@
}
window.swaggerUi = new SwaggerUi({
url: url,
validatorUrl: "<%= @validator_url %>",
validatorUrl: validationUrl("<%= @validator_url %>"),
oauth2RedirectUrl: "<%= oauth2_swagger_docs_url %>",
dom_id: "swagger-ui-container",
supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
Expand Down
2 changes: 2 additions & 0 deletions lib/swagger_ui_engine/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class Engine < ::Rails::Engine
swagger_ui_engine/lang/*.js
swagger_ui_engine/DroidSans-Bold.ttf
swagger_ui_engine/DroidSans.ttf
swagger_ui_engine/application.js
swagger_ui_engine/application.css
]

Rails.application.config.assets.paths << Rails.root.join('vendor', 'assets', 'fonts')
Expand Down
2 changes: 1 addition & 1 deletion lib/swagger_ui_engine/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module SwaggerUiEngine
VERSION = '1.1.3'.freeze
VERSION = '1.1.4'.freeze
SWAGGER_UI_VERSION = '2.2.10'.freeze
end
4 changes: 3 additions & 1 deletion swagger_ui_engine.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Gem::Specification.new do |s|
'CHANGELOG.md'
]

s.add_runtime_dependency 'rails', '>= 4.2', '< 6'
s.add_runtime_dependency 'rails', '>= 4.2', '< 6.2'
s.add_runtime_dependency 'sassc-rails'

s.add_development_dependency 'sqlite3'
end
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,15 @@ class SwaggerDocsControllerTest < ActionDispatch::IntegrationTest
assert_response :success
assert_match('showRequestHeaders: "false"', @response.body)
assert_match('jsonEditor: "false"', @response.body)
assert_match('validatorUrl: "null"', @response.body)
assert_match('clientId: "your-client-id"', @response.body)
assert_match('clientSecret: "your-client-secret-if-required"', @response.body)
assert_match('scopeSeparator: " "', @response.body)
assert_match('additionalQueryStringParams: "{}"', @response.body)
end

test 'validatorUrl should should check the url to validate the given url or return real null' do
get '/swagger/swagger_docs/v1'
assert_match('validatorUrl: validationUrl("null")', @response.body)
end
end
end
Empty file.
22 changes: 22 additions & 0 deletions test/dummy/config/database.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# SQLite version 3.x
# gem install sqlite3
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000

production:
adapter: sqlite3
database: db/production.sqlite3
pool: 5
timeout: 5000