grape-swagger 0.7.2 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +33 -0
  3. data/.rubocop.yml +36 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/.travis.yml +3 -0
  7. data/CHANGELOG.md +90 -0
  8. data/CONTRIBUTING.md +126 -0
  9. data/Gemfile +1 -21
  10. data/LICENSE.txt +1 -1
  11. data/README.md +397 -0
  12. data/RELEASING.md +80 -0
  13. data/Rakefile +6 -23
  14. data/UPGRADING.md +47 -0
  15. data/grape-swagger.gemspec +26 -84
  16. data/lib/grape-swagger.rb +237 -111
  17. data/lib/grape-swagger/errors.rb +9 -0
  18. data/lib/grape-swagger/markdown.rb +23 -0
  19. data/lib/grape-swagger/markdown/kramdown_adapter.rb +37 -0
  20. data/lib/grape-swagger/markdown/redcarpet_adapter.rb +89 -0
  21. data/lib/grape-swagger/version.rb +3 -0
  22. data/spec/api_description_spec.rb +41 -0
  23. data/spec/api_global_models_spec.rb +76 -0
  24. data/spec/api_models_spec.rb +190 -93
  25. data/spec/default_api_spec.rb +31 -36
  26. data/spec/form_params_spec.rb +56 -53
  27. data/spec/grape-swagger_helper_spec.rb +88 -49
  28. data/spec/grape-swagger_spec.rb +7 -5
  29. data/spec/hide_api_spec.rb +58 -55
  30. data/spec/markdown/kramdown_adapter_spec.rb +38 -0
  31. data/spec/markdown/markdown_spec.rb +27 -0
  32. data/spec/markdown/redcarpet_adapter_spec.rb +81 -0
  33. data/spec/namespaced_api_spec.rb +47 -0
  34. data/spec/non_default_api_spec.rb +372 -222
  35. data/spec/response_model_spec.rb +80 -0
  36. data/spec/simple_mounted_api_spec.rb +113 -118
  37. data/spec/spec_helper.rb +0 -1
  38. data/spec/version_spec.rb +8 -0
  39. data/test/api.rb +62 -0
  40. data/test/config.ru +10 -2
  41. data/test/splines.png +0 -0
  42. metadata +145 -91
  43. data/.rvmrc +0 -48
  44. data/CHANGELOG.markdown +0 -55
  45. data/Gemfile.lock +0 -94
  46. data/README.markdown +0 -168
  47. data/VERSION +0 -1
  48. data/test/nested_api.rb +0 -30
data/test/config.ru CHANGED
@@ -1,2 +1,10 @@
1
- require './nested_api'
2
- run SimpleApi.new
1
+ require 'rack/cors'
2
+ use Rack::Cors do
3
+ allow do
4
+ origins '*'
5
+ resource '*', headers: :any, methods: [ :get, :post, :put, :delete, :options ]
6
+ end
7
+ end
8
+
9
+ require './api'
10
+ run Api.new
data/test/splines.png ADDED
Binary file
metadata CHANGED
@@ -1,235 +1,289 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape-swagger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
5
- prerelease:
4
+ version: 0.8.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Tim Vandecasteele
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-02-06 00:00:00.000000000 Z
11
+ date: 2014-08-31 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: grape
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
- version: 0.2.0
19
+ version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
- version: 0.2.0
26
+ version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: grape-entity
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
- version: 0.3.0
33
+ version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
- version: 0.3.0
40
+ version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
- name: kramdown
42
+ name: rake
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
- version: 1.3.1
54
- type: :runtime
47
+ version: '0'
48
+ type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
- version: 1.3.1
54
+ version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: shoulda
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - ">="
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - ">="
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rdoc
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ~>
73
+ - - ">="
84
74
  - !ruby/object:Gem::Version
85
- version: '3.12'
75
+ version: '0'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ~>
80
+ - - ">="
92
81
  - !ruby/object:Gem::Version
93
- version: '3.12'
82
+ version: '0'
94
83
  - !ruby/object:Gem::Dependency
95
- name: bundler
84
+ name: rspec
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ! '>'
87
+ - - "~>"
100
88
  - !ruby/object:Gem::Version
101
- version: 1.0.0
89
+ version: '3.0'
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ! '>'
94
+ - - "~>"
108
95
  - !ruby/object:Gem::Version
109
- version: 1.0.0
96
+ version: '3.0'
110
97
  - !ruby/object:Gem::Dependency
111
- name: jeweler
98
+ name: bundler
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
- - - ~>
101
+ - - ">="
116
102
  - !ruby/object:Gem::Version
117
- version: 1.8.4
103
+ version: '0'
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
- - - ~>
108
+ - - ">="
124
109
  - !ruby/object:Gem::Version
125
- version: 1.8.4
110
+ version: '0'
126
111
  - !ruby/object:Gem::Dependency
127
- name: pry
112
+ name: rack-test
128
113
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
114
  requirements:
131
- - - ! '>='
115
+ - - ">="
132
116
  - !ruby/object:Gem::Version
133
117
  version: '0'
134
118
  type: :development
135
119
  prerelease: false
136
120
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
121
  requirements:
139
- - - ! '>='
122
+ - - ">="
140
123
  - !ruby/object:Gem::Version
141
124
  version: '0'
142
125
  - !ruby/object:Gem::Dependency
143
- name: rack-test
126
+ name: rack-cors
144
127
  requirement: !ruby/object:Gem::Requirement
145
- none: false
146
128
  requirements:
147
- - - ! '>='
129
+ - - ">="
148
130
  - !ruby/object:Gem::Version
149
131
  version: '0'
150
132
  type: :development
151
133
  prerelease: false
152
134
  version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
135
  requirements:
155
- - - ! '>='
136
+ - - ">="
156
137
  - !ruby/object:Gem::Version
157
138
  version: '0'
158
139
  - !ruby/object:Gem::Dependency
159
- name: rspec
140
+ name: rubocop
160
141
  requirement: !ruby/object:Gem::Requirement
161
- none: false
162
142
  requirements:
163
- - - ! '>='
143
+ - - '='
164
144
  - !ruby/object:Gem::Version
165
- version: '0'
145
+ version: 0.24.1
166
146
  type: :development
167
147
  prerelease: false
168
148
  version_requirements: !ruby/object:Gem::Requirement
169
- none: false
170
149
  requirements:
171
- - - ! '>='
150
+ - - '='
172
151
  - !ruby/object:Gem::Version
173
- version: '0'
174
- description: A simple way to add proper auto generated documentation - that can be
175
- displayed with swagger - to your inline described grape API
176
- email: tim.vandecasteele@gmail.com
152
+ version: 0.24.1
153
+ - !ruby/object:Gem::Dependency
154
+ name: kramdown
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: 1.4.1
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: 1.4.1
167
+ - !ruby/object:Gem::Dependency
168
+ name: redcarpet
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: 3.1.2
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: 3.1.2
181
+ - !ruby/object:Gem::Dependency
182
+ name: rouge
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: 1.6.1
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: 1.6.1
195
+ description:
196
+ email:
197
+ - tim.vandecasteele@gmail.com
177
198
  executables: []
178
199
  extensions: []
179
- extra_rdoc_files:
180
- - LICENSE.txt
181
- - README.markdown
200
+ extra_rdoc_files: []
182
201
  files:
183
- - .document
184
- - .rspec
185
- - .rvmrc
186
- - .travis.yml
187
- - CHANGELOG.markdown
202
+ - ".document"
203
+ - ".gitignore"
204
+ - ".rspec"
205
+ - ".rubocop.yml"
206
+ - ".ruby-gemset"
207
+ - ".ruby-version"
208
+ - ".travis.yml"
209
+ - CHANGELOG.md
210
+ - CONTRIBUTING.md
188
211
  - Gemfile
189
- - Gemfile.lock
190
212
  - LICENSE.txt
191
- - README.markdown
213
+ - README.md
214
+ - RELEASING.md
192
215
  - Rakefile
193
- - VERSION
216
+ - UPGRADING.md
194
217
  - grape-swagger.gemspec
195
218
  - lib/grape-swagger.rb
219
+ - lib/grape-swagger/errors.rb
220
+ - lib/grape-swagger/markdown.rb
221
+ - lib/grape-swagger/markdown/kramdown_adapter.rb
222
+ - lib/grape-swagger/markdown/redcarpet_adapter.rb
223
+ - lib/grape-swagger/version.rb
224
+ - spec/api_description_spec.rb
225
+ - spec/api_global_models_spec.rb
196
226
  - spec/api_models_spec.rb
197
227
  - spec/default_api_spec.rb
198
228
  - spec/form_params_spec.rb
199
229
  - spec/grape-swagger_helper_spec.rb
200
230
  - spec/grape-swagger_spec.rb
201
231
  - spec/hide_api_spec.rb
232
+ - spec/markdown/kramdown_adapter_spec.rb
233
+ - spec/markdown/markdown_spec.rb
234
+ - spec/markdown/redcarpet_adapter_spec.rb
235
+ - spec/namespaced_api_spec.rb
202
236
  - spec/non_default_api_spec.rb
237
+ - spec/response_model_spec.rb
203
238
  - spec/simple_mounted_api_spec.rb
204
239
  - spec/spec_helper.rb
240
+ - spec/version_spec.rb
241
+ - test/api.rb
205
242
  - test/config.ru
206
- - test/nested_api.rb
207
- homepage: http://github.com/tim-vandecasteele/grape-swagger
243
+ - test/splines.png
244
+ homepage: https://github.com/tim-vandecasteele/grape-swagger
208
245
  licenses:
209
246
  - MIT
247
+ metadata: {}
210
248
  post_install_message:
211
249
  rdoc_options: []
212
250
  require_paths:
213
251
  - lib
214
252
  required_ruby_version: !ruby/object:Gem::Requirement
215
- none: false
216
253
  requirements:
217
- - - ! '>='
254
+ - - ">="
218
255
  - !ruby/object:Gem::Version
219
256
  version: '0'
220
- segments:
221
- - 0
222
- hash: -17008049882572761
223
257
  required_rubygems_version: !ruby/object:Gem::Requirement
224
- none: false
225
258
  requirements:
226
- - - ! '>='
259
+ - - ">="
227
260
  - !ruby/object:Gem::Version
228
261
  version: '0'
229
262
  requirements: []
230
263
  rubyforge_project:
231
- rubygems_version: 1.8.23
264
+ rubygems_version: 2.2.2
232
265
  signing_key:
233
- specification_version: 3
234
- summary: Add swagger compliant documentation to your grape API
235
- test_files: []
266
+ specification_version: 4
267
+ summary: A simple way to add auto generated documentation to your Grape API that can
268
+ be displayed with Swagger.
269
+ test_files:
270
+ - spec/api_description_spec.rb
271
+ - spec/api_global_models_spec.rb
272
+ - spec/api_models_spec.rb
273
+ - spec/default_api_spec.rb
274
+ - spec/form_params_spec.rb
275
+ - spec/grape-swagger_helper_spec.rb
276
+ - spec/grape-swagger_spec.rb
277
+ - spec/hide_api_spec.rb
278
+ - spec/markdown/kramdown_adapter_spec.rb
279
+ - spec/markdown/markdown_spec.rb
280
+ - spec/markdown/redcarpet_adapter_spec.rb
281
+ - spec/namespaced_api_spec.rb
282
+ - spec/non_default_api_spec.rb
283
+ - spec/response_model_spec.rb
284
+ - spec/simple_mounted_api_spec.rb
285
+ - spec/spec_helper.rb
286
+ - spec/version_spec.rb
287
+ - test/api.rb
288
+ - test/config.ru
289
+ - test/splines.png
data/.rvmrc DELETED
@@ -1,48 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
- # development environment upon cd'ing into the directory
5
-
6
- # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
7
- # Only full ruby name is supported here, for short names use:
8
- # echo "rvm use 1.9.3" > .rvmrc
9
- environment_id="ruby-1.9.3@grape-swagger"
10
-
11
- # Uncomment the following lines if you want to verify rvm version per project
12
- # rvmrc_rvm_version="1.14.3 (stable)" # 1.10.1 seams as a safe start
13
- # eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
14
- # echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
15
- # return 1
16
- # }
17
-
18
- # First we attempt to load the desired environment directly from the environment
19
- # file. This is very fast and efficient compared to running through the entire
20
- # CLI and selector. If you want feedback on which environment was used then
21
- # insert the word 'use' after --create as this triggers verbose mode.
22
- if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
23
- && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
24
- then
25
- \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
26
- [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
27
- \. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
28
- else
29
- # If the environment file has not yet been created, use the RVM CLI to select.
30
- rvm --create "$environment_id" || {
31
- echo "Failed to create RVM environment '${environment_id}'."
32
- return 1
33
- }
34
- fi
35
-
36
- # If you use bundler, this might be useful to you:
37
- # if [[ -s Gemfile ]] && {
38
- # ! builtin command -v bundle >/dev/null ||
39
- # builtin command -v bundle | GREP_OPTIONS= \grep $rvm_path/bin/bundle >/dev/null
40
- # }
41
- # then
42
- # printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
43
- # gem install bundler
44
- # fi
45
- # if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
46
- # then
47
- # bundle install | GREP_OPTIONS= \grep -vE '^Using|Your bundle is complete'
48
- # fi
data/CHANGELOG.markdown DELETED
@@ -1,55 +0,0 @@
1
- ### Next Release
2
-
3
- * Fix: translate parameter `type` to String, enables using Mongoid fields as parameter definitions - [@dblock](https://github.com/dblock).
4
- * Adding support for generating swagger responseClass and models from Grape Entities - [@calebwoods](https://github.com/calebwoods).
5
- * Adding hidden endpoints - [@arturoherrero](https://github.com/arturoherrero).
6
- * Fix: allow urls with `-` - [@dadario](https://github.com/dadario).
7
- * Fix: mounting multiple documentations - [@Drakula2k](https://github.com/Drakula2k).
8
- * Fix: resource groupings for prefixed APIs - [@aew](https://github.com/aew).
9
- * Fix: hide_documentation_path on prefixed APIs - [@spier](https://github.com/spier).
10
- * Your Contribution Here
11
-
12
- ### 0.6.0 (June 19, 2013)
13
-
14
- * Added Rails 4 support - [@jrhe](https://github.com/jrhe).
15
- * Fix: document APIs at root level - [@dblock](https://github.com/dblock).
16
- * Added support for procs in basepath - [@tim-vandecasteele](https://github.com/tim-vandecasteele).
17
- * Support both `:desc` and `:description` when describing parameters - [@dblock](https://github.com/dblock).
18
- * Fix: allow parameters such as `name[]` - [@dblock](https://github.com/dblock).
19
-
20
- ### 0.5.0 (March 28, 2013)
21
-
22
- * Added Grape 0.5.0 support - [@tim-vandecasteele](https://github.com/tim-vandecasteele).
23
-
24
- ### 0.4.0 (March 28, 2013)
25
-
26
- * Support https - [@cutalion](https://github.com/cutalion).
27
-
28
- ### 0.3.0 (October 19, 2012)
29
-
30
- * Added version support - [@agileanimal](https://github.com/agileanimal), [@fknappe](https://github.com/fknappe).
31
- * Added support for nested parameters - [@tim-vandecasteele](https://github.com/tim-vandecasteele).
32
- * Added basic support for specifying parameters that need to be passed in the header - [@agileanimal](https://github.com/agileanimal).
33
- * Add possibility to hide the documentation paths in the generated swagger documentation - [@tim-vandecasteele](https://github.com/tim-vandecasteele).
34
-
35
- ### 0.2.1 (August 17, 2012)
36
-
37
- * Added support for markdown in notes field - [@tim-vandecasteele](https://github.com/tim-vandecasteele).
38
- * Fix: compatibility with Rails - [@qwert666](https://github.com/qwert666).
39
- * Fix: swagger UI history - [@tim-vandecasteele](https://github.com/tim-vandecasteele).
40
-
41
- ### 0.2.0 (July 27, 2012)
42
-
43
- * Use resource as root for swagger - [@tim-vandecasteele](https://github.com/tim-vandecasteele).
44
- * Added support for file uploads, and proper `paramType` - [@tim-vandecasteele](https://github.com/tim-vandecasteele).
45
- * Added tests - [@nathanvda](https://github.com/nathanvda).
46
-
47
- ### 0.1.0 (July 19, 2012)
48
-
49
- * Added some configurability to the generated documentation - [@tim-vandecasteele](https://github.com/tim-vandecasteele).
50
- * Adapted to rails plugin structure - [@tim-vandecasteele](https://github.com/tim-vandecasteele).
51
- * Allowed cross origin, so swagger can be used from official site - [@tim-vandecasteele](https://github.com/tim-vandecasteele).
52
-
53
- ### 0.0.0 (July 19, 2012)
54
-
55
- * Initial public release - [@tim-vandecasteele](https://github.com/tim-vandecasteele).