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/.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/.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 60d9c8b..8697be9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,56 +1,67 @@ PATH - remote: ./rswag-api + remote: rswag-api specs: - rswag-api (1.2.0) - rails (>= 3.1, < 5.1) + rswag-api (1.2.1) + rails (>= 3.1, < 5.2) 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) + 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) + rswag-ui (1.2.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) @@ -61,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) @@ -127,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) @@ -161,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/README.md b/README.md index 228168c..237e976 100644 --- a/README.md +++ b/README.md @@ -103,6 +103,17 @@ If you've used [Swagger](http://swagger.io/specification) before, then the synta Take special note of the __run_test!__ method that's called within each response block. This tells rswag to create and execute a corresponding example. It builds and submits a request based on parameter descriptions and corresponding values that have been provided using the rspec "let" syntax. For example, the "post" description in the example above specifies a "body" parameter called "blog". It also lists 2 different responses. For the success case (i.e. the 201 response), notice how "let" is used to set the blog parameter to a value that matches the provided schema. For the failure case (i.e. the 422 response), notice how it's set to a value that does not match the provided schema. When the test is executed, rswag also validates the actual response code and, where applicable, the response body against the provided [JSON Schema](http://json-schema.org/documentation.html). +If you want to do additional validation on the response, pass a block to the __run_test!__ method: + +```ruby +response '201', 'blog created' do + run_test! do |response| + data = JSON.parse(response.body) + expect(data['title']).to eq('foo') + end +end +``` + If you'd like your specs to be a little more explicit about what's going on here, you can replace the call to __run_test!__ with equivalent "before" and "it" blocks: ```ruby 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-api/rswag-api.gemspec b/rswag-api/rswag-api.gemspec index 5275ea2..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.1" + s.add_dependency "rails", ">= 3.1", "< 5.2" end diff --git a/rswag-specs/lib/rswag/specs/example_group_helpers.rb b/rswag-specs/lib/rswag/specs/example_group_helpers.rb index cb96e71..ed7b20f 100644 --- a/rswag-specs/lib/rswag/specs/example_group_helpers.rb +++ b/rswag-specs/lib/rswag/specs/example_group_helpers.rb @@ -69,7 +69,7 @@ module Rswag metadata[:response][:examples] = example end - def run_test! + def run_test!(&block) # NOTE: rspec 2.x support if RSPEC_VERSION < 3 before do @@ -77,7 +77,7 @@ module Rswag end it "returns a #{metadata[:response][:code]} response" do - assert_response_matches_metadata(example.metadata) + assert_response_matches_metadata(example.metadata, &block) end else before do |example| @@ -85,7 +85,7 @@ module Rswag end it "returns a #{metadata[:response][:code]} response" do |example| - assert_response_matches_metadata(example.metadata) + assert_response_matches_metadata(example.metadata, &block) end end end diff --git a/rswag-specs/lib/rswag/specs/example_helpers.rb b/rswag-specs/lib/rswag/specs/example_helpers.rb index b9850ce..b7185fb 100644 --- a/rswag-specs/lib/rswag/specs/example_helpers.rb +++ b/rswag-specs/lib/rswag/specs/example_helpers.rb @@ -28,10 +28,10 @@ module Rswag end end - def assert_response_matches_metadata(api_metadata) + def assert_response_matches_metadata(api_metadata, &block) global_metadata = rswag_config.get_swagger_doc(api_metadata[:swagger_doc]) validator = ResponseValidator.new(api_metadata, global_metadata) - validator.validate!(response) + validator.validate!(response, &block) end private diff --git a/rswag-specs/lib/rswag/specs/extended_schema.rb b/rswag-specs/lib/rswag/specs/extended_schema.rb index 493a27a..62eb4ee 100644 --- a/rswag-specs/lib/rswag/specs/extended_schema.rb +++ b/rswag-specs/lib/rswag/specs/extended_schema.rb @@ -3,6 +3,7 @@ require 'json-schema' module Rswag module Specs class ExtendedSchema < JSON::Schema::Draft4 + def initialize super @attributes['type'] = ExtendedTypeAttribute @@ -12,6 +13,7 @@ module Rswag 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 diff --git a/rswag-specs/lib/rswag/specs/response_validator.rb b/rswag-specs/lib/rswag/specs/response_validator.rb index 7212a3f..7194953 100644 --- a/rswag-specs/lib/rswag/specs/response_validator.rb +++ b/rswag-specs/lib/rswag/specs/response_validator.rb @@ -1,5 +1,6 @@ require 'active_support/core_ext/hash/slice' require 'json-schema' +require 'json' require 'rswag/specs/extended_schema' module Rswag @@ -11,10 +12,11 @@ module Rswag @global_metadata = global_metadata end - def validate!(response) + def validate!(response, &block) validate_code!(response.code) validate_headers!(response.headers) - validate_body!(response.body) + validate_body!(response.body, &block) + block.call(response) if block_given? end private 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-specs/rswag-specs.gemspec b/rswag-specs/rswag-specs.gemspec index 6bfd38b..17daaab 100644 --- a/rswag-specs/rswag-specs.gemspec +++ b/rswag-specs/rswag-specs.gemspec @@ -16,7 +16,8 @@ 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' end diff --git a/rswag-specs/spec/rswag/specs/response_validator_spec.rb b/rswag-specs/spec/rswag/specs/response_validator_spec.rb index 286940d..cb95996 100644 --- a/rswag-specs/spec/rswag/specs/response_validator_spec.rb +++ b/rswag-specs/spec/rswag/specs/response_validator_spec.rb @@ -29,7 +29,7 @@ module Rswag api_metadata[:response][:schema] = { type: 'object', properties: { text: { type: 'string' } }, - required: [ 'text' ] + required: ['text'] } end @@ -42,6 +42,25 @@ module Rswag let(:response) { OpenStruct.new(code: 200, body: "{\"foo\":\"Some comment\"}") } it { expect { call }.to raise_error UnexpectedResponse } end + + context "'block' provided" do + let(:call) do + subject.validate!(response) do |response| + data = JSON.parse(response.body) + expect(data['text']).to eq('Some comment') + end + end + + context 'the block validation passes' do + let(:response) { OpenStruct.new(code: 200, body: "{\"text\":\"Some comment\"}") } + it { expect { call }.to_not raise_error } + end + + context 'the block validation fails' do + let(:response) { OpenStruct.new(code: 200, body: "{\"text\":\"Some other comment\"}") } + it { expect { call }.to raise_error(RSpec::Expectations::ExpectationNotMetError) } + end + end end context "referenced 'schema' provided" do @@ -51,7 +70,7 @@ module Rswag author: { type: 'object', properties: { name: { type: 'string' } }, - required: [ 'name' ] + required: ['name'] } } end 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 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-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/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 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/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..cea4d93 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", limit: 255 + t.text "content" + 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": [