From 233c5cc7358723d5c7ab98d439b70cd949f177bd Mon Sep 17 00:00:00 2001 From: Dante Piombino Date: Thu, 16 Feb 2017 16:31:45 -0500 Subject: [PATCH 01/10] get no deprecation; add some docs --- README.md | 25 +++++++++++++++++++ .../lib/rswag/specs/extended_schema.rb | 6 ++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f6db531..228168c 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,31 @@ response '201', 'blog created' do end ``` +### Null Values ### + +This library is currently using JSON::Draft4 for validation of response models. It does not support null as a value. So you can add the property 'x-nullable' to a definition to allow null/nil values to pass. +```ruby +describe 'Blogs API' do + path '/blogs' do + post 'Creates a blog' do + ... + + response '200', 'blog found' do + schema type: :object, + properties: { + id: { type: :integer }, + title: { type: :string }, + content: { type: :string, 'x-nullable': true } + } + .... + end + end + end +end +``` +*Note:* the OAI v3 may be released soon(ish?) and include a nullable property. This may have an effect on the need/use of custom extension to the draft. Do not use this property if you don't understand the implications. + + ### Global Metadata ### In addition to paths, operations and responses, Swagger also supports global API metadata. When you install rswag, a file called _swagger_helper.rb_ is added to your spec folder. This is where you define one or more Swagger documents and provide global metadata. Again, the format is based on Swagger so most of the global fields supported by the top level ["Swagger" object](http://swagger.io/specification/#swaggerObject) can be provided with each document definition. As an example, you could define a Swagger document for each version of your API and in each case specify a title, version string and URL basePath: diff --git a/rswag-specs/lib/rswag/specs/extended_schema.rb b/rswag-specs/lib/rswag/specs/extended_schema.rb index 379868d..493a27a 100644 --- a/rswag-specs/lib/rswag/specs/extended_schema.rb +++ b/rswag-specs/lib/rswag/specs/extended_schema.rb @@ -2,18 +2,16 @@ require 'json-schema' module Rswag module Specs - class ExtendedSchema < JSON::Schema::Validator - + class ExtendedSchema < JSON::Schema::Draft4 def initialize super - extend_schema_definition("http://json-schema.org/draft-04/schema#") @attributes['type'] = ExtendedTypeAttribute @uri = URI.parse('http://tempuri.org/rswag/specs/extended_schema') + @names = ['http://tempuri.org/rswag/specs/extended_schema'] end end class ExtendedTypeAttribute < JSON::Schema::TypeV4Attribute - def self.validate(current_schema, data, fragments, processor, validator, options={}) return if data.nil? && current_schema.schema['x-nullable'] == true super From 8aeb9a6c70e08a3e1b23e3a1fc5394b55e022a7e Mon Sep 17 00:00:00 2001 From: Grzesiek Kolodziejczyk Date: Thu, 18 May 2017 11:39:18 +0200 Subject: [PATCH 02/10] Relax Rails dependency to allow 5.1 --- .travis.yml | 1 + Gemfile | 2 +- Gemfile.lock | 195 ++++++++++-------- rswag-api/rswag-api.gemspec | 2 +- rswag-specs/rswag-specs.gemspec | 2 +- rswag-ui/rswag-ui.gemspec | 2 +- .../db/migrate/20160218212104_create_blogs.rb | 8 +- test-app/db/schema.rb | 15 +- 8 files changed, 127 insertions(+), 100 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6c59b5b..1e052a7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,7 @@ env: - "RAILS_VERSION=3.2.22" - "RAILS_VERSION=4.2.0" - "RAILS_VERSION=5.0.0" + - "RAILS_VERSION=5.1.1" cache: bundler install: bundle update before_script: diff --git a/Gemfile b/Gemfile index 298afb3..e642a0f 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source "https://rubygems.org" # Allow the rails version to come from an ENV setting so Travis can test multiple versions. # See http://www.schneems.com/post/50991826838/testing-against-multiple-rails-versions/ -rails_version = ENV['RAILS_VERSION'] || '3.2.22' +rails_version = ENV['RAILS_VERSION'] || '5.1.1' gem 'rails', "#{rails_version}" diff --git a/Gemfile.lock b/Gemfile.lock index 5afb841..b9ea1a4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,57 +1,67 @@ PATH - remote: ./rswag-api + remote: rswag-api specs: rswag-api (1.2.0) - rails (>= 3.1, < 5.1) + rails (>= 3.1, < 5.2) PATH - remote: ./rswag-specs + remote: rswag-specs specs: rswag-specs (1.2.0) json (~> 1.8) json-schema (~> 2.2) - rails (>= 3.1, < 5.1) + rails (>= 3.1, < 5.2) rspec-rails (>= 2.14, < 4) PATH - remote: ./rswag-ui + remote: rswag-ui specs: rswag-ui (1.2.0) - rails (>= 3.1, < 5.1) + rails (>= 3.1, < 5.2) GEM remote: https://rubygems.org/ specs: - actionmailer (3.2.22) - actionpack (= 3.2.22) - mail (~> 2.5.4) - actionpack (3.2.22) - activemodel (= 3.2.22) - activesupport (= 3.2.22) - builder (~> 3.0.0) - erubis (~> 2.7.0) - journey (~> 1.0.4) - rack (~> 1.4.5) - rack-cache (~> 1.2) - rack-test (~> 0.6.1) - sprockets (~> 2.2.1) - activemodel (3.2.22) - activesupport (= 3.2.22) - builder (~> 3.0.0) - activerecord (3.2.22) - activemodel (= 3.2.22) - activesupport (= 3.2.22) - arel (~> 3.0.2) - tzinfo (~> 0.3.29) - activeresource (3.2.22) - activemodel (= 3.2.22) - activesupport (= 3.2.22) - activesupport (3.2.22) - i18n (~> 0.6, >= 0.6.4) - multi_json (~> 1.0) + actioncable (5.1.1) + actionpack (= 5.1.1) + nio4r (~> 2.0) + websocket-driver (~> 0.6.1) + actionmailer (5.1.1) + actionpack (= 5.1.1) + actionview (= 5.1.1) + activejob (= 5.1.1) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (5.1.1) + actionview (= 5.1.1) + activesupport (= 5.1.1) + rack (~> 2.0) + rack-test (~> 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (5.1.1) + activesupport (= 5.1.1) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (5.1.1) + activesupport (= 5.1.1) + globalid (>= 0.3.6) + activemodel (5.1.1) + activesupport (= 5.1.1) + activerecord (5.1.1) + activemodel (= 5.1.1) + activesupport (= 5.1.1) + arel (~> 8.0) + activesupport (5.1.1) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (~> 0.7) + minitest (~> 5.1) + tzinfo (~> 1.1) addressable (2.4.0) - arel (3.0.3) - builder (3.0.4) + arel (8.0.0) + builder (3.2.3) capybara (2.10.1) addressable mime-types (>= 1.16) @@ -62,55 +72,65 @@ GEM capybara-webkit (1.1.0) capybara (~> 2.0, >= 2.0.2) json + concurrent-ruby (1.0.5) diff-lcs (1.2.5) - erubis (2.7.0) + erubi (1.6.0) execjs (2.7.0) generator_spec (0.9.3) activesupport (>= 3.0.0) railties (>= 3.0.0) - hike (1.2.3) - i18n (0.7.0) - journey (1.0.4) - json (1.8.3) - json-schema (2.7.0) + globalid (0.4.0) + activesupport (>= 4.2.0) + i18n (0.8.1) + json (1.8.6) + json-schema (2.8.0) addressable (>= 2.4) libv8 (3.16.14.15) - mail (2.5.4) - mime-types (~> 1.16) - treetop (~> 1.4.8) - mime-types (1.25.1) + loofah (2.0.3) + nokogiri (>= 1.5.9) + mail (2.6.5) + mime-types (>= 1.16, < 4) + method_source (0.8.2) + mime-types (3.1) + mime-types-data (~> 3.2015) + mime-types-data (3.2016.0521) mini_portile2 (2.1.0) - multi_json (1.12.1) + minitest (5.10.2) + nio4r (2.0.0) nokogiri (1.6.8.1) mini_portile2 (~> 2.1.0) - polyglot (0.3.5) power_assert (0.3.1) - rack (1.4.7) - rack-cache (1.6.1) - rack (>= 0.4) - rack-ssl (1.3.4) - rack + rack (2.0.3) rack-test (0.6.3) rack (>= 1.0) - rails (3.2.22) - actionmailer (= 3.2.22) - actionpack (= 3.2.22) - activerecord (= 3.2.22) - activeresource (= 3.2.22) - activesupport (= 3.2.22) - bundler (~> 1.0) - railties (= 3.2.22) - railties (3.2.22) - actionpack (= 3.2.22) - activesupport (= 3.2.22) - rack-ssl (~> 1.3.2) + rails (5.1.1) + actioncable (= 5.1.1) + actionmailer (= 5.1.1) + actionpack (= 5.1.1) + actionview (= 5.1.1) + activejob (= 5.1.1) + activemodel (= 5.1.1) + activerecord (= 5.1.1) + activesupport (= 5.1.1) + bundler (>= 1.3.0, < 2.0) + railties (= 5.1.1) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.0.3) + loofah (~> 2.0) + railties (5.1.1) + actionpack (= 5.1.1) + activesupport (= 5.1.1) + method_source rake (>= 0.8.7) - rdoc (~> 3.4) - thor (>= 0.14.6, < 2.0) - rake (11.3.0) - rdoc (3.12.2) - json (~> 1.4) + thor (>= 0.18.1, < 2.0) + rake (12.0.0) ref (2.0.0) + responders (2.4.0) + actionpack (>= 4.2.0, < 5.3) + railties (>= 4.2.0, < 5.3) rspec-core (3.5.4) rspec-support (~> 3.5.0) rspec-expectations (3.5.0) @@ -128,30 +148,28 @@ GEM rspec-mocks (~> 3.5.0) rspec-support (~> 3.5.0) rspec-support (3.5.0) - sprockets (2.2.3) - hike (~> 1.2) - multi_json (~> 1.0) - rack (~> 1.0) - tilt (~> 1.1, != 1.3.0) + sprockets (3.7.1) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.0) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) sqlite3 (1.3.12) - strong_parameters (0.2.3) - actionpack (~> 3.0) - activemodel (~> 3.0) - activesupport (~> 3.0) - railties (~> 3.0) test-unit (3.2.1) power_assert therubyracer (0.12.2) libv8 (~> 3.16.14.0) ref - thor (0.19.1) - tilt (1.4.1) - treetop (1.4.15) - polyglot - polyglot (>= 0.3.1) - tzinfo (0.3.51) + thor (0.19.4) + thread_safe (0.3.6) + tzinfo (1.2.3) + thread_safe (~> 0.1) uglifier (3.0.2) execjs (>= 0.3.0, < 3) + websocket-driver (0.6.5) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.2) xpath (2.0.0) nokogiri (~> 1.3) @@ -162,13 +180,16 @@ DEPENDENCIES capybara capybara-webkit generator_spec - rails (= 3.2.22) + rails (= 5.1.1) + responders rspec-rails rswag-api! rswag-specs! rswag-ui! sqlite3 - strong_parameters test-unit therubyracer uglifier + +BUNDLED WITH + 1.14.6 diff --git a/rswag-api/rswag-api.gemspec b/rswag-api/rswag-api.gemspec index 5275ea2..b76df41 100644 --- a/rswag-api/rswag-api.gemspec +++ b/rswag-api/rswag-api.gemspec @@ -16,5 +16,5 @@ Gem::Specification.new do |s| s.files = Dir["{lib}/**/*"] + ["MIT-LICENSE", "Rakefile" ] - s.add_dependency "rails", ">= 3.1", "< 5.1" + s.add_dependency "rails", ">= 3.1", "< 5.2" end diff --git a/rswag-specs/rswag-specs.gemspec b/rswag-specs/rswag-specs.gemspec index 6e866a6..17daaab 100644 --- a/rswag-specs/rswag-specs.gemspec +++ b/rswag-specs/rswag-specs.gemspec @@ -16,7 +16,7 @@ Gem::Specification.new do |s| s.files = Dir["{lib}/**/*"] + ["MIT-LICENSE", "Rakefile" ] - s.add_dependency "rails", ">= 3.1", "< 5.1" + s.add_dependency "rails", ">= 3.1", "< 5.2" s.add_dependency 'json', '~> 1.8' s.add_dependency 'json-schema', '~> 2.2' s.add_dependency 'rspec-rails', '>= 2.14', '< 4' diff --git a/rswag-ui/rswag-ui.gemspec b/rswag-ui/rswag-ui.gemspec index 2634542..edbbf82 100644 --- a/rswag-ui/rswag-ui.gemspec +++ b/rswag-ui/rswag-ui.gemspec @@ -16,5 +16,5 @@ Gem::Specification.new do |s| s.files = Dir["{app,config,lib,vendor}/**/*"] + ["MIT-LICENSE", "Rakefile" ] - s.add_dependency "rails", ">= 3.1", "< 5.1" + s.add_dependency "rails", ">= 3.1", "< 5.2" end diff --git a/test-app/db/migrate/20160218212104_create_blogs.rb b/test-app/db/migrate/20160218212104_create_blogs.rb index 81d9813..03e1463 100644 --- a/test-app/db/migrate/20160218212104_create_blogs.rb +++ b/test-app/db/migrate/20160218212104_create_blogs.rb @@ -1,4 +1,10 @@ -class CreateBlogs < ActiveRecord::Migration +migration_class = if Gem::Version.new(Rails.version) >= Gem::Version.new("5.0") + ActiveRecord::Migration[4.2] + else + ActiveRecord::Migration + end + +class CreateBlogs < migration_class def change create_table :blogs do |t| t.string :title diff --git a/test-app/db/schema.rb b/test-app/db/schema.rb index 082bb8d..4e72efd 100644 --- a/test-app/db/schema.rb +++ b/test-app/db/schema.rb @@ -1,4 +1,3 @@ -# encoding: UTF-8 # This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. @@ -9,15 +8,15 @@ # from scratch. The latter is a flawed and unsustainable approach (the more migrations # you'll amass, the slower it'll run and the greater likelihood for issues). # -# It's strongly recommended to check this file into your version control system. +# It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(:version => 20160218212104) do +ActiveRecord::Schema.define(version: 20160218212104) do - create_table "blogs", :force => true do |t| - t.string "title" - t.text "content" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + create_table "blogs", force: :cascade do |t| + t.string "title" + t.text "content" + t.datetime "created_at" + t.datetime "updated_at" end end From 724ede007698a7db9d4f6e6ea8c2824a95a28f24 Mon Sep 17 00:00:00 2001 From: Grzesiek Kolodziejczyk Date: Thu, 18 May 2017 11:48:14 +0200 Subject: [PATCH 03/10] Remove unnecessary whitespace --- rswag-api/rswag-api.gemspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rswag-api/rswag-api.gemspec b/rswag-api/rswag-api.gemspec index b76df41..19ba7f0 100644 --- a/rswag-api/rswag-api.gemspec +++ b/rswag-api/rswag-api.gemspec @@ -14,7 +14,7 @@ Gem::Specification.new do |s| s.description = "Open up your API to the phenomenal Swagger ecosystem by exposing Swagger files, that describe your service, as JSON endpoints" s.license = "MIT" - s.files = Dir["{lib}/**/*"] + ["MIT-LICENSE", "Rakefile" ] + s.files = Dir["{lib}/**/*"] + ["MIT-LICENSE", "Rakefile"] - s.add_dependency "rails", ">= 3.1", "< 5.2" + s.add_dependency "rails", ">= 3.1", "< 5.2" end From 2617fdc48d5bec6c07f751d7b077ebde541dfd2e Mon Sep 17 00:00:00 2001 From: domaindrivendev Date: Thu, 23 Feb 2017 18:47:38 -0800 Subject: [PATCH 04/10] Prep for v1.2.1 release --- .gitignore | 1 + Gemfile.lock | 15 +++++++++------ rswag-api/lib/rswag/api/version.rb | 2 +- rswag-specs/lib/rswag/specs/version.rb | 2 +- rswag-ui/lib/rswag/ui/version.rb | 2 +- rswag/lib/rswag/version.rb | 2 +- 6 files changed, 14 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 8bfce63..d688e03 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ **/*/*.gem **/*/*.sqlite3 **/*/public/assets +*.swp diff --git a/Gemfile.lock b/Gemfile.lock index 5afb841..4fd4aa7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,22 +1,22 @@ PATH - remote: ./rswag-api + remote: rswag-api specs: - rswag-api (1.2.0) + rswag-api (1.2.1) rails (>= 3.1, < 5.1) PATH - remote: ./rswag-specs + remote: rswag-specs specs: - rswag-specs (1.2.0) + rswag-specs (1.2.1) json (~> 1.8) json-schema (~> 2.2) rails (>= 3.1, < 5.1) rspec-rails (>= 2.14, < 4) PATH - remote: ./rswag-ui + remote: rswag-ui specs: - rswag-ui (1.2.0) + rswag-ui (1.2.1) rails (>= 3.1, < 5.1) GEM @@ -172,3 +172,6 @@ DEPENDENCIES test-unit therubyracer uglifier + +BUNDLED WITH + 1.14.6 diff --git a/rswag-api/lib/rswag/api/version.rb b/rswag-api/lib/rswag/api/version.rb index 95b49f0..ca2a0e8 100644 --- a/rswag-api/lib/rswag/api/version.rb +++ b/rswag-api/lib/rswag/api/version.rb @@ -1,5 +1,5 @@ module Rswag module Api - VERSION = '1.2.0' + VERSION = '1.2.1' end end diff --git a/rswag-specs/lib/rswag/specs/version.rb b/rswag-specs/lib/rswag/specs/version.rb index ab6aa48..fe728f1 100644 --- a/rswag-specs/lib/rswag/specs/version.rb +++ b/rswag-specs/lib/rswag/specs/version.rb @@ -1,5 +1,5 @@ module Rswag module Specs - VERSION = '1.2.0' + VERSION = '1.2.1' end end diff --git a/rswag-ui/lib/rswag/ui/version.rb b/rswag-ui/lib/rswag/ui/version.rb index 29631fb..9079487 100644 --- a/rswag-ui/lib/rswag/ui/version.rb +++ b/rswag-ui/lib/rswag/ui/version.rb @@ -1,5 +1,5 @@ module Rswag module Ui - VERSION = '1.2.0' + VERSION = '1.2.1' end end diff --git a/rswag/lib/rswag/version.rb b/rswag/lib/rswag/version.rb index dcd66b1..19b73a9 100644 --- a/rswag/lib/rswag/version.rb +++ b/rswag/lib/rswag/version.rb @@ -1,3 +1,3 @@ module Rswag - VERSION = '1.2.0' + VERSION = '1.2.1' end From 353be669e4ff118b082a7b9227d95a399b87c41e Mon Sep 17 00:00:00 2001 From: domaindrivendev Date: Fri, 19 May 2017 11:11:13 -0700 Subject: [PATCH 05/10] Removed some deprecation warnings --- .ruby-version | 1 + .../lib/rswag/specs/extended_schema.rb | 3 +- test-app/app/models/blog.rb | 2 +- test-app/config/environments/development.rb | 2 + test-app/config/environments/production.rb | 67 ------------------- test-app/config/environments/test.rb | 2 + test-app/config/initializers/secret_token.rb | 3 + test-app/db/schema.rb | 6 +- test-app/spec/swagger_helper.rb | 2 +- test-app/swagger/v1/swagger.json | 3 +- 10 files changed, 16 insertions(+), 75 deletions(-) create mode 100644 .ruby-version delete mode 100644 test-app/config/environments/production.rb diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..276cbf9 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +2.3.0 diff --git a/rswag-specs/lib/rswag/specs/extended_schema.rb b/rswag-specs/lib/rswag/specs/extended_schema.rb index 379868d..18bd940 100644 --- a/rswag-specs/lib/rswag/specs/extended_schema.rb +++ b/rswag-specs/lib/rswag/specs/extended_schema.rb @@ -2,11 +2,10 @@ require 'json-schema' module Rswag module Specs - class ExtendedSchema < JSON::Schema::Validator + class ExtendedSchema < JSON::Schema::Draft4 def initialize super - extend_schema_definition("http://json-schema.org/draft-04/schema#") @attributes['type'] = ExtendedTypeAttribute @uri = URI.parse('http://tempuri.org/rswag/specs/extended_schema') end diff --git a/test-app/app/models/blog.rb b/test-app/app/models/blog.rb index 51b0795..e913dba 100644 --- a/test-app/app/models/blog.rb +++ b/test-app/app/models/blog.rb @@ -5,7 +5,7 @@ class Blog < ActiveRecord::Base { id: id, title: title, - content: content + content: nil } end end diff --git a/test-app/config/environments/development.rb b/test-app/config/environments/development.rb index 7886e90..9bcfc66 100644 --- a/test-app/config/environments/development.rb +++ b/test-app/config/environments/development.rb @@ -28,4 +28,6 @@ TestApp::Application.configure do # Expands the lines which load the assets config.assets.debug = true + + config.eager_load = false end diff --git a/test-app/config/environments/production.rb b/test-app/config/environments/production.rb deleted file mode 100644 index a9a5401..0000000 --- a/test-app/config/environments/production.rb +++ /dev/null @@ -1,67 +0,0 @@ -TestApp::Application.configure do - # Settings specified here will take precedence over those in config/application.rb - - # Code is not reloaded between requests - config.cache_classes = true - - # Full error reports are disabled and caching is turned on - config.consider_all_requests_local = false - config.action_controller.perform_caching = true - - # Disable Rails's static asset server (Apache or nginx will already do this) - config.serve_static_assets = true - - # Compress JavaScripts and CSS - config.assets.compress = true - - # Don't fallback to assets pipeline if a precompiled asset is missed - config.assets.compile = false - - # Generate digests for assets URLs - config.assets.digest = true - - # Defaults to nil and saved in location specified by config.assets.prefix - # config.assets.manifest = YOUR_PATH - - # Specifies the header that your server uses for sending files - # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache - # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx - - # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. - # config.force_ssl = true - - # See everything in the log (default is :info) - # config.log_level = :debug - - # Prepend all log lines with the following tags - # config.log_tags = [ :subdomain, :uuid ] - - # Use a different logger for distributed setups - # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) - - # Use a different cache store in production - # config.cache_store = :mem_cache_store - - # Enable serving of images, stylesheets, and JavaScripts from an asset server - # config.action_controller.asset_host = "http://assets.example.com" - - # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) - # config.assets.precompile += %w( search.js ) - - # Disable delivery errors, bad email addresses will be ignored - # config.action_mailer.raise_delivery_errors = false - - # Enable threaded mode - # config.threadsafe! - - # Enable locale fallbacks for I18n (makes lookups for any locale fall back to - # the I18n.default_locale when a translation can not be found) - config.i18n.fallbacks = true - - # Send deprecation notices to registered listeners - config.active_support.deprecation = :notify - - # Log the query plan for queries taking more than this (works - # with SQLite, MySQL, and PostgreSQL) - # config.active_record.auto_explain_threshold_in_seconds = 0.5 -end diff --git a/test-app/config/environments/test.rb b/test-app/config/environments/test.rb index 6dd0bf7..3a35ac5 100644 --- a/test-app/config/environments/test.rb +++ b/test-app/config/environments/test.rb @@ -32,4 +32,6 @@ TestApp::Application.configure do # Print deprecation notices to the stderr config.active_support.deprecation = :stderr + + config.eager_load = false end diff --git a/test-app/config/initializers/secret_token.rb b/test-app/config/initializers/secret_token.rb index 706e45d..843ff63 100644 --- a/test-app/config/initializers/secret_token.rb +++ b/test-app/config/initializers/secret_token.rb @@ -5,3 +5,6 @@ # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attacks. TestApp::Application.config.secret_token = '60f36cd33756d73f362053f1d45256ae50d75440b634ae73b070a6e35a2df38692f59e28e5ecbd1f9f2e850255f6d29a468bc59ac4484c2b7f0548ddbfc1b870' + +# See http://guides.rubyonrails.org/upgrading_ruby_on_rails.html#config-secrets-yml +TestApp::Application.config.secret_key_base = 'f6a820cc8aa76094583cd68ef46a735e25e3278648086355f8bd24721f036959c728c06a28dcecfe695f17ae2db44dfa1424f22b81377f2a1496d4e19f6f7faa' diff --git a/test-app/db/schema.rb b/test-app/db/schema.rb index 4e72efd..cea4d93 100644 --- a/test-app/db/schema.rb +++ b/test-app/db/schema.rb @@ -13,10 +13,10 @@ ActiveRecord::Schema.define(version: 20160218212104) do create_table "blogs", force: :cascade do |t| - t.string "title" + t.string "title", limit: 255 t.text "content" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end end diff --git a/test-app/spec/swagger_helper.rb b/test-app/spec/swagger_helper.rb index a3b76b4..f3202ec 100644 --- a/test-app/spec/swagger_helper.rb +++ b/test-app/spec/swagger_helper.rb @@ -39,7 +39,7 @@ RSpec.configure do |config| properties: { id: { type: 'integer' }, title: { type: 'string' }, - content: { type: 'string' } + content: { type: 'string', 'x-nullable': true } }, required: [ 'id', 'title', 'content' ] } diff --git a/test-app/swagger/v1/swagger.json b/test-app/swagger/v1/swagger.json index acbcd1e..7ee0753 100644 --- a/test-app/swagger/v1/swagger.json +++ b/test-app/swagger/v1/swagger.json @@ -146,7 +146,8 @@ "type": "string" }, "content": { - "type": "string" + "type": "string", + "x-nullable": true } }, "required": [ From 69c7decce16e7425395f0e3a2d3c1570a6599d36 Mon Sep 17 00:00:00 2001 From: Robert Kranz Date: Thu, 1 Jun 2017 16:01:15 +0200 Subject: [PATCH 06/10] Add proper swagger ui url As this only supports swagger ui 2, the url should link accordingly --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index be69bbb..f068c70 100644 --- a/README.md +++ b/README.md @@ -382,7 +382,7 @@ end ### Customizing the swagger-ui ### -The swagger-ui provides several options for customizing it's behavior, all of which are documented here https://github.com/swagger-api/swagger-ui#swaggerui. If you need to tweak these or customize the overall look and feel of your swagger-ui, then you'll need to provide your own version of index.html. You can do this with the following generator. +The swagger-ui provides several options for customizing it's behavior, all of which are documented here https://github.com/swagger-api/swagger-ui/tree/2.x#swaggerui. If you need to tweak these or customize the overall look and feel of your swagger-ui, then you'll need to provide your own version of index.html. You can do this with the following generator. ```ruby rails g rswag:ui:custom From 925b754233300ba20a5b7b854aa2be48eade2b3d Mon Sep 17 00:00:00 2001 From: Vadim Lazebny Date: Mon, 19 Jun 2017 15:15:53 +0300 Subject: [PATCH 07/10] Fixed issue with precomilation --- rswag-ui/lib/rswag/ui/engine.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/rswag-ui/lib/rswag/ui/engine.rb b/rswag-ui/lib/rswag/ui/engine.rb index 9e35902..f9e2460 100644 --- a/rswag-ui/lib/rswag/ui/engine.rb +++ b/rswag-ui/lib/rswag/ui/engine.rb @@ -5,7 +5,14 @@ module Rswag initializer 'rswag-ui.initialize' do |app| if app.config.respond_to?(:assets) - app.config.assets.precompile += [ 'swagger-ui/*' ] + app.config.assets.precompile += [ + 'swagger-ui/css/*', + 'swagger-ui/fonts/*', + 'swagger-ui/images/*', + 'swagger-ui/lang/*', + 'swagger-ui/lib/*', + 'swagger-ui/swagger-ui.min.js' + ] end end end From e40c5fc26ed96fe18f0e3ed53ff75c9010700966 Mon Sep 17 00:00:00 2001 From: domaindrivendev Date: Fri, 19 May 2017 11:23:03 -0700 Subject: [PATCH 08/10] Prep for 1.3.0 --- Gemfile.lock | 6 +++--- rswag-api/lib/rswag/api/version.rb | 2 +- rswag-specs/lib/rswag/specs/version.rb | 2 +- rswag-ui/lib/rswag/ui/version.rb | 2 +- rswag/lib/rswag/version.rb | 2 +- test-app/config/boot.rb | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 8697be9..65cd78f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,13 +1,13 @@ PATH remote: rswag-api specs: - rswag-api (1.2.1) + rswag-api (1.3.0) rails (>= 3.1, < 5.2) PATH remote: rswag-specs specs: - rswag-specs (1.2.1) + rswag-specs (1.3.0) json (~> 1.8) json-schema (~> 2.2) rails (>= 3.1, < 5.2) @@ -16,7 +16,7 @@ PATH PATH remote: rswag-ui specs: - rswag-ui (1.2.1) + rswag-ui (1.3.0) rails (>= 3.1, < 5.2) GEM diff --git a/rswag-api/lib/rswag/api/version.rb b/rswag-api/lib/rswag/api/version.rb index ca2a0e8..5dc9577 100644 --- a/rswag-api/lib/rswag/api/version.rb +++ b/rswag-api/lib/rswag/api/version.rb @@ -1,5 +1,5 @@ module Rswag module Api - VERSION = '1.2.1' + VERSION = '1.3.0' end end diff --git a/rswag-specs/lib/rswag/specs/version.rb b/rswag-specs/lib/rswag/specs/version.rb index fe728f1..2f136b2 100644 --- a/rswag-specs/lib/rswag/specs/version.rb +++ b/rswag-specs/lib/rswag/specs/version.rb @@ -1,5 +1,5 @@ module Rswag module Specs - VERSION = '1.2.1' + VERSION = '1.3.0' end end diff --git a/rswag-ui/lib/rswag/ui/version.rb b/rswag-ui/lib/rswag/ui/version.rb index 9079487..1966406 100644 --- a/rswag-ui/lib/rswag/ui/version.rb +++ b/rswag-ui/lib/rswag/ui/version.rb @@ -1,5 +1,5 @@ module Rswag module Ui - VERSION = '1.2.1' + VERSION = '1.3.0' end end diff --git a/rswag/lib/rswag/version.rb b/rswag/lib/rswag/version.rb index 19b73a9..d903ac6 100644 --- a/rswag/lib/rswag/version.rb +++ b/rswag/lib/rswag/version.rb @@ -1,3 +1,3 @@ module Rswag - VERSION = '1.2.1' + VERSION = '1.3.0' end diff --git a/test-app/config/boot.rb b/test-app/config/boot.rb index eba0681..5ea7451 100644 --- a/test-app/config/boot.rb +++ b/test-app/config/boot.rb @@ -1,5 +1,5 @@ require 'rubygems' -gemfile = File.expand_path('../../../../Gemfile', __FILE__) +gemfile = File.expand_path('../../../Gemfile', __FILE__) if File.exist?(gemfile) ENV['BUNDLE_GEMFILE'] = gemfile @@ -7,4 +7,4 @@ if File.exist?(gemfile) Bundler.setup end -$:.unshift File.expand_path('../../../../lib', __FILE__) \ No newline at end of file +$:.unshift File.expand_path('../../../../lib', __FILE__) From de7ec5f15d94588c61f0b78bd28678b83fe8db4f Mon Sep 17 00:00:00 2001 From: domaindrivendev Date: Wed, 15 Feb 2017 15:38:03 -0500 Subject: [PATCH 09/10] Leverage security definitions for headers in example requests --- Gemfile.lock | 12 ++-- README.md | 52 +++++++++++++++++ .../lib/rswag/specs/example_helpers.rb | 18 +++++- .../lib/rswag/specs/request_factory.rb | 57 ++++++++++++------- .../spec/rswag/specs/request_factory_spec.rb | 35 ++++++++++-- .../app/controllers/application_controller.rb | 2 +- .../app/controllers/auth_tests_controller.rb | 13 +++++ test-app/config/routes.rb | 2 + test-app/spec/integration/auth_tests_spec.rb | 22 +++++++ test-app/spec/swagger_helper.rb | 3 + test-app/swagger/v1/swagger.json | 27 +++++++++ 11 files changed, 209 insertions(+), 34 deletions(-) create mode 100644 test-app/app/controllers/auth_tests_controller.rb create mode 100644 test-app/spec/integration/auth_tests_spec.rb diff --git a/Gemfile.lock b/Gemfile.lock index 65cd78f..132eeed 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -81,24 +81,24 @@ GEM railties (>= 3.0.0) globalid (0.4.0) activesupport (>= 4.2.0) - i18n (0.8.1) + i18n (0.8.4) json (1.8.6) json-schema (2.8.0) addressable (>= 2.4) libv8 (3.16.14.15) loofah (2.0.3) nokogiri (>= 1.5.9) - mail (2.6.5) + mail (2.6.6) mime-types (>= 1.16, < 4) method_source (0.8.2) mime-types (3.1) mime-types-data (~> 3.2015) mime-types-data (3.2016.0521) - mini_portile2 (2.1.0) + mini_portile2 (2.2.0) minitest (5.10.2) - nio4r (2.0.0) - nokogiri (1.6.8.1) - mini_portile2 (~> 2.1.0) + nio4r (2.1.0) + nokogiri (1.8.0) + mini_portile2 (~> 2.2.0) power_assert (0.3.1) rack (2.0.3) rack-test (0.6.3) diff --git a/README.md b/README.md index 0b14a60..7e45f4d 100644 --- a/README.md +++ b/README.md @@ -200,6 +200,58 @@ describe 'Blogs API', swagger_doc: 'v2/swagger.json' do end ``` +### Specifying/Testing API Security ### + +Swagger allows for the specification of different security schemes and their applicability to operations in an API. To leverage this in rswag, you define the schemes globally in _swagger_helper.rb_ and then use the "security" attribute at the operation level to specify which schemes, if any, are applicable to that operation. Swagger supports :basic, :apiKey and :oauth2 scheme types. See [the spec](http://swagger.io/specification/#security-definitions-object-109) for more info. + +```ruby +# spec/swagger_helper.rb +RSpec.configure do |config| + config.swagger_root = Rails.root.to_s + '/swagger' + + config.swagger_docs = { + 'v1/swagger.json' => { + ... + securityDefinitions: { + basic: { + type: :basic + }, + apiKey: { + type: :apiKey, + name: 'api_key', + in: :query + } + } + } + } +end + +# spec/integration/blogs_spec.rb +describe 'Blogs API' do + + path '/blogs' do + + post 'Creates a blog' do + tags 'Blogs' + security [ basic: [] ] + ... + + response '201', 'blog created' do + let(:Authorization) { "Basic #{::Base64.strict_encode64('jsmith:jspass')}" } + run_test! + end + + response '401', 'authentication failed' do + let(:Authorization) { "Basic #{::Base64.strict_encode64('bogus:bogus')}" } + run_test! + end + end + end +end +``` + +__NOTE:__ Depending on the scheme types, you'll be required to assign a corresponding parameter value with each example. For example, :basic auth is required above and so the :Authorization (header) parameter must be set accordingly + ## Configuration & Customization ## The steps described above will get you up and running with minimal setup. However, rswag offers a lot of flexibility to customize as you see fit. Before exploring the various options, you'll need to be aware of it's different components. The following table lists each of them and the files that get added/updated as part of a standard install. diff --git a/rswag-specs/lib/rswag/specs/example_helpers.rb b/rswag-specs/lib/rswag/specs/example_helpers.rb index b7185fb..d669c28 100644 --- a/rswag-specs/lib/rswag/specs/example_helpers.rb +++ b/rswag-specs/lib/rswag/specs/example_helpers.rb @@ -14,7 +14,7 @@ module Rswag api_metadata[:operation][:verb], factory.build_fullpath(self), factory.build_body(self), - factory.build_headers(self) + rackify_headers(factory.build_headers(self)) # Rails test infrastructure requires Rack headers ) else send( @@ -36,6 +36,22 @@ module Rswag private + def rackify_headers(headers) + name_value_pairs = headers.map do |name, value| + [ + case name + when 'Accept' then 'HTTP_ACCEPT' + when 'Content-Type' then 'CONTENT_TYPE' + when 'Authorization' then 'HTTP_AUTHORIZATION' + else name + end, + value + ] + end + + Hash[ name_value_pairs ] + end + def rswag_config ::Rswag::Specs.config end diff --git a/rswag-specs/lib/rswag/specs/request_factory.rb b/rswag-specs/lib/rswag/specs/request_factory.rb index daae7da..2d81aab 100644 --- a/rswag-specs/lib/rswag/specs/request_factory.rb +++ b/rswag-specs/lib/rswag/specs/request_factory.rb @@ -32,13 +32,20 @@ module Rswag end def build_headers(example) - headers = Hash[ parameters_in(:header).map { |p| [ p[:name], example.send(p[:name]).to_s ] } ] - headers.tap do |h| - produces = @api_metadata[:operation][:produces] || @global_metadata[:produces] - consumes = @api_metadata[:operation][:consumes] || @global_metadata[:consumes] - h['ACCEPT'] = produces.join(';') unless produces.nil? - h['CONTENT_TYPE'] = consumes.join(';') unless consumes.nil? + name_value_pairs = parameters_in(:header).map do |param| + [ + param[:name], + example.send(param[:name]).to_s + ] end + + # Add MIME type headers based on produces/consumes metadata + produces = @api_metadata[:operation][:produces] || @global_metadata[:produces] + consumes = @api_metadata[:operation][:consumes] || @global_metadata[:consumes] + name_value_pairs << [ 'Accept', produces.join(';') ] unless produces.nil? + name_value_pairs << [ 'Content-Type', consumes.join(';') ] unless consumes.nil? + + Hash[ name_value_pairs ] end private @@ -52,42 +59,48 @@ module Rswag applicable_params .map { |p| p['$ref'] ? resolve_parameter(p['$ref']) : p } # resolve any references - .concat(resolve_api_key_parameters) + .concat(security_parameters) .select { |p| p[:in] == location } end def resolve_parameter(ref) - defined_params = @global_metadata[:parameters] + defined_params = @global_metadata[:parameters] key = ref.sub('#/parameters/', '') raise "Referenced parameter '#{ref}' must be defined" unless defined_params && defined_params[key] defined_params[key] end - def resolve_api_key_parameters - @api_key_params ||= begin - # First figure out the security requirement applicable to the operation - global_requirements = (@global_metadata[:security] || [] ).map { |r| r.keys.first } - operation_requirements = (@api_metadata[:operation][:security] || [] ).map { |r| r.keys.first } - requirements = global_requirements | operation_requirements - - # Then obtain the scheme definitions for those requirements - definitions = (@global_metadata[:securityDefinitions] || {}).slice(*requirements) - definitions.values.select { |d| d[:type] == :apiKey } + def security_parameters + applicable_security_schemes.map do |scheme| + if scheme[:type] == :apiKey + { name: scheme[:name], type: :string, in: scheme[:in] } + else + { name: 'Authorization', type: :string, in: :header } # use auth header for basic & oauth2 + end end end + def applicable_security_schemes + # First figure out the security requirement applicable to the operation + requirements = @api_metadata[:operation][:security] || @global_metadata[:security] + scheme_names = requirements ? requirements.map { |r| r.keys.first } : [] + + # Then obtain the scheme definitions for those requirements + (@global_metadata[:securityDefinitions] || {}).slice(*scheme_names).values + end + def build_query_string_part(param, value) return "#{param[:name]}=#{value.to_s}" unless param[:type].to_sym == :array name = param[:name] case param[:collectionFormat] - when :ssv + when :ssv "#{name}=#{value.join(' ')}" - when :tsv + when :tsv "#{name}=#{value.join('\t')}" - when :pipes + when :pipes "#{name}=#{value.join('|')}" - when :multi + when :multi value.map { |v| "#{name}=#{v}" }.join('&') else "#{name}=#{value.join(',')}" # csv is default diff --git a/rswag-specs/spec/rswag/specs/request_factory_spec.rb b/rswag-specs/spec/rswag/specs/request_factory_spec.rb index c6791b1..3a0e430 100644 --- a/rswag-specs/spec/rswag/specs/request_factory_spec.rb +++ b/rswag-specs/spec/rswag/specs/request_factory_spec.rb @@ -193,6 +193,33 @@ module Rswag end end + context "global definition for 'basic auth'" do + before do + global_metadata[:securityDefinitions] = { basic_auth: { type: :basic} } + allow(example).to receive(:'Authorization').and_return('Basic foobar') + end + + context 'global requirement' do + before { global_metadata[:security] = [ { basic_auth: [] } ] } + + it "includes a corresponding Authorization header" do + expect(headers).to match( + 'Authorization' => 'Basic foobar' + ) + end + end + + context 'operation-specific requirement' do + before { api_metadata[:operation][:security] = [ { basic_auth: [] } ] } + + it "includes a corresponding Authorization header" do + expect(headers).to match( + 'Authorization' => 'Basic foobar' + ) + end + end + end + context 'consumes & produces' do before do api_metadata[:operation][:consumes] = [ 'application/json', 'application/xml' ] @@ -201,8 +228,8 @@ module Rswag it "includes corresponding 'Accept' & 'Content-Type' headers" do expect(headers).to match( - 'ACCEPT' => 'application/json;application/xml', - 'CONTENT_TYPE' => 'application/json;application/xml' + 'Accept' => 'application/json;application/xml', + 'Content-Type' => 'application/json;application/xml' ) end end @@ -217,8 +244,8 @@ module Rswag it "includes corresponding 'Accept' & 'Content-Type' headers" do expect(headers).to match( - 'ACCEPT' => 'application/json;application/xml', - 'CONTENT_TYPE' => 'application/json;application/xml' + 'Accept' => 'application/json;application/xml', + 'Content-Type' => 'application/json;application/xml' ) end end diff --git a/test-app/app/controllers/application_controller.rb b/test-app/app/controllers/application_controller.rb index a4506fc..4879440 100644 --- a/test-app/app/controllers/application_controller.rb +++ b/test-app/app/controllers/application_controller.rb @@ -1,7 +1,7 @@ class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. - protect_from_forgery with: :exception + protect_from_forgery with: :null_session wrap_parameters format: [ :json ] end diff --git a/test-app/app/controllers/auth_tests_controller.rb b/test-app/app/controllers/auth_tests_controller.rb new file mode 100644 index 0000000..4f90b67 --- /dev/null +++ b/test-app/app/controllers/auth_tests_controller.rb @@ -0,0 +1,13 @@ +class AuthTestsController < ApplicationController + wrap_parameters Blog + respond_to :json + + # POST /auth-tests/basic + def basic + if authenticate_with_http_basic { |u, p| u == 'jsmith' && p == 'jspass' } + head :no_content + else + request_http_basic_authentication + end + end +end diff --git a/test-app/config/routes.rb b/test-app/config/routes.rb index ed6b6ed..d8c676e 100644 --- a/test-app/config/routes.rb +++ b/test-app/config/routes.rb @@ -1,6 +1,8 @@ TestApp::Application.routes.draw do resources :blogs, defaults: { :format => :json } + post 'auth-tests/basic', to: 'auth_tests#basic' + mount Rswag::Api::Engine => 'api-docs' mount Rswag::Ui::Engine => 'api-docs' end diff --git a/test-app/spec/integration/auth_tests_spec.rb b/test-app/spec/integration/auth_tests_spec.rb new file mode 100644 index 0000000..9a6a4f4 --- /dev/null +++ b/test-app/spec/integration/auth_tests_spec.rb @@ -0,0 +1,22 @@ +require 'swagger_helper' + +describe 'Auth Tests API', type: :request, swagger_doc: 'v1/swagger.json' do + + path '/auth-tests/basic' do + post 'Authenticates with basic auth' do + tags 'Auth Test' + operationId 'testBasicAuth' + security [ basic_auth: [] ] + + response '204', 'Valid credentials' do + let(:Authorization) { "Basic #{::Base64.strict_encode64('jsmith:jspass')}" } + run_test! + end + + response '401', 'Invalid credentials' do + let(:Authorization) { "Basic #{::Base64.strict_encode64('foo:bar')}" } + run_test! + end + end + end +end diff --git a/test-app/spec/swagger_helper.rb b/test-app/spec/swagger_helper.rb index f3202ec..91d506c 100644 --- a/test-app/spec/swagger_helper.rb +++ b/test-app/spec/swagger_helper.rb @@ -45,6 +45,9 @@ RSpec.configure do |config| } }, securityDefinitions: { + basic_auth: { + type: :basic + }, api_key: { type: :apiKey, name: 'api_key', diff --git a/test-app/swagger/v1/swagger.json b/test-app/swagger/v1/swagger.json index 7ee0753..0318f94 100644 --- a/test-app/swagger/v1/swagger.json +++ b/test-app/swagger/v1/swagger.json @@ -5,6 +5,30 @@ "version": "v1" }, "paths": { + "/auth-tests/basic": { + "post": { + "summary": "Authenticates with basic auth", + "tags": [ + "Auth Test" + ], + "operationId": "testBasicAuth", + "security": [ + { + "basic_auth": [ + + ] + } + ], + "responses": { + "204": { + "description": "Valid credentials" + }, + "401": { + "description": "Invalid credentials" + } + } + } + }, "/blogs": { "post": { "summary": "Creates a blog", @@ -158,6 +182,9 @@ } }, "securityDefinitions": { + "basic_auth": { + "type": "basic" + }, "api_key": { "type": "apiKey", "name": "api_key", From 8f5cb1aa12ce92fb2807cd053da9323d43017421 Mon Sep 17 00:00:00 2001 From: domaindrivendev Date: Wed, 28 Jun 2017 08:59:15 -0700 Subject: [PATCH 10/10] Reduce depencencies to require Rails components only --- Gemfile | 14 ++-- Gemfile.lock | 136 +++++++++++++++----------------- rswag-api/rswag-api.gemspec | 2 +- rswag-specs/rswag-specs.gemspec | 5 +- rswag-ui/rswag-ui.gemspec | 3 +- 5 files changed, 76 insertions(+), 84 deletions(-) diff --git a/Gemfile b/Gemfile index e642a0f..ab4d32b 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source "https://rubygems.org" # Allow the rails version to come from an ENV setting so Travis can test multiple versions. # See http://www.schneems.com/post/50991826838/testing-against-multiple-rails-versions/ -rails_version = ENV['RAILS_VERSION'] || '5.1.1' +rails_version = ENV['RAILS_VERSION'] || '5.1.2' gem 'rails', "#{rails_version}" @@ -15,6 +15,7 @@ end gem 'sqlite3' +gem 'rswag-specs', path: './rswag-specs' gem 'rswag-api', path: './rswag-api' gem 'rswag-ui', path: './rswag-ui' @@ -27,10 +28,9 @@ group :test do gem 'generator_spec' gem 'capybara' gem 'capybara-webkit' - gem 'rswag-specs', path: './rswag-specs' -end - -group :assets do - gem 'uglifier' - gem 'therubyracer' end +# +#group :assets do +# gem 'uglifier' +# gem 'therubyracer' +#end diff --git a/Gemfile.lock b/Gemfile.lock index 132eeed..23039f2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,90 +2,89 @@ PATH remote: rswag-api specs: rswag-api (1.3.0) - rails (>= 3.1, < 5.2) + railties (>= 3.1) PATH remote: rswag-specs specs: rswag-specs (1.3.0) - json (~> 1.8) + activesupport (>= 3.1) json-schema (~> 2.2) - rails (>= 3.1, < 5.2) - rspec-rails (>= 2.14, < 4) + railties (>= 3.1) PATH remote: rswag-ui specs: rswag-ui (1.3.0) - rails (>= 3.1, < 5.2) + actionpack (>= 3.1) + railties (>= 3.1) GEM remote: https://rubygems.org/ specs: - actioncable (5.1.1) - actionpack (= 5.1.1) + actioncable (5.1.2) + actionpack (= 5.1.2) nio4r (~> 2.0) websocket-driver (~> 0.6.1) - actionmailer (5.1.1) - actionpack (= 5.1.1) - actionview (= 5.1.1) - activejob (= 5.1.1) + actionmailer (5.1.2) + actionpack (= 5.1.2) + actionview (= 5.1.2) + activejob (= 5.1.2) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.1.1) - actionview (= 5.1.1) - activesupport (= 5.1.1) + actionpack (5.1.2) + actionview (= 5.1.2) + activesupport (= 5.1.2) rack (~> 2.0) rack-test (~> 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.1.1) - activesupport (= 5.1.1) + actionview (5.1.2) + activesupport (= 5.1.2) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (5.1.1) - activesupport (= 5.1.1) + activejob (5.1.2) + activesupport (= 5.1.2) globalid (>= 0.3.6) - activemodel (5.1.1) - activesupport (= 5.1.1) - activerecord (5.1.1) - activemodel (= 5.1.1) - activesupport (= 5.1.1) + activemodel (5.1.2) + activesupport (= 5.1.2) + activerecord (5.1.2) + activemodel (= 5.1.2) + activesupport (= 5.1.2) arel (~> 8.0) - activesupport (5.1.1) + activesupport (5.1.2) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (~> 0.7) minitest (~> 5.1) tzinfo (~> 1.1) - addressable (2.4.0) + addressable (2.5.1) + public_suffix (~> 2.0, >= 2.0.2) arel (8.0.0) builder (3.2.3) - capybara (2.10.1) + capybara (2.13.0) addressable mime-types (>= 1.16) nokogiri (>= 1.3.3) rack (>= 1.0.0) rack-test (>= 0.5.4) xpath (~> 2.0) - capybara-webkit (1.1.0) - capybara (~> 2.0, >= 2.0.2) + capybara-webkit (1.14.0) + capybara (>= 2.3.0, < 2.14.0) json concurrent-ruby (1.0.5) - diff-lcs (1.2.5) - erubi (1.6.0) - execjs (2.7.0) - generator_spec (0.9.3) + diff-lcs (1.3) + erubi (1.6.1) + generator_spec (0.9.4) activesupport (>= 3.0.0) railties (>= 3.0.0) globalid (0.4.0) activesupport (>= 4.2.0) i18n (0.8.4) - json (1.8.6) + json (2.1.0) json-schema (2.8.0) addressable (>= 2.4) - libv8 (3.16.14.15) loofah (2.0.3) nokogiri (>= 1.5.9) mail (2.6.6) @@ -99,55 +98,55 @@ GEM nio4r (2.1.0) nokogiri (1.8.0) mini_portile2 (~> 2.2.0) - power_assert (0.3.1) + power_assert (1.0.2) + public_suffix (2.0.5) rack (2.0.3) rack-test (0.6.3) rack (>= 1.0) - rails (5.1.1) - actioncable (= 5.1.1) - actionmailer (= 5.1.1) - actionpack (= 5.1.1) - actionview (= 5.1.1) - activejob (= 5.1.1) - activemodel (= 5.1.1) - activerecord (= 5.1.1) - activesupport (= 5.1.1) + rails (5.1.2) + actioncable (= 5.1.2) + actionmailer (= 5.1.2) + actionpack (= 5.1.2) + actionview (= 5.1.2) + activejob (= 5.1.2) + activemodel (= 5.1.2) + activerecord (= 5.1.2) + activesupport (= 5.1.2) bundler (>= 1.3.0, < 2.0) - railties (= 5.1.1) + railties (= 5.1.2) sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) rails-html-sanitizer (1.0.3) loofah (~> 2.0) - railties (5.1.1) - actionpack (= 5.1.1) - activesupport (= 5.1.1) + railties (5.1.2) + actionpack (= 5.1.2) + activesupport (= 5.1.2) method_source rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rake (12.0.0) - ref (2.0.0) responders (2.4.0) actionpack (>= 4.2.0, < 5.3) railties (>= 4.2.0, < 5.3) - rspec-core (3.5.4) - rspec-support (~> 3.5.0) - rspec-expectations (3.5.0) + rspec-core (3.6.0) + rspec-support (~> 3.6.0) + rspec-expectations (3.6.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.5.0) - rspec-mocks (3.5.0) + rspec-support (~> 3.6.0) + rspec-mocks (3.6.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.5.0) - rspec-rails (3.5.2) + rspec-support (~> 3.6.0) + rspec-rails (3.6.0) actionpack (>= 3.0) activesupport (>= 3.0) railties (>= 3.0) - rspec-core (~> 3.5.0) - rspec-expectations (~> 3.5.0) - rspec-mocks (~> 3.5.0) - rspec-support (~> 3.5.0) - rspec-support (3.5.0) + rspec-core (~> 3.6.0) + rspec-expectations (~> 3.6.0) + rspec-mocks (~> 3.6.0) + rspec-support (~> 3.6.0) + rspec-support (3.6.0) sprockets (3.7.1) concurrent-ruby (~> 1.0) rack (> 1, < 3) @@ -155,22 +154,17 @@ GEM actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) - sqlite3 (1.3.12) - test-unit (3.2.1) + sqlite3 (1.3.13) + test-unit (3.2.5) power_assert - therubyracer (0.12.2) - libv8 (~> 3.16.14.0) - ref thor (0.19.4) thread_safe (0.3.6) tzinfo (1.2.3) thread_safe (~> 0.1) - uglifier (3.0.2) - execjs (>= 0.3.0, < 3) websocket-driver (0.6.5) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.2) - xpath (2.0.0) + xpath (2.1.0) nokogiri (~> 1.3) PLATFORMS @@ -180,7 +174,7 @@ DEPENDENCIES capybara capybara-webkit generator_spec - rails (= 5.1.1) + rails (= 5.1.2) responders rspec-rails rswag-api! @@ -188,8 +182,6 @@ DEPENDENCIES rswag-ui! sqlite3 test-unit - therubyracer - uglifier BUNDLED WITH 1.14.6 diff --git a/rswag-api/rswag-api.gemspec b/rswag-api/rswag-api.gemspec index 19ba7f0..80ec270 100644 --- a/rswag-api/rswag-api.gemspec +++ b/rswag-api/rswag-api.gemspec @@ -16,5 +16,5 @@ Gem::Specification.new do |s| s.files = Dir["{lib}/**/*"] + ["MIT-LICENSE", "Rakefile"] - s.add_dependency "rails", ">= 3.1", "< 5.2" + s.add_dependency 'railties', '>= 3.1' end diff --git a/rswag-specs/rswag-specs.gemspec b/rswag-specs/rswag-specs.gemspec index 17daaab..7c21c7f 100644 --- a/rswag-specs/rswag-specs.gemspec +++ b/rswag-specs/rswag-specs.gemspec @@ -16,8 +16,7 @@ Gem::Specification.new do |s| s.files = Dir["{lib}/**/*"] + ["MIT-LICENSE", "Rakefile" ] - s.add_dependency "rails", ">= 3.1", "< 5.2" - s.add_dependency 'json', '~> 1.8' + s.add_dependency 'activesupport', '>= 3.1' + s.add_dependency 'railties', '>= 3.1' s.add_dependency 'json-schema', '~> 2.2' - s.add_dependency 'rspec-rails', '>= 2.14', '< 4' end diff --git a/rswag-ui/rswag-ui.gemspec b/rswag-ui/rswag-ui.gemspec index edbbf82..95f9bc2 100644 --- a/rswag-ui/rswag-ui.gemspec +++ b/rswag-ui/rswag-ui.gemspec @@ -16,5 +16,6 @@ Gem::Specification.new do |s| s.files = Dir["{app,config,lib,vendor}/**/*"] + ["MIT-LICENSE", "Rakefile" ] - s.add_dependency "rails", ">= 3.1", "< 5.2" + s.add_dependency 'actionpack', '>=3.1' + s.add_dependency 'railties', '>= 3.1' end