grape-swagger 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -3,7 +3,8 @@ source "http://rubygems.org"
3
3
  # Example:
4
4
  # gem "activesupport", ">= 2.3.5"
5
5
 
6
- gem 'grape'
6
+ gem 'grape', '~> 0.2.0'
7
+ gem 'kramdown'
7
8
 
8
9
  # Add dependencies to develop your gem here.
9
10
  # Include everything needed to run rake, tests, features, etc.
@@ -12,13 +13,10 @@ group :development do
12
13
  gem "rdoc", "~> 3.12"
13
14
  gem "bundler", "> 1.0.0"
14
15
  gem "jeweler", "~> 1.8.4"
15
- # jquery-rails is used by the dummy application
16
- gem "jquery-rails"
17
- gem "rails", "~> 3.2"
18
- gem "sqlite3"
16
+
17
+ gem "pry"
19
18
 
20
19
  gem "rack-test"
21
20
 
22
- gem "rspec-rails"
23
21
  gem "rspec"
24
22
  end
data/Gemfile.lock CHANGED
@@ -1,37 +1,11 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- actionmailer (3.2.6)
5
- actionpack (= 3.2.6)
6
- mail (~> 2.4.4)
7
- actionpack (3.2.6)
8
- activemodel (= 3.2.6)
9
- activesupport (= 3.2.6)
10
- builder (~> 3.0.0)
11
- erubis (~> 2.7.0)
12
- journey (~> 1.0.1)
13
- rack (~> 1.4.0)
14
- rack-cache (~> 1.2)
15
- rack-test (~> 0.6.1)
16
- sprockets (~> 2.1.3)
17
- activemodel (3.2.6)
18
- activesupport (= 3.2.6)
19
- builder (~> 3.0.0)
20
- activerecord (3.2.6)
21
- activemodel (= 3.2.6)
22
- activesupport (= 3.2.6)
23
- arel (~> 3.0.2)
24
- tzinfo (~> 0.3.29)
25
- activeresource (3.2.6)
26
- activemodel (= 3.2.6)
27
- activesupport (= 3.2.6)
28
4
  activesupport (3.2.6)
29
5
  i18n (~> 0.6)
30
6
  multi_json (~> 1.0)
31
- arel (3.0.2)
32
- builder (3.0.0)
7
+ coderay (1.0.7)
33
8
  diff-lcs (1.1.3)
34
- erubis (2.7.0)
35
9
  git (1.2.5)
36
10
  grape (0.2.1)
37
11
  hashie (~> 1.2)
@@ -40,50 +14,26 @@ GEM
40
14
  rack
41
15
  rack-mount
42
16
  hashie (1.2.0)
43
- hike (1.2.1)
44
17
  i18n (0.6.0)
45
18
  jeweler (1.8.4)
46
19
  bundler (~> 1.0)
47
20
  git (>= 1.2.5)
48
21
  rake
49
22
  rdoc
50
- journey (1.0.4)
51
- jquery-rails (2.0.2)
52
- railties (>= 3.2.0, < 5.0)
53
- thor (~> 0.14)
54
23
  json (1.7.3)
55
- mail (2.4.4)
56
- i18n (>= 0.4.0)
57
- mime-types (~> 1.16)
58
- treetop (~> 1.4.8)
59
- mime-types (1.19)
24
+ kramdown (0.13.7)
25
+ method_source (0.8)
60
26
  multi_json (1.3.6)
61
27
  multi_xml (0.5.1)
62
- polyglot (0.3.3)
28
+ pry (0.9.10)
29
+ coderay (~> 1.0.5)
30
+ method_source (~> 0.8)
31
+ slop (~> 3.3.1)
63
32
  rack (1.4.1)
64
- rack-cache (1.2)
65
- rack (>= 0.4)
66
33
  rack-mount (0.8.3)
67
34
  rack (>= 1.0.0)
68
- rack-ssl (1.3.2)
69
- rack
70
35
  rack-test (0.6.1)
71
36
  rack (>= 1.0)
72
- rails (3.2.6)
73
- actionmailer (= 3.2.6)
74
- actionpack (= 3.2.6)
75
- activerecord (= 3.2.6)
76
- activeresource (= 3.2.6)
77
- activesupport (= 3.2.6)
78
- bundler (~> 1.0)
79
- railties (= 3.2.6)
80
- railties (3.2.6)
81
- actionpack (= 3.2.6)
82
- activesupport (= 3.2.6)
83
- rack-ssl (~> 1.3.2)
84
- rake (>= 0.8.7)
85
- rdoc (~> 3.4)
86
- thor (>= 0.14.6, < 2.0)
87
37
  rake (0.9.2.2)
88
38
  rdoc (3.12)
89
39
  json (~> 1.4)
@@ -95,41 +45,24 @@ GEM
95
45
  rspec-expectations (2.11.1)
96
46
  diff-lcs (~> 1.1.3)
97
47
  rspec-mocks (2.11.1)
98
- rspec-rails (2.11.0)
99
- actionpack (>= 3.0)
100
- activesupport (>= 3.0)
101
- railties (>= 3.0)
102
- rspec (~> 2.11.0)
103
48
  shoulda (3.1.1)
104
49
  shoulda-context (~> 1.0)
105
50
  shoulda-matchers (~> 1.2)
106
51
  shoulda-context (1.0.0)
107
52
  shoulda-matchers (1.2.0)
108
53
  activesupport (>= 3.0.0)
109
- sprockets (2.1.3)
110
- hike (~> 1.2)
111
- rack (~> 1.0)
112
- tilt (~> 1.1, != 1.3.0)
113
- sqlite3 (1.3.6)
114
- thor (0.15.4)
115
- tilt (1.3.3)
116
- treetop (1.4.10)
117
- polyglot
118
- polyglot (>= 0.3.1)
119
- tzinfo (0.3.33)
54
+ slop (3.3.2)
120
55
 
121
56
  PLATFORMS
122
57
  ruby
123
58
 
124
59
  DEPENDENCIES
125
60
  bundler (> 1.0.0)
126
- grape
61
+ grape (~> 0.2.0)
127
62
  jeweler (~> 1.8.4)
128
- jquery-rails
63
+ kramdown
64
+ pry
129
65
  rack-test
130
- rails (~> 3.2)
131
66
  rdoc (~> 3.12)
132
67
  rspec
133
- rspec-rails
134
68
  shoulda
135
- sqlite3
data/README.markdown CHANGED
@@ -40,6 +40,35 @@ You can pass a hash with some configuration possibilities to ```add_swagger_docu
40
40
  * ```:mount_path``` The path were the API documentation is loaded, default '/swagger_doc'
41
41
  * ```:api_version``` Version of the API that's being exposed
42
42
  * ```:base_path``` Basepath of the API that's being exposed
43
+ * ```:markdown``` Allow markdown in `notes`, default `false`
44
+
45
+ ## Swagger additions
46
+ grape-swagger allows you to add an explanation in markdown in the notes field. Which would result in proper formatted markdown in Swagger UI. The default Swagger UI doesn't allow HTML in the notes field, so you need to use an adapted version of Swagger UI (you can find one at https://github.com/tim-vandecasteele/swagger-ui/tree/vasco).
47
+
48
+ We're using [kramdown](http://kramdown.rubyforge.org) for parsing the markdown, specific syntax can be found [here](http://kramdown.rubyforge.org/syntax.html).
49
+
50
+ Be sure to enable markdown in the `add_swagger_documentation` call: ':markdown => true'
51
+
52
+ ``` ruby
53
+ desc "Reserve a virgin in heaven", {
54
+ :notes => <<-NOTE
55
+ Virgins in heaven
56
+ -----------------
57
+
58
+ > A virgin doesn't come for free
59
+
60
+ If you want to reserve a virgin in heaven, you have to do
61
+ some crazy stuff on earth.
62
+
63
+ def do_good
64
+ puts 'help people'
65
+ end
66
+
67
+ * _Will go to Heaven:_ Probably
68
+ * _Will go to Hell:_ Probably not
69
+ NOTE
70
+ }
71
+ ```
43
72
 
44
73
  ## Contributing to grape-swagger
45
74
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "grape-swagger"
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Tim Vandecasteele"]
12
- s.date = "2012-07-27"
12
+ s.date = "2012-08-17"
13
13
  s.description = "A simple way to add proper auto generated documentation - that can be displayed with swagger - to your inline described grape API"
14
14
  s.email = "tim.vandecasteele@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -42,41 +42,35 @@ Gem::Specification.new do |s|
42
42
  s.specification_version = 3
43
43
 
44
44
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
45
- s.add_runtime_dependency(%q<grape>, [">= 0"])
45
+ s.add_runtime_dependency(%q<grape>, ["~> 0.2.0"])
46
+ s.add_runtime_dependency(%q<kramdown>, [">= 0"])
46
47
  s.add_development_dependency(%q<shoulda>, [">= 0"])
47
48
  s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
48
49
  s.add_development_dependency(%q<bundler>, ["> 1.0.0"])
49
50
  s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
50
- s.add_development_dependency(%q<jquery-rails>, [">= 0"])
51
- s.add_development_dependency(%q<rails>, ["~> 3.2"])
52
- s.add_development_dependency(%q<sqlite3>, [">= 0"])
51
+ s.add_development_dependency(%q<pry>, [">= 0"])
53
52
  s.add_development_dependency(%q<rack-test>, [">= 0"])
54
- s.add_development_dependency(%q<rspec-rails>, [">= 0"])
55
53
  s.add_development_dependency(%q<rspec>, [">= 0"])
56
54
  else
57
- s.add_dependency(%q<grape>, [">= 0"])
55
+ s.add_dependency(%q<grape>, ["~> 0.2.0"])
56
+ s.add_dependency(%q<kramdown>, [">= 0"])
58
57
  s.add_dependency(%q<shoulda>, [">= 0"])
59
58
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
60
59
  s.add_dependency(%q<bundler>, ["> 1.0.0"])
61
60
  s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
62
- s.add_dependency(%q<jquery-rails>, [">= 0"])
63
- s.add_dependency(%q<rails>, ["~> 3.2"])
64
- s.add_dependency(%q<sqlite3>, [">= 0"])
61
+ s.add_dependency(%q<pry>, [">= 0"])
65
62
  s.add_dependency(%q<rack-test>, [">= 0"])
66
- s.add_dependency(%q<rspec-rails>, [">= 0"])
67
63
  s.add_dependency(%q<rspec>, [">= 0"])
68
64
  end
69
65
  else
70
- s.add_dependency(%q<grape>, [">= 0"])
66
+ s.add_dependency(%q<grape>, ["~> 0.2.0"])
67
+ s.add_dependency(%q<kramdown>, [">= 0"])
71
68
  s.add_dependency(%q<shoulda>, [">= 0"])
72
69
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
73
70
  s.add_dependency(%q<bundler>, ["> 1.0.0"])
74
71
  s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
75
- s.add_dependency(%q<jquery-rails>, [">= 0"])
76
- s.add_dependency(%q<rails>, ["~> 3.2"])
77
- s.add_dependency(%q<sqlite3>, [">= 0"])
72
+ s.add_dependency(%q<pry>, [">= 0"])
78
73
  s.add_dependency(%q<rack-test>, [">= 0"])
79
- s.add_dependency(%q<rspec-rails>, [">= 0"])
80
74
  s.add_dependency(%q<rspec>, [">= 0"])
81
75
  end
82
76
  end
data/lib/grape-swagger.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'kramdown'
2
+
1
3
  module Grape
2
4
  class API
3
5
  class << self
@@ -39,12 +41,14 @@ module Grape
39
41
  :mount_path => '/swagger_doc',
40
42
  :base_path => nil,
41
43
  :api_version => '0.1',
44
+ :markdown => false
42
45
  }
43
46
  options = defaults.merge(options)
44
47
 
45
48
  @@target_class = options[:target_class]
46
49
  @@mount_path = options[:mount_path]
47
50
  @@class_name = options[:class_name] || options[:mount_path].gsub('/','')
51
+ @@markdown = options[:markdown]
48
52
  api_version = options[:api_version]
49
53
  base_path = options[:base_path]
50
54
 
@@ -68,19 +72,20 @@ module Grape
68
72
 
69
73
  desc 'Swagger compatible API description for specific API', :params =>
70
74
  {
71
- "name" => { :desc => "Class name of mounted API", :type => "string", :required => true },
75
+ "name" => { :desc => "Resource name of mounted API", :type => "string", :required => true },
72
76
  }
73
77
  get "#{@@mount_path}/:name" do
74
78
  header['Access-Control-Allow-Origin'] = '*'
75
79
  header['Access-Control-Request-Method'] = '*'
76
80
  routes = @@target_class::combined_routes[params[:name]]
77
81
  routes_array = routes.map do |route|
82
+ notes = route.route_notes && @@markdown ? Kramdown::Document.new(route.route_notes.strip_heredoc).to_html : route.route_notes
78
83
  {
79
84
  :path => parse_path(route.route_path),
80
85
  :operations => [{
81
- :notes => route.route_notes,
86
+ :notes => notes,
82
87
  :summary => route.route_description || '',
83
- :nickname => Random.rand(1000000),
88
+ :nickname => route.route_method + route.route_path.gsub(/[\/:\(\)\.]/,'-'),
84
89
  :httpMethod => route.route_method,
85
90
  :parameters => parse_params(route.route_params, route.route_path, route.route_method)
86
91
  }]
@@ -129,3 +134,28 @@ module Grape
129
134
  end
130
135
  end
131
136
  end
137
+
138
+ class Object
139
+ ##
140
+ # @person ? @person.name : nil
141
+ # vs
142
+ # @person.try(:name)
143
+ #
144
+ # File activesupport/lib/active_support/core_ext/object/try.rb#L32
145
+ def try(*a, &b)
146
+ if a.empty? && block_given?
147
+ yield self
148
+ else
149
+ __send__(*a, &b)
150
+ end
151
+ end
152
+ end
153
+
154
+ class String
155
+ # strip_heredoc from rails
156
+ # File activesupport/lib/active_support/core_ext/string/strip.rb, line 22
157
+ def strip_heredoc
158
+ indent = scan(/^[ \t]*(?=\S)/).min.try(:size) || 0
159
+ gsub(/^[ \t]{#{indent}}/, '')
160
+ end
161
+ end
@@ -1,25 +1,24 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "overruling the defaults for the api documentation generation" do
4
-
5
- class MountedApi < Grape::API
6
- desc 'this gets something'
7
- get '/something' do
8
- {:bla => 'something'}
9
- end
10
- end
11
-
12
-
3
+ describe "options: " do
13
4
  context "overruling the basepath" do
14
- class SimpleApiWithBasePath < Grape::API
15
- NON_DEFAULT_BASE_PATH= "http://www.breakcoregivesmewood.com"
16
-
17
- mount MountedApi
18
- add_swagger_documentation :base_path => NON_DEFAULT_BASE_PATH
5
+ before(:all) do
6
+ class BasePathMountedApi < Grape::API
7
+ desc 'this gets something'
8
+ get '/something' do
9
+ {:bla => 'something'}
10
+ end
11
+ end
12
+
13
+ class SimpleApiWithBasePath < Grape::API
14
+ NON_DEFAULT_BASE_PATH= "http://www.breakcoregivesmewood.com"
15
+
16
+ mount BasePathMountedApi
17
+ add_swagger_documentation :base_path => NON_DEFAULT_BASE_PATH
18
+ end
19
19
  end
20
20
 
21
- subject { SimpleApiWithBasePath.new }
22
- def app; subject end
21
+ def app; SimpleApiWithBasePath end
23
22
 
24
23
  it "retrieves the given base-path on /swagger_doc" do
25
24
  get '/swagger_doc'
@@ -27,55 +26,68 @@ describe "overruling the defaults for the api documentation generation" do
27
26
  end
28
27
 
29
28
  it "retrieves the same given base-path for mounted-api" do
30
- Random.stub(:rand) { 0 }
31
29
  get '/swagger_doc/something'
32
- last_response.body.should == "{:apiVersion=>\"0.1\", :swaggerVersion=>\"1.1\", :basePath=>\"#{SimpleApiWithBasePath::NON_DEFAULT_BASE_PATH}\", :resourcePath=>\"\", :apis=>[{:path=>\"/something.{format}\", :operations=>[{:notes=>nil, :summary=>\"this gets something\", :nickname=>0, :httpMethod=>\"GET\", :parameters=>[]}]}]}"
30
+ last_response.body.should == "{:apiVersion=>\"0.1\", :swaggerVersion=>\"1.1\", :basePath=>\"#{SimpleApiWithBasePath::NON_DEFAULT_BASE_PATH}\", :resourcePath=>\"\", :apis=>[{:path=>\"/something.{format}\", :operations=>[{:notes=>nil, :summary=>\"this gets something\", :nickname=>\"GET-something---format-\", :httpMethod=>\"GET\", :parameters=>[]}]}]}"
33
31
  end
34
32
  end
35
33
 
36
- context "overruling the basepath" do
37
- class SimpleApiWithAPiVersion < Grape::API
38
- API_VERSION = "101"
39
-
40
- mount MountedApi
41
- add_swagger_documentation :api_version => API_VERSION
34
+ context "overruling the version" do
35
+ before(:all) do
36
+ class ApiVersionMountedApi < Grape::API
37
+ desc 'this gets something'
38
+ get '/something' do
39
+ {:bla => 'something'}
40
+ end
41
+ end
42
+
43
+ class SimpleApiWithApiVersion < Grape::API
44
+ API_VERSION = "101"
45
+
46
+ mount ApiVersionMountedApi
47
+ add_swagger_documentation :api_version => API_VERSION
48
+ end
42
49
  end
43
50
 
44
- subject { SimpleApiWithAPiVersion.new }
45
- def app; subject end
51
+ def app; SimpleApiWithApiVersion end
46
52
 
47
- it "retrieves the given base-path on /swagger_doc" do
53
+ it "retrieves the api version on /swagger_doc" do
48
54
  get '/swagger_doc'
49
- last_response.body.should == "{:apiVersion=>\"#{SimpleApiWithAPiVersion::API_VERSION}\", :swaggerVersion=>\"1.1\", :basePath=>\"http://example.org\", :operations=>[], :apis=>[{:path=>\"/swagger_doc/something.{format}\"}, {:path=>\"/swagger_doc/swagger_doc.{format}\"}]}"
55
+ last_response.body.should == "{:apiVersion=>\"#{SimpleApiWithApiVersion::API_VERSION}\", :swaggerVersion=>\"1.1\", :basePath=>\"http://example.org\", :operations=>[], :apis=>[{:path=>\"/swagger_doc/something.{format}\"}, {:path=>\"/swagger_doc/swagger_doc.{format}\"}]}"
50
56
  end
51
57
 
52
- it "retrieves the same given base-path for mounted-api" do
53
- Random.stub(:rand) { 0 }
58
+ it "retrieves the same api version for mounted-api" do
54
59
  get '/swagger_doc/something'
55
- last_response.body.should == "{:apiVersion=>\"#{SimpleApiWithAPiVersion::API_VERSION}\", :swaggerVersion=>\"1.1\", :basePath=>\"http://example.org\", :resourcePath=>\"\", :apis=>[{:path=>\"/something.{format}\", :operations=>[{:notes=>nil, :summary=>\"this gets something\", :nickname=>0, :httpMethod=>\"GET\", :parameters=>[]}]}]}"
60
+ last_response.body.should == "{:apiVersion=>\"#{SimpleApiWithApiVersion::API_VERSION}\", :swaggerVersion=>\"1.1\", :basePath=>\"http://example.org\", :resourcePath=>\"\", :apis=>[{:path=>\"/something.{format}\", :operations=>[{:notes=>nil, :summary=>\"this gets something\", :nickname=>\"GET-something---format-\", :httpMethod=>\"GET\", :parameters=>[]}]}]}"
56
61
  end
57
62
  end
58
63
 
59
64
  context "overruling the mount-path" do
60
- class SimpleApiWithDifferentMount < Grape::API
61
- MOUNT_PATH = "api_doc"
62
-
63
- mount MountedApi
64
- add_swagger_documentation :mount_path => MOUNT_PATH
65
+ before(:all) do
66
+ class DifferentMountMountedApi < Grape::API
67
+ desc 'this gets something'
68
+ get '/something' do
69
+ {:bla => 'something'}
70
+ end
71
+ end
72
+
73
+ class SimpleApiWithDifferentMount < Grape::API
74
+ MOUNT_PATH = "/api_doc"
75
+
76
+ mount DifferentMountMountedApi
77
+ add_swagger_documentation :mount_path => MOUNT_PATH
78
+ end
65
79
  end
66
80
 
67
- subject { SimpleApiWithDifferentMount.new }
68
- def app; subject end
81
+ def app; SimpleApiWithDifferentMount end
69
82
 
70
- it "retrieves the given base-path on /swagger_doc" do
83
+ it "retrieves the given base-path on /api_doc" do
71
84
  get '/api_doc'
72
- last_response.body.should == "{:apiVersion=>\"0.1\", :swaggerVersion=>\"1.1\", :basePath=>\"http://example.org\", :operations=>[], :apis=>[{:path=>\"/swagger_doc/something.{format}\"}, {:path=>\"/swagger_doc/swagger_doc.{format}\"}]}"
85
+ last_response.body.should == "{:apiVersion=>\"0.1\", :swaggerVersion=>\"1.1\", :basePath=>\"http://example.org\", :operations=>[], :apis=>[{:path=>\"/api_doc/something.{format}\"}, {:path=>\"/api_doc/api_doc.{format}\"}]}"
73
86
  end
74
87
 
75
88
  it "retrieves the same given base-path for mounted-api" do
76
- Random.stub(:rand) { 0 }
77
89
  get '/api_doc/something'
78
- last_response.body.should == "{:apiVersion=>\"0.1\", :swaggerVersion=>\"1.1\", :basePath=>\"http://example.org\", :resourcePath=>\"\", :apis=>[{:path=>\"/something.{format}\", :operations=>[{:notes=>nil, :summary=>\"this gets something\", :nickname=>0, :httpMethod=>\"GET\", :parameters=>[]}]}]}"
90
+ last_response.body.should == "{:apiVersion=>\"0.1\", :swaggerVersion=>\"1.1\", :basePath=>\"http://example.org\", :resourcePath=>\"\", :apis=>[{:path=>\"/something.{format}\", :operations=>[{:notes=>nil, :summary=>\"this gets something\", :nickname=>\"GET-something---format-\", :httpMethod=>\"GET\", :parameters=>[]}]}]}"
79
91
  end
80
92
 
81
93
  it "does not respond to swagger_doc" do
@@ -84,5 +96,29 @@ describe "overruling the defaults for the api documentation generation" do
84
96
  end
85
97
  end
86
98
 
99
+ context "overruling the markdown" do
100
+ before(:all) do
101
+ class MarkDownMountedApi < Grape::API
102
+ desc 'this gets something', {
103
+ :notes => '_test_'
104
+ }
105
+ get '/something' do
106
+ {:bla => 'something'}
107
+ end
108
+ end
109
+
110
+ class SimpleApiWithMarkdown < Grape::API
111
+ mount MarkDownMountedApi
112
+ add_swagger_documentation :markdown => true
113
+ end
114
+ end
115
+
116
+ def app; SimpleApiWithMarkdown end
117
+
118
+ it "parses markdown for a mounted-api" do
119
+ get '/swagger_doc/something'
120
+ last_response.body.should == "{:apiVersion=>\"0.1\", :swaggerVersion=>\"1.1\", :basePath=>\"http://example.org\", :resourcePath=>\"\", :apis=>[{:path=>\"/something.{format}\", :operations=>[{:notes=>\"<p><em>test</em></p>\\n\", :summary=>\"this gets something\", :nickname=>\"GET-something---format-\", :httpMethod=>\"GET\", :parameters=>[]}]}]}"
121
+ end
122
+ end
87
123
 
88
124
  end
@@ -1,30 +1,31 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe "a simple mounted api" do
4
-
5
- class MountedApi < Grape::API
6
- desc 'this gets something'
7
- get '/something' do
8
- {:bla => 'something'}
4
+ before(:all) do
5
+ class SimpleMountedApi < Grape::API
6
+ desc 'this gets something', {
7
+ :notes => '_test_'
8
+ }
9
+ get '/simple' do
10
+ {:bla => 'something'}
11
+ end
9
12
  end
10
- end
11
13
 
12
- class SimpleApi < Grape::API
13
- mount MountedApi
14
- add_swagger_documentation
14
+ class SimpleApi < Grape::API
15
+ mount SimpleMountedApi
16
+ add_swagger_documentation
17
+ end
15
18
  end
16
19
 
17
- subject { SimpleApi.new }
18
- def app; subject end
20
+ def app; SimpleApi end
19
21
 
20
22
  it "retrieves swagger-documentation on /swagger_doc" do
21
23
  get '/swagger_doc'
22
- last_response.body.should == "{:apiVersion=>\"0.1\", :swaggerVersion=>\"1.1\", :basePath=>\"http://example.org\", :operations=>[], :apis=>[{:path=>\"/swagger_doc/something.{format}\"}, {:path=>\"/swagger_doc/swagger_doc.{format}\"}]}"
24
+ last_response.body.should == "{:apiVersion=>\"0.1\", :swaggerVersion=>\"1.1\", :basePath=>\"http://example.org\", :operations=>[], :apis=>[{:path=>\"/swagger_doc/simple.{format}\"}, {:path=>\"/swagger_doc/swagger_doc.{format}\"}]}"
23
25
  end
24
26
 
25
27
  it "retrieves the documentation for mounted-api" do
26
- Random.stub(:rand) { 0 }
27
- get '/swagger_doc/something'
28
- last_response.body.should == "{:apiVersion=>\"0.1\", :swaggerVersion=>\"1.1\", :basePath=>\"http://example.org\", :resourcePath=>\"\", :apis=>[{:path=>\"/something.{format}\", :operations=>[{:notes=>nil, :summary=>\"this gets something\", :nickname=>0, :httpMethod=>\"GET\", :parameters=>[]}]}]}"
28
+ get '/swagger_doc/simple'
29
+ last_response.body.should == "{:apiVersion=>\"0.1\", :swaggerVersion=>\"1.1\", :basePath=>\"http://example.org\", :resourcePath=>\"\", :apis=>[{:path=>\"/simple.{format}\", :operations=>[{:notes=>\"_test_\", :summary=>\"this gets something\", :nickname=>\"GET-simple---format-\", :httpMethod=>\"GET\", :parameters=>[]}]}]}"
29
30
  end
30
31
  end
data/spec/spec_helper.rb CHANGED
@@ -7,6 +7,9 @@ require 'grape-swagger'
7
7
 
8
8
  require 'rubygems'
9
9
  require 'bundler'
10
+
11
+ require 'pry'
12
+
10
13
  Bundler.setup :default, :test
11
14
 
12
15
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape-swagger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,10 +9,26 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-27 00:00:00.000000000 Z
12
+ date: 2012-08-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: grape
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.2.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.2.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: kramdown
16
32
  requirement: !ruby/object:Gem::Requirement
17
33
  none: false
18
34
  requirements:
@@ -92,39 +108,7 @@ dependencies:
92
108
  - !ruby/object:Gem::Version
93
109
  version: 1.8.4
94
110
  - !ruby/object:Gem::Dependency
95
- name: jquery-rails
96
- requirement: !ruby/object:Gem::Requirement
97
- none: false
98
- requirements:
99
- - - ! '>='
100
- - !ruby/object:Gem::Version
101
- version: '0'
102
- type: :development
103
- prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
- requirements:
107
- - - ! '>='
108
- - !ruby/object:Gem::Version
109
- version: '0'
110
- - !ruby/object:Gem::Dependency
111
- name: rails
112
- requirement: !ruby/object:Gem::Requirement
113
- none: false
114
- requirements:
115
- - - ~>
116
- - !ruby/object:Gem::Version
117
- version: '3.2'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
- requirements:
123
- - - ~>
124
- - !ruby/object:Gem::Version
125
- version: '3.2'
126
- - !ruby/object:Gem::Dependency
127
- name: sqlite3
111
+ name: pry
128
112
  requirement: !ruby/object:Gem::Requirement
129
113
  none: false
130
114
  requirements:
@@ -155,22 +139,6 @@ dependencies:
155
139
  - - ! '>='
156
140
  - !ruby/object:Gem::Version
157
141
  version: '0'
158
- - !ruby/object:Gem::Dependency
159
- name: rspec-rails
160
- requirement: !ruby/object:Gem::Requirement
161
- none: false
162
- requirements:
163
- - - ! '>='
164
- - !ruby/object:Gem::Version
165
- version: '0'
166
- type: :development
167
- prerelease: false
168
- version_requirements: !ruby/object:Gem::Requirement
169
- none: false
170
- requirements:
171
- - - ! '>='
172
- - !ruby/object:Gem::Version
173
- version: '0'
174
142
  - !ruby/object:Gem::Dependency
175
143
  name: rspec
176
144
  requirement: !ruby/object:Gem::Requirement
@@ -225,7 +193,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
225
193
  version: '0'
226
194
  segments:
227
195
  - 0
228
- hash: -2449825622916780559
196
+ hash: -3173865515529886165
229
197
  required_rubygems_version: !ruby/object:Gem::Requirement
230
198
  none: false
231
199
  requirements: