grape-swagger 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -1,4 +1,5 @@
1
1
  rvm:
2
+ - jruby-19mode
2
3
  - 1.9.3
3
4
  - 2.0.0
4
5
 
data/Gemfile CHANGED
@@ -5,7 +5,7 @@ source "http://rubygems.org"
5
5
 
6
6
  gem 'grape', '>= 0.2.0'
7
7
  gem 'grape-entity', '>= 0.3.0'
8
- gem 'github-markdown'
8
+ gem 'kramdown', '>= 1.3.1'
9
9
 
10
10
  # Add dependencies to develop your gem here.
11
11
  # Include everything needed to run rake, tests, features, etc.
data/Gemfile.lock CHANGED
@@ -11,7 +11,6 @@ GEM
11
11
  diff-lcs (1.1.3)
12
12
  ffi (1.9.3-java)
13
13
  git (1.2.5)
14
- github-markdown (0.6.4)
15
14
  grape (0.5.0)
16
15
  activesupport
17
16
  builder
@@ -34,6 +33,7 @@ GEM
34
33
  rdoc
35
34
  json (1.7.3)
36
35
  json (1.7.3-java)
36
+ kramdown (1.3.1)
37
37
  method_source (0.8)
38
38
  multi_json (1.7.7)
39
39
  multi_xml (0.5.4)
@@ -83,10 +83,10 @@ PLATFORMS
83
83
 
84
84
  DEPENDENCIES
85
85
  bundler (> 1.0.0)
86
- github-markdown
87
86
  grape (>= 0.2.0)
88
87
  grape-entity (>= 0.3.0)
89
88
  jeweler (~> 1.8.4)
89
+ kramdown (>= 1.3.1)
90
90
  pry
91
91
  rack-test
92
92
  rdoc (~> 3.12)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.0
1
+ 0.7.1
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "grape-swagger"
8
- s.version = "0.7.0"
8
+ s.version = "0.7.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"]
@@ -52,7 +52,7 @@ Gem::Specification.new do |s|
52
52
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
53
53
  s.add_runtime_dependency(%q<grape>, [">= 0.2.0"])
54
54
  s.add_runtime_dependency(%q<grape-entity>, [">= 0.3.0"])
55
- s.add_runtime_dependency(%q<github-markdown>, [">= 0"])
55
+ s.add_runtime_dependency(%q<kramdown>, [">= 1.3.1"])
56
56
  s.add_development_dependency(%q<shoulda>, [">= 0"])
57
57
  s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
58
58
  s.add_development_dependency(%q<bundler>, ["> 1.0.0"])
@@ -63,7 +63,7 @@ Gem::Specification.new do |s|
63
63
  else
64
64
  s.add_dependency(%q<grape>, [">= 0.2.0"])
65
65
  s.add_dependency(%q<grape-entity>, [">= 0.3.0"])
66
- s.add_dependency(%q<github-markdown>, [">= 0"])
66
+ s.add_dependency(%q<kramdown>, [">= 1.3.1"])
67
67
  s.add_dependency(%q<shoulda>, [">= 0"])
68
68
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
69
69
  s.add_dependency(%q<bundler>, ["> 1.0.0"])
@@ -75,7 +75,7 @@ Gem::Specification.new do |s|
75
75
  else
76
76
  s.add_dependency(%q<grape>, [">= 0.2.0"])
77
77
  s.add_dependency(%q<grape-entity>, [">= 0.3.0"])
78
- s.add_dependency(%q<github-markdown>, [">= 0"])
78
+ s.add_dependency(%q<kramdown>, [">= 1.3.1"])
79
79
  s.add_dependency(%q<shoulda>, [">= 0"])
80
80
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
81
81
  s.add_dependency(%q<bundler>, ["> 1.0.0"])
data/lib/grape-swagger.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'github/markdown'
1
+ require 'kramdown'
2
2
 
3
3
  module Grape
4
4
  class API
@@ -49,6 +49,7 @@ module Grape
49
49
  :markdown => false,
50
50
  :hide_documentation_path => false,
51
51
  :hide_format => false,
52
+ :format => nil,
52
53
  :models => [],
53
54
  :info => {},
54
55
  :authorizations => nil,
@@ -72,6 +73,12 @@ module Grape
72
73
 
73
74
  @@hide_documentation_path = options[:hide_documentation_path]
74
75
 
76
+ if options[:format]
77
+ [:format, :default_format, :default_error_formatter].each do |method|
78
+ send(method, options[:format])
79
+ end
80
+ end
81
+
75
82
  desc 'Swagger compatible API description'
76
83
  get @@mount_path do
77
84
  header['Access-Control-Allow-Origin'] = '*'
@@ -175,7 +182,7 @@ module Grape
175
182
  helpers do
176
183
 
177
184
  def as_markdown(description)
178
- description && @@markdown ? GitHub::Markdown.render_gfm(strip_heredoc(description)) : description
185
+ description && @@markdown ? Kramdown::Document.new(strip_heredoc(description), :input => 'GFM', :enable_coderay => false).to_html : description
179
186
  end
180
187
 
181
188
  def parse_params(params, path, method)
@@ -520,4 +520,29 @@ describe "options: " do
520
520
  }
521
521
  end
522
522
  end
523
+
524
+ context ":formatting" do
525
+ before :all do
526
+ class JSONDefaultFormatAPI < Grape::API
527
+ desc 'This gets something.'
528
+ get '/something' do
529
+ { bla: 'something' }
530
+ end
531
+ end
532
+
533
+ class SimpleJSONFormattedAPI < Grape::API
534
+ mount JSONDefaultFormatAPI
535
+ add_swagger_documentation format: :json
536
+ end
537
+ end
538
+
539
+ def app; SimpleJSONFormattedAPI; end
540
+
541
+ it "defaults to JSON format when none is specified" do
542
+ get '/swagger_doc/something'
543
+
544
+ lambda{ JSON.parse(last_response.body) }.should_not raise_error
545
+ end
546
+
547
+ end
523
548
  end
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.7.0
4
+ version: 0.7.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -44,13 +44,13 @@ dependencies:
44
44
  - !ruby/object:Gem::Version
45
45
  version: 0.3.0
46
46
  - !ruby/object:Gem::Dependency
47
- name: github-markdown
47
+ name: kramdown
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  none: false
50
50
  requirements:
51
51
  - - ! '>='
52
52
  - !ruby/object:Gem::Version
53
- version: '0'
53
+ version: 1.3.1
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
@@ -58,7 +58,7 @@ dependencies:
58
58
  requirements:
59
59
  - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: 1.3.1
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: shoulda
64
64
  requirement: !ruby/object:Gem::Requirement
@@ -217,7 +217,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
217
217
  version: '0'
218
218
  segments:
219
219
  - 0
220
- hash: 1382622318618846643
220
+ hash: -4023410877516363028
221
221
  required_rubygems_version: !ruby/object:Gem::Requirement
222
222
  none: false
223
223
  requirements: