introspective_grape 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4a21e9540c7f4929e4dced1d88eb599edb4e887b
4
- data.tar.gz: e97148d4dd00bba79807d6b52a79a29073fbbc9f
3
+ metadata.gz: d8dc4cc268e2946259654e5b44eb1841afb3a2a1
4
+ data.tar.gz: 4110a9992a24fb544a58c3185abce336694499f0
5
5
  SHA512:
6
- metadata.gz: 4236508d67aac2b65c1ed4123c4bfd63ab76851c1a4cbc17d943326bc01530ac9cc57f336954cfde83713fbb4020751a1e201dbe58a585e919aa3a7c23a7f7aa
7
- data.tar.gz: d80ccf25f1db8187717fb57f6e8a8f82f2fb8889154efc0b96121bdf5a022f193de94380fc222ec8aeecc19d1041f99edbbd10234a2ba8ca50e1c4c15ee03ee1
6
+ metadata.gz: 9ed73bf254659358fba6e9635ed8bf4d38fbba2349e42a9636bd7a99b38d87f854ee05c6fb3430b94c899f641ebd62f31189a957d86ab1b55de60b3e2fff1872
7
+ data.tar.gz: aa5b91683e4f66eb1de93cb08fb537127aa3bc109c4388d6c60b266edbf1ca079527fbcbaa2d024e834e2d1cb3cf66bef6a9757bcd0f1a44e56b69609a9c5734
data/.gitignore CHANGED
@@ -2,7 +2,7 @@
2
2
  .DS_Store
3
3
  .byebug_history
4
4
  log/*.log
5
- Gemfile.lock
5
+ *Gemfile.lock
6
6
  pkg/
7
7
  spec/dummy/db/*.sqlite3
8
8
  spec/dummy/db/*.sqlite3-journal
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.1.2
1
+ 2.3.0
data/.travis.yml CHANGED
@@ -8,14 +8,21 @@ script:
8
8
 
9
9
  rvm:
10
10
  - 2.3.0
11
- - 2.2
12
- - 2.1
13
- - 2.0.0
14
- - jruby-9.0.4.0
11
+ - 2.2.6
15
12
  - ruby-head
16
13
  - jruby-head
17
-
18
14
  matrix:
15
+ include:
16
+ # We'll have to back up to grape-swagger 0.11 for earlier rubies.
17
+ - rvm: 2.0.0
18
+ gemfile: gemfiles/2.0.0-Gemfile
19
+ - rvm: 2.1.0
20
+ gemfile: gemfiles/2.0.0-Gemfile
21
+ - rvm: 2.2.0
22
+ gemfile: gemfiles/2.0.0-Gemfile
23
+ - rvm: jruby-9.0.4.0
24
+ gemfile: gemfiles/2.0.0-Gemfile
25
+
19
26
  allow_failures:
20
27
  - rvm: ruby-head
21
28
  - rvm: jruby-head
@@ -25,6 +32,7 @@ env:
25
32
  - RAILS=3.2.22
26
33
  - RAILS=4.1.13
27
34
  - RAILS=4.2.5.1
35
+ - RAILS=5.0.1
28
36
  - RAILS=master
29
37
  global:
30
38
  - JRUBY_OPTS="-J-Xmx1024m --debug"
data/CHANGELOG.md CHANGED
@@ -1,4 +1,10 @@
1
1
 
2
+ 0.2.7 01/18/2017
3
+ ==============
4
+
5
+ Add support for Swagger 2+, we can now support the latest versions of grape and other dependencies.
6
+
7
+
2
8
  0.2.6 11/01/2016
3
9
  ==============
4
10
 
data/README.md CHANGED
@@ -152,7 +152,7 @@ class MyModelAPI < IntrospectiveGrape::API
152
152
  end
153
153
  ```
154
154
 
155
- Multiple values can be specified at once for Integer attributes that end in "id" (i.e. conventional primary and foreign keys) at once by passing a comma separated list of IDs.
155
+ Multiple values can be specified at once for Integer attributes that end in "id" (i.e. conventional primary and foreign keys) by passing a comma separated list of IDs.
156
156
 
157
157
  For timestamp attributes it will generate `<name_of_timestamp>_start` and `<name_of_timestamp>_end` constraints.
158
158
 
@@ -0,0 +1,22 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Declare your gem's dependencies in introspective_grape.gemspec.
4
+ # Bundler will treat runtime dependencies like base dependencies, and
5
+ # development dependencies will be added by default to the :development group.
6
+
7
+ gemspec :path => '../'
8
+
9
+ gem 'grape', '0.16.2'
10
+ gem 'grape-swagger', '~> 0.11.0'
11
+ gem 'nokogiri', '~> 1.6.8'
12
+ gem 'coveralls', require: false
13
+
14
+ # Declare any dependencies that are still in development here instead of in
15
+ # your gemspec. These might include edge Rails or gems from your path or
16
+ # Git. Remember to move these dependencies to your gemspec before releasing
17
+ # your gem to rubygems.org.
18
+
19
+ group :development,:test do
20
+ gem 'rspec'
21
+ # gem 'byebug'
22
+ end
@@ -22,12 +22,13 @@ Gem::Specification.new do |s|
22
22
 
23
23
  s.add_dependency "rails", '>= 3.0.0', '< 5.0.0'
24
24
 
25
- s.add_dependency 'grape', '~> 0.16.2'
26
- s.add_dependency 'grape-entity', '< 0.5.0'
27
- s.add_dependency 'grape-swagger', '~>0.11.0'
28
- s.add_dependency 'grape-kaminari', '~>0.1.9'
25
+ s.add_dependency 'grape' #, '~> 0.16.2'
26
+ s.add_dependency 'grape-entity' #, '< 0.5.0'
27
+ s.add_dependency 'grape-swagger' #, '~>0.11.0'
28
+ s.add_dependency 'kaminari', '< 1.0' # There's a version 1.0.0 out there that breaks everything
29
+ s.add_dependency 'grape-kaminari'
29
30
  s.add_dependency 'pundit'
30
- s.add_dependency 'camel_snake_keys', '~>0.0.4'
31
+ s.add_dependency 'camel_snake_keys'
31
32
 
32
33
  if RUBY_PLATFORM == 'java'
33
34
  #s.add_development_dependency "jdbc-sqlite3"
@@ -1,7 +1,6 @@
1
1
  require 'grape-swagger'
2
2
  require 'active_support' #/core_ext/module/aliasing'
3
3
  require 'camel_snake_keys'
4
-
5
4
  if IntrospectiveGrape.config.camelize_parameters
6
5
  # Camelize the parameters in the swagger documentation.
7
6
  if Gem::Version.new( GrapeSwagger::VERSION ) <= Gem::Version.new('0.11.0')
@@ -31,10 +30,23 @@ if IntrospectiveGrape.config.camelize_parameters
31
30
  end
32
31
  end
33
32
  else Gem::Version.new( GrapeSwagger::VERSION ) > Gem::Version.new('0.11.0')
34
- # Grape::Swagger 0.20.xx is not yet compatible with Grape >0.14 and will alter
35
- # the way it parses params, so will not be compatible with introspective_grape,
36
- # and produces swagger docs for SwaggerUI 2.1.4 that don't appear to be
37
- # backwards compatible swagger.js 2.0.41, so this is pending.
33
+ module GrapeSwagger
34
+ module DocMethods
35
+ def self.extended(mod)
36
+ # Do not camelize the grape-swagger documentation endpoints.
37
+ mod.formatter :json, Grape::Formatter::Json
38
+ end
39
+ class ParseParams
40
+ class << self
41
+ def call_with_camelized(*args)
42
+ param = call_without_camelized(*args)
43
+ param[:name] = param[:name].camelize(:lower).gsub(/Destroy/, '_destroy')
44
+ param
45
+ end
46
+ alias_method_chain :call, :camelized
47
+ end
48
+ end
49
+ end
50
+ end
38
51
  end
39
-
40
52
  end
@@ -16,7 +16,7 @@ module Grape::Validators
16
16
  begin
17
17
  raise unless JSON.parse( params[field] ).kind_of? Array
18
18
  rescue
19
- fail Grape::Exceptions::Validation, params: [@scope.full_name(field)], message: 'must be valid JSON array!'
19
+ fail Grape::Exceptions::Validation, params: [@scope.full_name(field)], message: 'must be a valid JSON array!'
20
20
  end
21
21
  end
22
22
  end
@@ -26,7 +26,7 @@ module Grape::Validators
26
26
  begin
27
27
  raise unless JSON.parse( params[field] ).kind_of? Hash
28
28
  rescue
29
- fail Grape::Exceptions::Validation, params: [@scope.full_name(field)], message: 'must be valid JSON hash!'
29
+ fail Grape::Exceptions::Validation, params: [@scope.full_name(field)], message: 'must be a valid JSON hash!'
30
30
  end
31
31
  end
32
32
  end
@@ -1,3 +1,3 @@
1
1
  module IntrospectiveGrape
2
- VERSION = "0.2.6".freeze
2
+ VERSION = "0.2.7".freeze
3
3
  end
data/spec/dummy/Gemfile CHANGED
@@ -1,6 +1,19 @@
1
1
  source 'https://rubygems.org'
2
+ gem 'rails', '<5.0'
3
+
4
+ #gem 'byebug'
5
+
6
+ gem 'grape'
7
+ gem 'grape-entity'
8
+ gem 'grape-swagger'
2
9
  gem 'grape-kaminari'
10
+
3
11
  gem 'pundit'
4
- #gem 'byebug'
5
12
  gem 'paperclip'
6
13
  gem 'delayed_paperclip'
14
+ gem 'devise-async'
15
+ gem 'activerecord-tableless'
16
+
17
+ gem 'camel_snake_keys'
18
+
19
+ gem 'sqlite3'
@@ -46,12 +46,18 @@ class DummyAPI < Grape::API
46
46
  # configure grape-swagger to auto-generate swagger docs
47
47
  protocol = Rails.application.config.force_ssl ? 'https' : 'http'
48
48
  add_swagger_documentation({
49
- base_path: "#{protocol}://localhost:3000/api",
50
- api_version: 'v1',
51
- hide_documentation_path: true,
52
- format: :json,
53
- hide_format: true
54
- #markdown: true
49
+ base_path: "/api",
50
+ doc_version: 'v1',
51
+ hide_documentation_path: true,
52
+ format: :json,
53
+ hide_format: true,
54
+ security_definitions: {
55
+ api_key: {
56
+ type: "apiKey",
57
+ name: "api_key",
58
+ in: "header"
59
+ }
60
+ }
55
61
  })
56
62
 
57
63
  end
@@ -33,6 +33,6 @@ module Dummy
33
33
 
34
34
  # Do not swallow errors in after_commit/after_rollback callbacks.
35
35
  config.active_record.raise_in_transactional_callbacks = true
36
+
36
37
  end
37
38
  end
38
-
@@ -93,12 +93,12 @@ describe Dummy::CompanyAPI, type: :request do
93
93
 
94
94
  it "should validate json array parameters" do
95
95
  put "/api/v1/companies/#{company.id}", { widgets: "[garbage[\"A\",\"B\"]" }
96
- json["error"].should eq "widgets must be valid JSON array!"
96
+ json["error"].should eq "widgets must be a valid JSON array!"
97
97
  end
98
98
 
99
99
  it "should validate json hash parameters" do
100
100
  put "/api/v1/companies/#{company.id}", { sprockets: "{\"foo\":\"bar\"}garbage}" }
101
- json["error"].should eq "sprockets must be valid JSON hash!"
101
+ json["error"].should eq "sprockets must be a valid JSON hash!"
102
102
  end
103
103
 
104
104
  end
@@ -7,8 +7,14 @@ describe GrapeSwagger, type: :request do
7
7
  get '/api/v1/swagger_doc'
8
8
  response.should be_success
9
9
  json = JSON.parse( response.body )
10
- json['apiVersion'].should == 'v1'
10
+ if Gem::Version.new( GrapeSwagger::VERSION ) <= Gem::Version.new('0.11.0')
11
+ json['apiVersion'].should == '0.1'
12
+ else
13
+ json['paths'].map {|p| p[1].values }.flatten.map{|p| p['parameters']}.flatten.compact.map{|p| p['name']}.each do |name|
14
+ name.should eq name.camelize(:lower).gsub(/Destroy/,'_destroy')
15
+ end
16
+ end
11
17
  end
12
- end
13
18
 
19
+ end
14
20
  end
@@ -29,7 +29,7 @@ Company.blueprint do
29
29
  end
30
30
 
31
31
  User.blueprint do
32
- email { "test-"+word(5)+'@springshot.com' }
32
+ email { "test-"+word(10)+'@springshot.com' }
33
33
  first_name { word(4) }
34
34
  last_name { word(5) }
35
35
  password { 'abc12345' }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: introspective_grape
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Buermann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-08 00:00:00.000000000 Z
11
+ date: 2017-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -34,58 +34,72 @@ dependencies:
34
34
  name: grape
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - "~>"
37
+ - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: 0.16.2
39
+ version: '0'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - "~>"
44
+ - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: 0.16.2
46
+ version: '0'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: grape-entity
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - "<"
51
+ - - ">="
52
52
  - !ruby/object:Gem::Version
53
- version: 0.5.0
53
+ version: '0'
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - "<"
58
+ - - ">="
59
59
  - !ruby/object:Gem::Version
60
- version: 0.5.0
60
+ version: '0'
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: grape-swagger
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - "~>"
65
+ - - ">="
66
66
  - !ruby/object:Gem::Version
67
- version: 0.11.0
67
+ version: '0'
68
68
  type: :runtime
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
- - - "~>"
72
+ - - ">="
73
73
  - !ruby/object:Gem::Version
74
- version: 0.11.0
74
+ version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: kaminari
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "<"
80
+ - !ruby/object:Gem::Version
81
+ version: '1.0'
82
+ type: :runtime
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "<"
87
+ - !ruby/object:Gem::Version
88
+ version: '1.0'
75
89
  - !ruby/object:Gem::Dependency
76
90
  name: grape-kaminari
77
91
  requirement: !ruby/object:Gem::Requirement
78
92
  requirements:
79
- - - "~>"
93
+ - - ">="
80
94
  - !ruby/object:Gem::Version
81
- version: 0.1.9
95
+ version: '0'
82
96
  type: :runtime
83
97
  prerelease: false
84
98
  version_requirements: !ruby/object:Gem::Requirement
85
99
  requirements:
86
- - - "~>"
100
+ - - ">="
87
101
  - !ruby/object:Gem::Version
88
- version: 0.1.9
102
+ version: '0'
89
103
  - !ruby/object:Gem::Dependency
90
104
  name: pundit
91
105
  requirement: !ruby/object:Gem::Requirement
@@ -104,16 +118,16 @@ dependencies:
104
118
  name: camel_snake_keys
105
119
  requirement: !ruby/object:Gem::Requirement
106
120
  requirements:
107
- - - "~>"
121
+ - - ">="
108
122
  - !ruby/object:Gem::Version
109
- version: 0.0.4
123
+ version: '0'
110
124
  type: :runtime
111
125
  prerelease: false
112
126
  version_requirements: !ruby/object:Gem::Requirement
113
127
  requirements:
114
- - - "~>"
128
+ - - ">="
115
129
  - !ruby/object:Gem::Version
116
- version: 0.0.4
130
+ version: '0'
117
131
  - !ruby/object:Gem::Dependency
118
132
  name: sqlite3
119
133
  requirement: !ruby/object:Gem::Requirement
@@ -266,6 +280,7 @@ files:
266
280
  - app/models/.keep
267
281
  - app/views/.keep
268
282
  - bin/rails
283
+ - gemfiles/2.0.0-Gemfile
269
284
  - introspective_grape.gemspec
270
285
  - lib/.DS_Store
271
286
  - lib/introspective_grape.rb
@@ -444,7 +459,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
444
459
  version: '0'
445
460
  requirements: []
446
461
  rubyforge_project:
447
- rubygems_version: 2.2.2
462
+ rubygems_version: 2.6.8
448
463
  signing_key:
449
464
  specification_version: 4
450
465
  summary: Introspectively configure deeply nested RESTful Grape APIs for ActiveRecord