Permalink
Browse files

Add Swagger and serve it with Rack

  • Loading branch information...
tonymadbrain committed Nov 24, 2015
1 parent 158fc4b commit 8b9ec95d7b00b98095a6058e73a92698d1906c43
Showing with 12,512 additions and 0 deletions.
  1. +2 −0 Gemfile
  2. +9 −0 Gemfile.lock
  3. +16 −0 app/api/notes.rb
  4. +2 −0 app/core.rb
  5. +17 −0 config.ru
  6. +5 −0 public/swagger_ui/README.md
  7. +125 −0 public/swagger_ui/css/reset.css
  8. +1,256 −0 public/swagger_ui/css/screen.css
  9. +26 −0 public/swagger_ui/css/typography.css
  10. BIN public/swagger_ui/fonts/droid-sans-v6-latin-700.eot
  11. +411 −0 public/swagger_ui/fonts/droid-sans-v6-latin-700.svg
  12. BIN public/swagger_ui/fonts/droid-sans-v6-latin-700.ttf
  13. BIN public/swagger_ui/fonts/droid-sans-v6-latin-700.woff
  14. BIN public/swagger_ui/fonts/droid-sans-v6-latin-700.woff2
  15. BIN public/swagger_ui/fonts/droid-sans-v6-latin-regular.eot
  16. +403 −0 public/swagger_ui/fonts/droid-sans-v6-latin-regular.svg
  17. BIN public/swagger_ui/fonts/droid-sans-v6-latin-regular.ttf
  18. BIN public/swagger_ui/fonts/droid-sans-v6-latin-regular.woff
  19. BIN public/swagger_ui/fonts/droid-sans-v6-latin-regular.woff2
  20. BIN public/swagger_ui/images/explorer_icons.png
  21. BIN public/swagger_ui/images/logo_small.png
  22. BIN public/swagger_ui/images/pet_store_api.png
  23. BIN public/swagger_ui/images/throbber.gif
  24. BIN public/swagger_ui/images/wordnik_api.png
  25. +96 −0 public/swagger_ui/index.html
  26. +2,240 −0 public/swagger_ui/js/swagger-ui.js
  27. +15 −0 public/swagger_ui/lib/backbone-min.js
  28. +28 −0 public/swagger_ui/lib/handlebars-2.0.0.js
  29. +1 −0 public/swagger_ui/lib/highlight.7.3.pack.js
  30. +2 −0 public/swagger_ui/lib/jquery-1.8.0.min.js
  31. +18 −0 public/swagger_ui/lib/jquery.ba-bbq.min.js
  32. +1 −0 public/swagger_ui/lib/jquery.slideto.min.js
  33. +8 −0 public/swagger_ui/lib/jquery.wiggle.min.js
  34. +1,272 −0 public/swagger_ui/lib/marked.js
  35. +2,765 −0 public/swagger_ui/lib/shred.bundle.js
  36. +193 −0 public/swagger_ui/lib/shred/content.js
  37. +3,294 −0 public/swagger_ui/lib/swagger-client.js
  38. +279 −0 public/swagger_ui/lib/swagger-oauth.js
  39. +6 −0 public/swagger_ui/lib/underscore-min.js
  40. +20 −0 public/swagger_ui/o2c.html
  41. +2 −0 public/swagger_ui/swagger-ui.min.js
View
@@ -2,6 +2,8 @@ source 'https://rubygems.org'
ruby '2.2.3'
gem 'rack-fiber_pool', :require => 'rack/fiber_pool'
gem 'grape'
gem 'grape-swagger'
gem 'pry'
gem 'awesome_print'
View
@@ -29,6 +29,12 @@ GEM
rack-accept
rack-mount
virtus (>= 1.0.0)
grape-entity (0.4.8)
activesupport
multi_json (>= 1.3.2)
grape-swagger (0.10.2)
grape (>= 0.8.0)
grape-entity
hashie (3.4.3)
i18n (0.7.0)
ice_nine (0.11.1)
@@ -44,6 +50,7 @@ GEM
rack (1.6.4)
rack-accept (0.4.5)
rack (>= 0.4)
rack-fiber_pool (0.9.3)
rack-mount (0.8.3)
rack (>= 1.0.0)
slop (3.6.0)
@@ -62,7 +69,9 @@ PLATFORMS
DEPENDENCIES
awesome_print
grape
grape-swagger
pry
rack-fiber_pool
BUNDLED WITH
1.10.6
View
@@ -8,5 +8,21 @@ class Notes < Grape::API
get '/test' do
{ data: "TEST" }
end
end
add_swagger_documentation \
:info => {
:title => "Notes API"
},
:hide_documentation_path => true,
:mount_path => "/swagger_doc",
:markdown => false,
:api_version => 'v1'
before do
header['Access-Control-Allow-Origin'] = '*'
header['Access-Control-Request-Method'] = '*'
end
end
View
@@ -3,3 +3,5 @@
Bundler.require
app_base = "#{File.dirname(File.expand_path(__FILE__))}/.."
Dir.glob("#{app_base}/app/models/**/*.rb").each { |i| require i }
Dir.glob("#{app_base}/app/lib/**/*.rb").each { |i| require i }
View
@@ -6,3 +6,20 @@ require './app/core'
require './app/api/notes'
run Notes
use Rack::Static,
:urls => ["/images", "/lib", "/js", "/css"],
:root => "public/swagger_ui"
map '/swagger-ui' do
run lambda { |env|
[
200,
{
'Content-Type' => 'txt-html',
'Cache-Control' => 'public, max-age=86400'
},
File.open('public/swagger_ui/index.html', File::RDONLY)
]
}
end
@@ -0,0 +1,5 @@
This folder is the content of the dist folder taken from this repo on date 03/04/2015:
* https://github.com/swagger-api/swagger-ui
The only change was done to index.html to accomodate our needs.
@@ -0,0 +1,125 @@
/* http://meyerweb.com/eric/tools/css/reset/ v2.0 | 20110126 */
html,
body,
div,
span,
applet,
object,
iframe,
h1,
h2,
h3,
h4,
h5,
h6,
p,
blockquote,
pre,
a,
abbr,
acronym,
address,
big,
cite,
code,
del,
dfn,
em,
img,
ins,
kbd,
q,
s,
samp,
small,
strike,
strong,
sub,
sup,
tt,
var,
b,
u,
i,
center,
dl,
dt,
dd,
ol,
ul,
li,
fieldset,
form,
label,
legend,
table,
caption,
tbody,
tfoot,
thead,
tr,
th,
td,
article,
aside,
canvas,
details,
embed,
figure,
figcaption,
footer,
header,
hgroup,
menu,
nav,
output,
ruby,
section,
summary,
time,
mark,
audio,
video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
menu,
nav,
section {
display: block;
}
body {
line-height: 1;
}
ol,
ul {
list-style: none;
}
blockquote,
q {
quotes: none;
}
blockquote:before,
blockquote:after,
q:before,
q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
Oops, something went wrong.

0 comments on commit 8b9ec95

Please sign in to comment.