46 Commits
2.0.2 ... 2.0.6

Author SHA1 Message Date
Greg Myers
f4ba3266ba Merge pull request #235 from BookOfGreg/doc/update-contrib
Update contributing instructions. Add changelog
2019-10-03 22:46:41 +01:00
Greg Myers
a3aa56e2df Add a message on how to release to contributing guide 2019-10-03 22:37:48 +01:00
Greg Myers
3329c1ec55 Add Changelog
Fix #38
2019-10-02 14:10:18 +01:00
Greg Myers
8bdf3eac08 Update the contributing doc, referencing the CI files 2019-10-02 13:50:56 +01:00
Greg Myers
ed25ff36e6 Merge pull request #210 from olleolleolle/patch-1
CONTRIBUTING: Correct URL
2019-09-30 21:54:54 +01:00
Greg Myers
7df00dde94 Merge pull request #227 from biow0lf/biow0lf-patch-1
Fix typo
2019-09-30 21:12:11 +01:00
Greg Myers
2a8c0cee4b Merge pull request #234 from rswag/BookOfGreg-patch-1
Update README.md
2019-09-30 21:09:23 +01:00
Greg Myers
e03af84262 Merge pull request #228 from thiagopradi/rails-6-full-support
Rails 6 Support
2019-09-30 21:09:04 +01:00
Greg Myers
b7a6b2de8b Update README.md
Repoint readme links
2019-09-30 21:06:14 +01:00
Thiago Pradi
4bdbd7ed98 Use updated ruby on CI too 2019-09-23 23:03:09 -03:00
Thiago Pradi
6c684729d1 Use updated ruby version 2019-09-23 22:56:24 -03:00
Thiago Pradi
81f8e0dbaf Removing Rails 3/4 - they are not supported by the Rails Core Team 2019-08-25 23:19:03 -03:00
Thiago Pradi
91a0f88eb5 Use different Sqlite versions for Rails versions 2019-08-25 23:11:57 -03:00
Thiago Pradi
586d0211ff Force SQlite 1.3 version 2019-08-25 23:06:19 -03:00
Thiago Pradi
d379338017 Enforce SQlite version 2019-08-25 23:00:07 -03:00
Thiago Pradi
7179802fe0 Using alternative config for xfvb 2019-08-25 22:50:28 -03:00
Thiago Pradi
16458d458a Adding extra lib to fix build 2019-08-25 22:45:12 -03:00
Thiago Pradi
621d6f4754 Updating travis file and adding Rails 6 to build matrix 2019-08-25 22:37:22 -03:00
Thiago Pradi
ac65dc1780 Gemfile / gemspec files compatible with Rails 6 2019-08-25 22:36:14 -03:00
Igor Zubkov
a00145c1f7 Fix typo 2019-08-20 16:51:27 +03:00
Olle Jonsson
f969fb6573 CONTRIBUTING: Correct URL 2019-04-17 14:46:26 +02:00
Richard Morris
10bb732148 Merge pull request #177 from FormAPI/show_response_body_for_invalid_code
Show response body when the response code is unexpected.
2019-04-08 12:25:28 +01:00
Richard Morris
c74c88fd46 Merge pull request #176 from BookOfGreg/patch-1
Update swagger_helper.rb
2019-04-08 12:24:54 +01:00
Richard Morris
9cb187192d Merge pull request #23 from drewish/contributing
Add a contributing file
2019-04-08 12:17:32 +01:00
Richard Morris
636cdcd8b3 Merge pull request #92 from seriousbee/add-section-on-formatting-to-RM
Updated Readme.md:
2019-04-08 12:17:05 +01:00
Nathan Broadbent
e381bf85d4 Show response body when the response code is unexpected. Makes it much easier to debug test failures 2018-12-22 15:20:49 +07:00
Greg Myers
9642937ee2 Update swagger_helper.rb
Use standard filesystem helpers to avoid OS specific slash errors.
2018-12-18 13:29:40 +00:00
Richard Morris
a50bf616b9 Merge pull request #156 from earksiinni/patch-1
Fix installation instructions for separate gems
2018-10-09 15:02:44 -07:00
Ersin Akinci
d69aa16985 Fix installation instructions for separate gems 2018-10-09 13:44:58 -07:00
Richard Morris
4d1f5f831b Merge pull request #150 from MSanteler/master
Update comment in swagger_helper template
2018-09-19 16:24:18 -07:00
Matthew Santeler
aa8f16070d Update comment in swagger_helper template 2018-09-19 15:24:16 -04:00
Richard Morris
6fc9faab57 Reflect swagger-ui upgrade in readme 2018-07-11 09:01:50 -07:00
Richard Morris
5ea1670d79 Merge pull request #136 from ledermann/upgrade-swagger-ui-to-3-17-3
Upgrade Swagger UI to 3.17.3
2018-07-10 07:53:01 -07:00
Georg Ledermann
00aa08bb22 ⬆️ Upgrade "swagger-ui" to 3.17.3 2018-07-10 14:49:12 +02:00
Richard Morris
ef91e087d3 Update compatibility chart to reflect realty 2018-06-21 23:27:57 -07:00
Richard Morris
be6def33ac Merge pull request #134 from ledermann/upgrade-swagger-ui-to-3-17-1
Upgrade Swagger UI to 3.17.1
2018-06-21 07:34:15 -07:00
Georg Ledermann
6b04c72cc9 ⬆️ Upgrade "swagger-ui" to 3.17.1 2018-06-21 09:11:06 +02:00
Richard Morris
890a31e749 Merge pull request #129 from hoshinotsuyoshi/fix_typo_readme
Fix typo in README
2018-05-30 18:16:01 -07:00
hoshinotsuyoshi
862ea53cf4 Fix typo in README
Fixed Gemfile example.
2018-05-31 08:54:12 +09:00
Richard Morris
254ade95db Update README.md 2018-05-24 20:28:17 -07:00
Richard Morris
b9f71fe9b1 Merge pull request #117 from imRohan/master
Fixed typos in the swagger_helper.rb file
2018-05-24 20:00:10 -07:00
Richard Morris
870d467046 Merge pull request #125 from indocomsoft/patch-1
Fix travis to not cleanup when publishing rswag-ui
2018-05-24 19:59:56 -07:00
Julius Putra Tanu Setiaji
334671cb95 Fix travis to not cleanup when publishing rswag-ui
This is to keep `node_modules` directory.
2018-05-25 10:05:48 +08:00
Rohan Likhite
fee3b3bb84 fixed typos in the swagger_helper.rb file 2018-03-29 11:42:36 -04:00
Tomasz Czernuszenko
3eda72155a Updated Readme.md:
Added a section on markdown formatting and and clarified some descriptions of API versioning
2017-08-07 14:12:40 +01:00
andrew morton
4842055ee6 Add a contributing file
The exact sequence of commands to be able to run the tests wasn't obvious
to me so I'm assumiing others could use a hand.

I used the factory_girl_rails gem's file as a starting point.
2016-09-13 06:47:01 -06:00
15 changed files with 171 additions and 45 deletions

View File

@@ -1 +1 @@
2.3.1
2.6.4

View File

@@ -1,24 +1,28 @@
language: ruby
dist: xenial
services:
- xvfb
rvm:
- 2.2.5
- 2.6.4
env:
- RAILS_VERSION=6.0.0
- RAILS_VERSION=5.2.0
- RAILS_VERSION=4.2.0
- RAILS_VERSION=3.2.22
addons:
apt:
packages:
- libqtwebkit-dev
- libqtwebkit4
cache:
directories:
- /home/travis/.rvm/gems/ruby-2.2.5
- /home/travis/.rvm/gems/ruby-2.6.4
install: ./ci/build.sh
before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- sleep 3
script: ./ci/test.sh
jobs:
@@ -49,6 +53,7 @@ jobs:
gemspec: rswag-ui.gemspec
provider: rubygems
api_key: $RUBYGEMS_API_KEY
skip_cleanup: true
on:
branch: master
tags: true

26
CHANGELOG.md Normal file
View File

@@ -0,0 +1,26 @@
# rswag
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Added
### Changed
### Deprecated
### Removed
### Fixed
### Security
## [2.0.6] - 2019-10-03
### Added
- Support for Rails 6 [#228](https://github.com/rswag/rswag/pull/228)
- Support for Windows paths [#176](https://github.com/rswag/rswag/pull/176)
### Changed
- Show response body when error code is not expected [#117](https://github.com/rswag/rswag/pull/177)
### Deprecated
### Removed
### Fixed
### Security
## [2.0.5] - 2018-07-10

59
CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,59 @@
# Contributing
## Fork, then clone the repo:
```
git clone git@github.com:rswag/rswag.git
cd rswag
```
## Build
Set up your machine:
```
./ci/build.sh
```
Or manually
```
bundle
cd test-app
bundle exec rake db:setup
cd -
cd rswag-ui
npm install
cd -
```
## Test
Make sure the tests pass:
```
./ci/test.sh
```
or manually
```
cd test-app
bundle exec rspec
```
Make your change. Add tests for your change. Make the tests pass:
```
bundle exec rspec
```
Push to your fork and [submit a Pull Request][pr].
[pr]: https://github.com/rswag/rswag/compare/
## Release
(for maintainers)
Update the changelog.md, putting the new version number in and moving the Unreleased marker.
Merge the changes into master you wish to release.
Add and push a new git tag, annotated tags preferred:
```
git tag -s 2.0.6 -m 'v2.0.6'
```
Travis will detect the tag and release all gems with that tag version number.

View File

@@ -9,11 +9,16 @@ gem 'rails', "#{rails_version}"
case rails_version.split('.').first
when '3'
gem 'strong_parameters'
when '4', '5'
when '4', '5', '6'
gem 'responders'
end
gem 'sqlite3'
case rails_version.split('.').first
when '3', '4', '5'
gem 'sqlite3', '~> 1.3.6'
when '6'
gem 'sqlite3', '~> 1.4.1'
end
gem 'rswag-api', path: './rswag-api'
gem 'rswag-ui', path: './rswag-ui'

View File

@@ -1,6 +1,6 @@
rswag (formerly swagger_rails)
rswag
=========
[![Build Status](https://travis-ci.org/domaindrivendev/rswag.svg?branch=master)](https://travis-ci.org/domaindrivendev/rswag)
[![Build Status](https://travis-ci.org/rswag/rswag.svg?branch=master)](https://travis-ci.org/rswag/rswag)
[Swagger](http://swagger.io) tooling for Rails API's. Generate beautiful API documentation, including a UI to explore and test operations, directly from your rspec integration tests.
@@ -14,9 +14,9 @@ Once you have an API that can describe itself in Swagger, you've opened the trea
|Rswag Version|Swagger (OpenAPI) Spec.|swagger-ui|
|----------|----------|----------|
|[master](https://github.com/domaindrivendev/rswag/tree/master)|2.0|3.13.2|
|[2.0.0](https://github.com/domaindrivendev/rswag/tree/2.0.0)|2.0|3.13.2|
|[1.6.0](https://github.com/domaindrivendev/rswag/tree/1.6.0)|2.0|2.2.5|
|[master](https://github.com/rswag/rswag/tree/master)|2.0|3.17.3|
|[2.0.5](https://github.com/rswag/rswag/tree/2.0.4)|2.0|3.17.3|
|[1.6.0](https://github.com/rswag/rswag/tree/1.6.0)|2.0|2.2.5|
## Getting Started ##
@@ -33,7 +33,7 @@ Once you have an API that can describe itself in Swagger, you've opened the trea
gem 'rswag-api'
gem 'rswag-ui'
groups :test do
group :test do
gem 'rspec-rails'
gem 'rswag-specs'
end
@@ -44,6 +44,13 @@ Once you have an API that can describe itself in Swagger, you've opened the trea
```ruby
rails g rswag:install
```
Or run the install generators for each package separately if you installed Rswag as separate gems, as indicated above:
```ruby
rails g rswag:api:install rswag:ui:install
RAILS_ENV=test rails g rswag:specs:install
```
3. Create an integration spec to describe and test your API.
@@ -195,7 +202,8 @@ RSpec.configure do |config|
swagger: '2.0',
info: {
title: 'API V1',
version: 'v1'
version: 'v1',
description: 'This is the first version of my API'
},
basePath: '/api/v1'
},
@@ -204,7 +212,8 @@ RSpec.configure do |config|
swagger: '2.0',
info: {
title: 'API V2',
version: 'v2'
version: 'v2',
description: 'This is the second version of my API'
},
basePath: '/api/v2'
}
@@ -212,7 +221,8 @@ RSpec.configure do |config|
end
```
__NOTE__: By default, the paths, operations and responses defined in your spec files will be associated with the first Swagger document in _swagger_helper.rb_. If you're using multiple documents, you'll need to tag the individual specs with their target document name:
#### Supporting multiple versions of API ####
By default, the paths, operations and responses defined in your spec files will be associated with the first Swagger document in _swagger_helper.rb_. If your API has multiple versions, you should be using separate documents to describe each of them. In order to assign a file with a given version of API, you'll need to add the ```swagger_doc``` tag to each spec specifying its target document name:
```ruby
# spec/integration/v2/blogs_spec.rb
@@ -226,6 +236,25 @@ describe 'Blogs API', swagger_doc: 'v2/swagger.json' do
end
```
#### Formatting the description literals: ####
Swagger supports the Markdown syntax to format strings. This can be especially handy if you were to provide a long description of a given API version or endpoint. Use [this guide](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) for reference.
__NOTE:__ There is one difference between the official Markdown syntax and Swagger interpretation, namely tables. To create a table like this:
| Column1 | Collumn2 |
| ------- | -------- |
| cell1 | cell2 |
you should use the folowing syntax, making sure there are no whitespaces at the start of any of the lines:
```

| Column1 | Collumn2 |
| ------- | -------- |
| cell1 | cell2 |

```
### 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.
@@ -457,7 +486,7 @@ Rswag::Api.configure do |c|
end
```
Note how the filter is passed the rack env for the current request. This provides a lot of flexibilty. For example, you can assign the "host" property (as shown) or you could inspect session information or an Authoriation header and remove operations based on user permissions.
Note how the filter is passed the rack env for the current request. This provides a lot of flexibilty. For example, you can assign the "host" property (as shown) or you could inspect session information or an Authorization header and remove operations based on user permissions.
### Enable Swagger Endpoints for swagger-ui ###

View File

@@ -13,5 +13,5 @@ Gem::Specification.new do |s|
s.files = Dir["{lib}/**/*"] + ["MIT-LICENSE", "Rakefile"]
s.add_dependency 'railties', '>= 3.1', '< 6.0'
s.add_dependency 'railties', '>= 3.1', '< 6.1'
end

View File

@@ -3,11 +3,11 @@ require 'rails_helper'
RSpec.configure do |config|
# Specify a root folder where Swagger JSON files are generated
# NOTE: If you're using the rswag-api to serve API descriptions, you'll need
# to ensure that it's confiugred to server Swagger from the same folder
config.swagger_root = Rails.root.to_s + '/swagger'
# to ensure that it's configured to serve Swagger from the same folder
config.swagger_root = Rails.root.join('swagger').to_s
# Define one or more Swagger documents and provide global metadata for each one
# When you run the 'rswag:specs:to_swagger' rake task, the complete Swagger will
# When you run the 'rswag:specs:swaggerize' rake task, the complete Swagger will
# be generated at the provided relative path under swagger_root
# By default, the operations defined in spec files are added to the first
# document below. You can override this behavior by adding a swagger_doc tag to the

View File

@@ -14,17 +14,19 @@ module Rswag
def validate!(metadata, response)
swagger_doc = @config.get_swagger_doc(metadata[:swagger_doc])
validate_code!(metadata, response.code)
validate_code!(metadata, response)
validate_headers!(metadata, response.headers)
validate_body!(metadata, swagger_doc, response.body)
end
private
def validate_code!(metadata, code)
def validate_code!(metadata, response)
expected = metadata[:response][:code].to_s
if code != expected
raise UnexpectedResponse, "Expected response code '#{code}' to match '#{expected}'"
if response.code != expected
raise UnexpectedResponse,
"Expected response code '#{response.code}' to match '#{expected}'\n" \
"Response body: #{response.body}"
end
end

View File

@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
s.files = Dir["{lib}/**/*"] + ["MIT-LICENSE", "Rakefile" ]
s.add_dependency 'activesupport', '>= 3.1', '< 6.0'
s.add_dependency 'railties', '>= 3.1', '< 6.0'
s.add_dependency 'activesupport', '>= 3.1', '< 6.1'
s.add_dependency 'railties', '>= 3.1', '< 6.1'
s.add_dependency 'json-schema', '~> 2.2'
end

View File

@@ -5,9 +5,9 @@
"requires": true,
"dependencies": {
"swagger-ui-dist": {
"version": "3.13.2",
"resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-3.13.2.tgz",
"integrity": "sha1-EL9SK9J0q2SU0r0Nuvn+2ibbHKI="
"version": "3.17.3",
"resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-3.17.3.tgz",
"integrity": "sha1-37lkCMzEZ3UVX3NpGQxdSyAW/lw="
}
}
}

View File

@@ -3,6 +3,6 @@
"version": "1.0.0",
"private": true,
"dependencies": {
"swagger-ui-dist": "3.13.2"
"swagger-ui-dist": "3.17.3"
}
}

View File

@@ -13,6 +13,6 @@ Gem::Specification.new do |s|
s.files = Dir.glob("{lib,node_modules}/**/*") + ["MIT-LICENSE", "Rakefile" ]
s.add_dependency 'actionpack', '>=3.1', '< 6.0'
s.add_dependency 'railties', '>= 3.1', '< 6.0'
s.add_dependency 'actionpack', '>=3.1', '< 6.1'
s.add_dependency 'railties', '>= 3.1', '< 6.1'
end

View File

@@ -2,15 +2,15 @@
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# 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).
# This file is the source Rails uses to define your schema when running `rails
# db:schema:load`. When creating a new database, `rails db:schema:load` tends to
# be faster and is potentially less error prone than running all of your
# migrations from scratch. Old migrations may fail to apply correctly if those
# migrations use external dependencies or application code.
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20160218212104) do
ActiveRecord::Schema.define(version: 2016_02_18_212104) do
create_table "blogs", force: :cascade do |t|
t.string "title"

View File

@@ -3,7 +3,7 @@ require 'rails_helper'
RSpec.configure do |config|
# Specify a root folder where Swagger JSON files are generated
# NOTE: If you're using the rswag-api to serve API descriptions, you'll need
# to ensure that it's confiugred to server Swagger from the same folder
# to ensure that it's configured to serve Swagger from the same folder
config.swagger_root = Rails.root.to_s + '/swagger'
# Define one or more Swagger documents and provide global metadata for each one