Skip to content

Commit c5fc80d

Browse files
committed
1st Swaggard version
0 parents  commit c5fc80d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+10357
-0
lines changed

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.bundle/
2+
log/*.log
3+
.DS_STORE
4+
swagger-ui.sublime-workspace
5+
.idea
6+
.project
7+
coverage

.rspec

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--color
2+
--format progress

.ruby-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.1.1

Gemfile

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
source "http://rubygems.org"
2+
3+
# Declare your gem's dependencies in swagger-yard.gemspec.
4+
# Bundler will treat runtime dependencies like base dependencies, and
5+
# development dependencies will be added by default to the :development group.
6+
gemspec
7+
8+
# jquery-rails is used by the dummy application
9+
gem "jquery-rails"
10+
11+
# Declare any dependencies that are still in development here instead of in
12+
# your gemspec. These might include edge Rails or gems from your path or
13+
# Git. Remember to move these dependencies to your gemspec before releasing
14+
# your gem to rubygems.org.
15+
16+
# To use debugger
17+
# gem 'debugger'

Gemfile.lock

+123
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
PATH
2+
remote: .
3+
specs:
4+
swagger_yard (0.0.5)
5+
rails (~> 3.2.8)
6+
yard
7+
8+
GEM
9+
remote: http://rubygems.org/
10+
specs:
11+
actionmailer (3.2.13)
12+
actionpack (= 3.2.13)
13+
mail (~> 2.5.3)
14+
actionpack (3.2.13)
15+
activemodel (= 3.2.13)
16+
activesupport (= 3.2.13)
17+
builder (~> 3.0.0)
18+
erubis (~> 2.7.0)
19+
journey (~> 1.0.4)
20+
rack (~> 1.4.5)
21+
rack-cache (~> 1.2)
22+
rack-test (~> 0.6.1)
23+
sprockets (~> 2.2.1)
24+
activemodel (3.2.13)
25+
activesupport (= 3.2.13)
26+
builder (~> 3.0.0)
27+
activerecord (3.2.13)
28+
activemodel (= 3.2.13)
29+
activesupport (= 3.2.13)
30+
arel (~> 3.0.2)
31+
tzinfo (~> 0.3.29)
32+
activeresource (3.2.13)
33+
activemodel (= 3.2.13)
34+
activesupport (= 3.2.13)
35+
activesupport (3.2.13)
36+
i18n (= 0.6.1)
37+
multi_json (~> 1.0)
38+
arel (3.0.3)
39+
bourne (1.5.0)
40+
mocha (>= 0.13.2, < 0.15)
41+
builder (3.0.4)
42+
diff-lcs (1.2.5)
43+
docile (1.1.3)
44+
erubis (2.7.0)
45+
hike (1.2.3)
46+
i18n (0.6.1)
47+
journey (1.0.4)
48+
jquery-rails (3.0.1)
49+
railties (>= 3.0, < 5.0)
50+
thor (>= 0.14, < 2.0)
51+
json (1.8.0)
52+
mail (2.5.4)
53+
mime-types (~> 1.16)
54+
treetop (~> 1.4.8)
55+
metaclass (0.0.4)
56+
mime-types (1.25.1)
57+
mocha (0.14.0)
58+
metaclass (~> 0.0.1)
59+
multi_json (1.7.7)
60+
polyglot (0.3.4)
61+
rack (1.4.5)
62+
rack-cache (1.2)
63+
rack (>= 0.4)
64+
rack-ssl (1.3.3)
65+
rack
66+
rack-test (0.6.2)
67+
rack (>= 1.0)
68+
rails (3.2.13)
69+
actionmailer (= 3.2.13)
70+
actionpack (= 3.2.13)
71+
activerecord (= 3.2.13)
72+
activeresource (= 3.2.13)
73+
activesupport (= 3.2.13)
74+
bundler (~> 1.0)
75+
railties (= 3.2.13)
76+
railties (3.2.13)
77+
actionpack (= 3.2.13)
78+
activesupport (= 3.2.13)
79+
rack-ssl (~> 1.3.2)
80+
rake (>= 0.8.7)
81+
rdoc (~> 3.4)
82+
thor (>= 0.14.6, < 2.0)
83+
rake (10.1.0)
84+
rdoc (3.12.2)
85+
json (~> 1.4)
86+
rspec (2.14.1)
87+
rspec-core (~> 2.14.0)
88+
rspec-expectations (~> 2.14.0)
89+
rspec-mocks (~> 2.14.0)
90+
rspec-core (2.14.8)
91+
rspec-expectations (2.14.5)
92+
diff-lcs (>= 1.1.3, < 2.0)
93+
rspec-mocks (2.14.6)
94+
simplecov (0.8.2)
95+
docile (~> 1.1.0)
96+
multi_json
97+
simplecov-html (~> 0.8.0)
98+
simplecov-html (0.8.0)
99+
sprockets (2.2.2)
100+
hike (~> 1.2)
101+
multi_json (~> 1.0)
102+
rack (~> 1.0)
103+
tilt (~> 1.1, != 1.3.0)
104+
sqlite3 (1.3.7)
105+
thor (0.18.1)
106+
tilt (1.4.1)
107+
treetop (1.4.15)
108+
polyglot
109+
polyglot (>= 0.3.1)
110+
tzinfo (0.3.39)
111+
yard (0.8.7.4)
112+
113+
PLATFORMS
114+
ruby
115+
116+
DEPENDENCIES
117+
bourne
118+
jquery-rails
119+
mocha
120+
rspec
121+
simplecov
122+
sqlite3
123+
swagger_yard!

MIT-LICENSE

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Copyright 2013 Chris Trinh
2+
3+
Permission is hereby granted, free of charge, to any person obtaining
4+
a copy of this software and associated documentation files (the
5+
"Software"), to deal in the Software without restriction, including
6+
without limitation the rights to use, copy, modify, merge, publish,
7+
distribute, sublicense, and/or sell copies of the Software, and to
8+
permit persons to whom the Software is furnished to do so, subject to
9+
the following conditions:
10+
11+
The above copyright notice and this permission notice shall be
12+
included in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
Swaggard
2+
========
3+
4+
Swaggard is a Rails Engine that can be used to document a REST api. It does this by generating a
5+
json that is compliant with [Swagger][http://swagger.io] and displaying it using [Swagger-ui](https://github.com/wordnik/swagger-ui).
6+
This gem is inspired and based on [SwaggerYard][https://github.com/synctv/swagger_yard] by [Chris Trinh][https://github.com/chtrinh].
7+
8+
9+
Swaggard vs SwaggerYard
10+
-----------------------
11+
12+
The main reason this gem exists is to avoid having to write by hand some information and use what
13+
rails already give us ie: controllers paths and methods paths.
14+
And also to bring support for rails 4 and swagger 2.
15+
16+
Installation
17+
------------
18+
19+
Put Swaggard in your Gemfile:
20+
21+
gem 'swaggard'
22+
23+
Install the gem with Bunder:
24+
25+
bundle install
26+
27+
28+
Getting Started
29+
-----------------
30+
31+
Place your configuration in a your rails initializers
32+
33+
# config/initializers/swaggard.rb
34+
Swaggard.configure do |config|
35+
config.api_version = "0.1"
36+
config.doc_base_path = "http://swagger.example.com/doc"
37+
config.api_base_path = "http://swagger.example.com/api"
38+
end
39+
40+
Mount your engine
41+
42+
# config/routes.rb
43+
mount Swaggard::Engine, at: "/swagger"
44+
45+
46+
Example
47+
-------
48+
49+
Here is a example of how to use Swaggard
50+
51+
# This document describes the API for creating, reading, and deleting account ownerships.
52+
#
53+
class Accounts::OwnershipsController < ActionController::Base
54+
##
55+
# Returns a list of ownerships associated with the account.
56+
#
57+
# Status can be -1(Deleted), 0(Inactive), 1(Active), 2(Expired) and 3(Cancelled).
58+
#
59+
# @parameter [Integer] offset Used for pagination of response data (default: 25 items per response). Specifies the offset of the next block of data to receive.
60+
# @parameter [Array] status Filter by status. (e.g. status[]=1&status[]=2&status[]=3).
61+
# @parameter_list [String] sort_order Orders response by fields. (e.g. sort_order=created_at).
62+
# [List] id
63+
# [List] begin_at
64+
# [List] end_at
65+
# [List] created_at
66+
# @parameter [Boolean] sort_descending Reverse order of sort_order sorting, make it descending.
67+
# @parameter [Date] begin_at_greater Filters response to include only items with begin_at >= specified timestamp (e.g. begin_at_greater=2012-02-15T02:06:56Z).
68+
# @parameter [Date] begin_at_less Filters response to include only items with begin_at <= specified timestamp (e.g. begin_at_less=2012-02-15T02:06:56Z).
69+
# @parameter [Date] end_at_greater Filters response to include only items with end_at >= specified timestamp (e.g. end_at_greater=2012-02-15T02:06:56Z).
70+
# @parameter [Date] end_at_less Filters response to include only items with end_at <= specified timestamp (e.g. end_at_less=2012-02-15T02:06:56Z).
71+
#
72+
def index
73+
...
74+
end
75+
end
76+
77+
78+
![Web UI](https://raw.github.com/synctv/swagger_yard/master/example/web-ui.png)
79+
80+
81+
Notes
82+
-----
83+
84+
By default Swaggard will use a slightly modify version of the swagger-ui.
85+
Changes to the JS code are indicated with "Swaggard changes" comments. The changes are mainly to
86+
support Rails way of supporting an array of parameters.
87+
88+
89+
More Information
90+
-----------------
91+
92+
[Swagger][http://swagger.io]
93+
[Swagger-ui](https://github.com/wordnik/swagger-ui)
94+
[Yard](https://github.com/lsegal/yard)
95+
96+
97+
Author
98+
------
99+
100+
[Adrian Gomez][https://github.com/adrian-gomez]
101+
102+
103+
Credits
104+
-------
105+
106+
[Chris Trinh][https://github.com/chtrinh] author of [SwaggerYard][https://github.com/synctv/swagger_yard] in which this gem is
107+
inspired and used a base.

Rakefile

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
require 'bundler/setup'
2+
require 'bundler/gem_tasks'
3+
4+
begin
5+
require 'rdoc/task'
6+
rescue LoadError
7+
require 'rdoc/rdoc'
8+
require 'rake/rdoctask'
9+
RDoc::Task = Rake::RDocTask
10+
end
11+
12+
RDoc::Task.new(:rdoc) do |rdoc|
13+
rdoc.rdoc_dir = 'rdoc'
14+
rdoc.title = 'Swaggard'
15+
rdoc.options << '--line-numbers'
16+
rdoc.rdoc_files.include('README.rdoc')
17+
rdoc.rdoc_files.include('lib/**/*.rb')
18+
end
19+
20+
require 'rspec/core/rake_task'
21+
22+
RSpec::Core::RakeTask.new(:spec)
23+
24+
task :default => :spec
770 Bytes
Loading
824 Bytes
Loading
9.04 KB
Loading
980 Bytes
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// This is a manifest file that'll be compiled into application.js, which will include all the files
2+
// listed below.
3+
//
4+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6+
//
7+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8+
// compiled file.
9+
//
10+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11+
// about supported directives.
12+
//
13+
//= require swaggard/lib/jquery-1.8.0.min.js
14+
//= require swaggard/lib/jquery.slideto.min.js
15+
//= require swaggard/lib/jquery.wiggle.min.js
16+
//= require swaggard/lib/jquery.ba-bbq.min.js
17+
//= require swaggard/lib/handlebars-1.0.rc.1.js
18+
//= require swaggard/lib/underscore-min.js
19+
//= require swaggard/lib/backbone-min.js
20+
//= require swaggard/lib/swagger.js
21+
//= require swaggard/lib/MD5.js
22+
//= require swaggard/lib/highlight.7.3.pack.js
23+
//= require swaggard/swagger-ui.js.erb

0 commit comments

Comments
 (0)