Skip to content

Added swagger Documentation #4

New issue

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

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

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
rvm:
- 1.9.3
- 2.0.0
- 2.1.0
- 2.1.6
- 2.2.2

before_script:
- "cp config/database.travis.yml config/database.yml"
Expand Down
33 changes: 17 additions & 16 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
source 'https://rubygems.org'

gem 'rails', '~> 4.2.1'
gem 'sass'
gem 'sass-rails', '~> 5.0.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'rails', '4.2.1'
gem 'sass','3.4.14'
gem 'sass-rails', '5.0.3'
gem 'coffee-rails', '4.1.0'
gem 'pg'
gem 'activerecord-jdbcsqlite3-adapter', '~> 1.2.9', platforms: [:jruby]
gem 'jquery-rails', '~> 3.0.0'
gem 'grape', '~> 0.11.0'
gem 'uglifier', '>= 1.0.3'
gem 'zip-zip', '~> 0.2'

gem 'activerecord-jdbcsqlite3-adapter', '1.3.1.6', platforms: [:jruby]
gem 'jquery-rails', '4.0.3'
gem 'uglifier', '2.7.1'
gem 'zip-zip', '0.3'
gem 'grape'
gem 'grape-swagger'
gem 'swagger-ui_rails'
group :development, :test do
gem 'rspec', '~> 3.1'
gem 'rspec-rails', '~> 3.1'
gem 'capybara', '~> 2.3.0'
gem 'selenium-webdriver', '~> 2.44.0'
gem 'rubocop', '~> 0.28.0'
gem 'nokogiri', '1.6.2.1'
gem 'rspec', '3.2.0'
gem 'rspec-rails', '3.2.2'
gem 'capybara', '2.4.4'
gem 'selenium-webdriver', '2.46.1'
gem 'rubocop', '0.31.0'
gem 'nokogiri', '1.6.6.2'
end
156 changes: 79 additions & 77 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ GEM
activemodel (= 4.2.1)
activesupport (= 4.2.1)
arel (~> 6.0)
activerecord-jdbc-adapter (1.2.9.1)
activerecord-jdbcsqlite3-adapter (1.2.9)
activerecord-jdbc-adapter (~> 1.2.9)
jdbc-sqlite3 (~> 3.7.2)
activesupport (4.2.1)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
Expand All @@ -49,31 +45,30 @@ GEM
ice_nine (~> 0.11.0)
thread_safe (~> 0.3, >= 0.3.1)
builder (3.2.2)
capybara (2.3.0)
capybara (2.4.4)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
childprocess (0.5.5)
childprocess (0.5.6)
ffi (~> 1.0, >= 1.0.11)
coercible (1.0.0)
descendants_tracker (~> 0.0.1)
coffee-rails (4.1.0)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.0)
coffee-script (2.3.0)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.8.0)
coffee-script-source (1.9.1.1)
descendants_tracker (0.0.4)
thread_safe (~> 0.3, >= 0.3.1)
diff-lcs (1.2.5)
equalizer (0.0.11)
erubis (2.7.0)
execjs (2.2.0)
ffi (1.9.6)
ffi (1.9.6-java)
execjs (2.5.2)
ffi (1.9.8)
globalid (0.3.5)
activesupport (>= 4.1.0)
grape (0.11.0)
Expand All @@ -86,33 +81,36 @@ GEM
rack-accept
rack-mount
virtus (>= 1.0.0)
hashie (3.4.1)
grape-entity (0.4.5)
activesupport
multi_json (>= 1.3.2)
grape-swagger (0.10.1)
grape (>= 0.8.0)
grape-entity
hashie (3.4.2)
i18n (0.7.0)
ice_nine (0.11.1)
jdbc-sqlite3 (3.7.2.1)
jquery-rails (3.0.4)
railties (>= 3.0, < 5.0)
jquery-rails (4.0.3)
rails-dom-testing (~> 1.0)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (1.8.2)
json (1.8.2-java)
json (1.8.3)
loofah (2.0.2)
nokogiri (>= 1.5.9)
mail (2.6.3)
mime-types (>= 1.16, < 3)
mime-types (2.5)
mini_portile (0.6.0)
minitest (5.6.1)
mime-types (2.6.1)
mini_portile (0.6.2)
minitest (5.7.0)
multi_json (1.11.0)
multi_xml (0.5.5)
nokogiri (1.6.2.1)
mini_portile (= 0.6.0)
nokogiri (1.6.2.1-java)
parser (2.2.0.pre.8)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
parser (2.2.2.5)
ast (>= 1.1, < 3.0)
slop (~> 3.4, >= 3.4.5)
pg (0.17.1)
powerpack (0.0.9)
rack (1.6.0)
pg (0.18.2)
powerpack (0.1.1)
rack (1.6.1)
rack-accept (0.4.5)
rack (>= 0.4)
rack-mount (0.8.3)
Expand Down Expand Up @@ -145,91 +143,95 @@ GEM
thor (>= 0.18.1, < 2.0)
rainbow (2.0.0)
rake (10.4.2)
rspec (3.1.0)
rspec-core (~> 3.1.0)
rspec-expectations (~> 3.1.0)
rspec-mocks (~> 3.1.0)
rspec-core (3.1.7)
rspec-support (~> 3.1.0)
rspec-expectations (3.1.2)
rspec (3.2.0)
rspec-core (~> 3.2.0)
rspec-expectations (~> 3.2.0)
rspec-mocks (~> 3.2.0)
rspec-core (3.2.3)
rspec-support (~> 3.2.0)
rspec-expectations (3.2.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.1.0)
rspec-mocks (3.1.3)
rspec-support (~> 3.1.0)
rspec-rails (3.1.0)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec-core (~> 3.1.0)
rspec-expectations (~> 3.1.0)
rspec-mocks (~> 3.1.0)
rspec-support (~> 3.1.0)
rspec-support (3.1.2)
rubocop (0.28.0)
rspec-support (~> 3.2.0)
rspec-mocks (3.2.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.2.0)
rspec-rails (3.2.2)
actionpack (>= 3.0, < 4.3)
activesupport (>= 3.0, < 4.3)
railties (>= 3.0, < 4.3)
rspec-core (~> 3.2.0)
rspec-expectations (~> 3.2.0)
rspec-mocks (~> 3.2.0)
rspec-support (~> 3.2.0)
rspec-support (3.2.2)
rubocop (0.31.0)
astrolabe (~> 1.3)
parser (>= 2.2.0.pre.7, < 3.0)
powerpack (~> 0.0.6)
parser (>= 2.2.2.1, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.4)
ruby-progressbar (1.7.0)
rubyzip (1.1.4)
sass (3.4.9)
sass-rails (5.0.0)
ruby-progressbar (1.7.5)
rubyzip (1.1.7)
sass (3.4.14)
sass-rails (5.0.3)
railties (>= 4.0.0, < 5.0)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (~> 1.1)
selenium-webdriver (2.44.0)
selenium-webdriver (2.46.1)
childprocess (~> 0.5)
multi_json (~> 1.0)
rubyzip (~> 1.0)
websocket (~> 1.0)
slop (3.6.0)
sprockets (3.0.3)
sprockets (3.2.0)
rack (~> 1.0)
sprockets-rails (2.2.4)
sprockets-rails (2.3.1)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
swagger-ui_rails (0.1.7)
thor (0.19.1)
thread_safe (0.3.5)
thread_safe (0.3.5-java)
tilt (1.4.1)
tzinfo (1.2.2)
thread_safe (~> 0.1)
uglifier (2.5.1)
uglifier (2.7.1)
execjs (>= 0.3.0)
json (>= 1.8.0)
virtus (1.0.5)
axiom-types (~> 0.1)
coercible (~> 1.0)
descendants_tracker (~> 0.0, >= 0.0.3)
equalizer (~> 0.0, >= 0.0.9)
websocket (1.2.1)
websocket (1.2.2)
xpath (2.0.0)
nokogiri (~> 1.3)
zip-zip (0.3)
rubyzip (>= 1.0.0)

PLATFORMS
java
ruby

DEPENDENCIES
activerecord-jdbcsqlite3-adapter (~> 1.2.9)
capybara (~> 2.3.0)
coffee-rails (~> 4.1.0)
grape (~> 0.11.0)
jquery-rails (~> 3.0.0)
nokogiri (= 1.6.2.1)
activerecord-jdbcsqlite3-adapter (= 1.3.1.6)
capybara (= 2.4.4)
coffee-rails (= 4.1.0)
grape
grape-swagger
jquery-rails (= 4.0.3)
nokogiri (= 1.6.6.2)
pg
rails (~> 4.2.1)
rspec (~> 3.1)
rspec-rails (~> 3.1)
rubocop (~> 0.28.0)
sass
sass-rails (~> 5.0.0)
selenium-webdriver (~> 2.44.0)
uglifier (>= 1.0.3)
zip-zip (~> 0.2)
rails (= 4.2.1)
rspec (= 3.2.0)
rspec-rails (= 3.2.2)
rubocop (= 0.31.0)
sass (= 3.4.14)
sass-rails (= 5.0.3)
selenium-webdriver (= 2.46.1)
swagger-ui_rails
uglifier (= 2.7.1)
zip-zip (= 0.3)

BUNDLED WITH
1.10.3
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ Run
bundle install
rails s
```

For Documentation
```
http://localhost:3000/documentation
```
Try http://localhost:3000/api/ping or http://localhost:3000/api/protected/ping with _username_ and _password_.

8 changes: 7 additions & 1 deletion app/api/api.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# require 'grape-swagger'

class API < Grape::API
prefix 'api'
version :v1
prefix :api
# prefix 'api'
format :json
mount Acme::Ping
mount Acme::Raise
mount Acme::Protected
mount Acme::Post
# add_swagger_documentation
add_swagger_documentation base_path: '', api_version: 'v1', mount_path: '/api/docs' unless Rails.env.production?
end
1 change: 1 addition & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
//
//= require jquery
//= require jquery_ujs
//= require swagger-ui
//= require_tree .
1 change: 1 addition & 0 deletions app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
* compiled file, but it's generally better to create a new file per style scope.
*
*= require_self
*= require swagger-ui
*= require_tree .
*/
1 change: 1 addition & 0 deletions app/views/application/apidocs.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= render 'swagger_ui/swagger_ui', discovery_url: '/api/docs' %>
4 changes: 4 additions & 0 deletions config/database.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
development:
adapter: postgresql
database: grape_on_rails_development
username: root
password: root

test:
adapter: postgresql
database: grape_on_rails_test
username: root
password: root
3 changes: 3 additions & 0 deletions config/initializers/swagger.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# GrapeSwaggerRails.options.url = '/api/swagger_doc'
# GrapeSwaggerRails.options.app_url = 'http://localhost:3000'
# GrapeSwaggerRails.options.app_name = 'Swagger-API-Documentation'
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
get 'welcome/index'
mount API => '/'
root 'welcome#index'
get '/apidocs' => 'application#apidocs'
end
Loading