Skip to content
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

Updated Swagger #506

Merged
merged 6 commits into from
Mar 16, 2019
Merged
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
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ gem 'coffee-rails', '~> 4.2'
gem 'country_select'
gem 'devise', '~> 4.3'
gem 'geocoder', '~> 1.2.1'
gem 'grape', '~> 0.7.0'
gem 'grape-swagger', '~> 0.7.2'
gem 'grape', '1.1'
gem 'grape-swagger', '~> 0.31'
gem 'grape-kaminari'
gem 'haml'
gem 'high_voltage', '~> 3.0.0'
Expand Down
28 changes: 9 additions & 19 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -140,34 +140,25 @@ GEM
geocoder (1.2.14)
globalid (0.4.1)
activesupport (>= 4.2.0)
grape (0.7.0)
grape (1.1.0)
activesupport
builder
hashie (>= 1.2.0)
multi_json (>= 1.3.2)
multi_xml (>= 0.5.2)
mustermann-grape (~> 1.0.0)
rack (>= 1.3.0)
rack-accept
rack-mount
virtus (>= 1.0.0)
grape-entity (0.6.1)
activesupport (>= 5.0.0)
multi_json (>= 1.3.2)
grape-kaminari (0.1.9)
grape
kaminari
grape-swagger (0.7.2)
grape (>= 0.2.0)
grape-entity (>= 0.3.0)
kramdown (>= 1.3.1)
grape-swagger (0.31.0)
grape (>= 0.16.2)
haml (5.0.4)
temple (>= 0.8.0)
tilt
has_scope (0.7.2)
actionpack (>= 4.1)
activesupport (>= 4.1)
hashdiff (0.3.7)
hashie (3.6.0)
high_voltage (3.0.0)
http_accept_language (2.1.1)
i18n (1.1.1)
Expand Down Expand Up @@ -203,7 +194,6 @@ GEM
kaminari-grape (1.0.1)
grape
kaminari-core (~> 1.0)
kramdown (1.15.0)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
Expand All @@ -227,7 +217,9 @@ GEM
i18n (>= 0.6.4, <= 2)
msgpack (1.2.4)
multi_json (1.13.1)
multi_xml (0.6.0)
mustermann (1.0.3)
mustermann-grape (1.0.0)
mustermann (~> 1.0.0)
nio4r (2.3.1)
nokogiri (1.8.5)
mini_portile2 (~> 2.3.0)
Expand All @@ -252,8 +244,6 @@ GEM
rack-cors (1.0.2)
rack-jsonp (1.3.1)
rack
rack-mount (0.8.3)
rack (>= 1.0.0)
rack-proxy (0.6.5)
rack
rack-test (1.1.0)
Expand Down Expand Up @@ -396,9 +386,9 @@ DEPENDENCIES
dotenv-rails (~> 2.2.1)
factory_bot_rails (~> 4.8.2)
geocoder (~> 1.2.1)
grape (~> 0.7.0)
grape (= 1.1)
grape-kaminari
grape-swagger (~> 0.7.2)
grape-swagger (~> 0.31)
haml
high_voltage (~> 3.0.0)
http_accept_language
Expand Down
31 changes: 31 additions & 0 deletions app/assets/stylesheets/pages/api_docs.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#swagger-ui-container {
margin-top: 20px;

.info .title {
display: none;
}
.opblock-summary-get {
background-color: #e7f0f7;
border: 1px solid #c3d9ec;
cursor: pointer;
padding: 5px;

.opblock-summary-method {
background-color: #0f6ab4;
color: #fff;
margin: 5px;
padding: 5px;
}
}

.opblock-body {
background-color: #e7f0f7;
border: 1px solid #c3d9ec;
padding: 5px;
}

.response-col_description pre {
overflow: scroll;
width: 80vw;
}
}
4 changes: 4 additions & 0 deletions app/controllers/api/docs_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Api::DocsController < ApplicationController
def index
end
end
5 changes: 5 additions & 0 deletions app/javascript/packs/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ import './views/restrooms/index'
import './views/restrooms/new'
import './views/restrooms/restrooms'
import './views/restrooms/search'
import ApiDocs from './views/api/docs'

document.addEventListener('DOMContentLoaded', function() {
if (document.getElementById('swagger-ui-container') != null ) { ApiDocs.loadSearch() }
})
10 changes: 10 additions & 0 deletions app/javascript/packs/views/api/docs/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import SwaggerUI from 'swagger-ui'

export default {
loadSearch() {
new SwaggerUI({
url: '/api/swagger_doc.json',
dom_id: '#swagger-ui-container',
})
}
}
1 change: 1 addition & 0 deletions app/views/api/docs/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div id='swagger-ui-container' class='swagger-ui-wrap'></div>
5 changes: 5 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
devise_for :admin_users, ActiveAdmin::Devise.config
ActiveAdmin.routes(self)
resources :restrooms, except: [:edit, :destroy]

namespace :api do
resources :docs, only: [:index]
end

mount API::Base => '/api'

get '/contact', to: 'contacts#new'
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
"jquery-ujs": "^1.2.2",
"popper.js": "^1.14.3",
"rails-erb-loader": "^5.4.2",
"swagger": "^0.7.5",
"swagger-ui": "^3.19.2",
"yarn": ">=1.0.2"
},
"devDependencies": {
Expand Down
135 changes: 0 additions & 135 deletions public/api/docs/css/highlight.default.css

This file was deleted.

Loading