10 Commits

Author SHA1 Message Date
Blake Erickson
989aab656f Revert "Add a macro for complexes multiparts" 2021-03-06 14:52:49 -07:00
Blake Erickson
f7036b7e5a Merge pull request #300 from sobrinho/master
Add a macro for complexes multiparts
2021-03-06 10:22:54 -07:00
Blake Erickson
84ab7a9e4c Merge pull request #405 from gogainda/master
Add Truffleruby head to CI
2021-03-06 10:01:05 -07:00
Blake Erickson
0169fbab66 Merge pull request #404 from Wolfer/patch-1
Allow use #/components/parameters and other in inherited $refs
2021-03-06 09:58:10 -07:00
Blake Erickson
4c42ad5f97 Merge pull request #406 from mynnx/specs-print-failed-body
Show the response body for comparison when schema checks fail
2021-03-06 09:30:48 -07:00
Blake Erickson
b91b6e5f1e Fix bundler warning
Move rswag-specs under development and test to resolve this warning:

```
Your Gemfile lists the gem rswag-specs (>= 0) more than once.
You should probably keep only one of them.
Remove any duplicate entries and specify the gem only once.
While it's not a problem now, it could cause errors if you change the version of one of them later.
```
2021-03-05 21:34:00 -07:00
mynnx
a34c931bb6 Show the response body for comparison when schema checks fail 2021-03-03 16:32:16 -08:00
Igor Victor
4b7ab9d381 Add Truffleruby head to CI 2021-02-26 17:58:30 +01:00
Serg F
3d3d93f3ab Allow use #/components/parameters and other in inherited $refs 2021-02-19 15:15:44 +03:00
Gabriel Sobrinho
f8dbd98bbc Add a macro for complexes multiparts
This will allow to describe multipart in a short way, like JSON payload:

Before:

    put 'Creates a blog with thumbnail' do
      consumes 'multipart/form-data'
      parameter name: :title, in: :formData, type: :string, required: true
      parameter name: :content, in: :formData, type: :string, required: true
      parameter name: :file, in: :formData, type: :file, required: true

      let(:blog) { FactoryBot.build(:blog) }
      let(:title) { blog.title }
      let(:content) { blog.content }
      let(:file) { blog.file }

      ...
    end

After:

    put 'Creates a blog with thumbnail' do
      consumes 'multipart/form-data'
      parameter name: :blog, in: :formData, schema: { '$ref' => '#/definitions/blog' }

      let(:blog) { FactoryBot.attributes_for(:blog) }

      ...
    end

Your mileage may vary but you can always choose the best option.
2020-04-16 22:38:35 -03:00
3 changed files with 11 additions and 5 deletions

View File

@@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ruby: [2.6, 2.7]
ruby: [2.6, 2.7, truffleruby-head]
rails: [5.2.4.4, 6.0.3.4]
env:
RAILS_VERSION: ${{ matrix.rails }}

View File

@@ -25,18 +25,20 @@ end
gem 'rswag-api', path: './rswag-api'
gem 'rswag-ui', path: './rswag-ui'
group :development, :test do
gem 'rswag-specs', path: './rswag-specs'
end
group :test do
gem 'capybara'
gem 'geckodriver-helper'
gem 'generator_spec'
gem 'rspec-rails'
gem 'selenium-webdriver'
gem 'rswag-specs', path: './rswag-specs'
gem 'test-unit'
end
group :development do
gem 'rswag-specs', path: './rswag-specs'
gem 'rubocop'
end

View File

@@ -50,7 +50,11 @@ module Rswag
.merge(schemas)
errors = JSON::Validator.fully_validate(validation_schema, body)
raise UnexpectedResponse, "Expected response body to match schema: #{errors[0]}" if errors.any?
return unless errors.any?
raise UnexpectedResponse,
"Expected response body to match schema: #{errors[0]}\n" \
"Response body: #{JSON.pretty_generate(JSON.parse(body))}"
end
def definitions_or_component_schemas(swagger_doc, version)
@@ -62,7 +66,7 @@ module Rswag
swagger_doc.slice(:definitions)
else
components = swagger_doc[:components] || {}
{ components: { schemas: components[:schemas] } }
{ components: components }
end
end
end