introspective_grape 0.5.4 → 0.5.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
  SHA256:
3
- metadata.gz: 18e335c3487696da5b56e184df1b4ad6495c890e72e2652ee3ef14841a786f94
4
- data.tar.gz: a18f28ce34addce187ed64af8273c5866c68a63463456dc1acc101a2cab349eb
3
+ metadata.gz: d29e073d96e9a6f2569eeaec65ece289f344fd5f0b6ea88a0dfb345d36d51052
4
+ data.tar.gz: dac77dd6bc6812de00ec06ee5299c5cea5ff0f3539a304e6a1d1335f72e69f36
5
5
  SHA512:
6
- metadata.gz: 77b1c4910e315342e2febc3bcca3a0b7b2eb59d1c7b762325a7da6bc60f0f8e69e34ddb2907b2cc76ce0b824367f10d365c7899ffb1f95f3f10444173c9bd3c8
7
- data.tar.gz: b13267c8b605afa2a4daa6b5620f87e628a105f9271cb8bc437e579bbf3a4f9fe451f4e1935623338c0bd1ec2a205c72275fce27e0b1cf7e2124cc4232553e25
6
+ metadata.gz: 118befdc8fca693dd91610d8c0ecff86ca2e297cdb1b3817384b1fa78958a5949f1d252cc70eadf2187bee87080fb9949382e656b6765f259f4d23bba7fd2c47
7
+ data.tar.gz: 21f3339a6e874bca7d94fa3efcd92812afbbc0e9b74371cafc8eb3e1644334930671ee59841a13237998272acc06954916a5b09ccd9eb760df38c8b3a28557f9
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.5.0
1
+ 2.7.3
data/CHANGELOG.md CHANGED
@@ -1,7 +1,23 @@
1
1
 
2
- 0.5.3 02/07/2022
2
+ 0.5.7 03/10/2022
3
3
  ================
4
4
 
5
+ Handle the switch from Grape::Validations::Base to Grape::Validations::Validators::Base.
6
+
7
+ 0.5.6 03/09/2022
8
+ ================
9
+
10
+ On the DELETE endpoint the primary key with its type was undeclared, creating conflicts with user-defined delete endpoints.
11
+
12
+ 0.5.5 02/24/2022
13
+ ================
14
+
15
+ Update the local ruby in the gem to 2.7.3 to clear security warning cruft.
16
+
17
+ Sanitize some sql.
18
+
19
+ Target the still-supported 'kt-paperclip' in the gemspec (many pardons while we're planning the switch over to activestorage support).
20
+
5
21
  Fix bug from looking for the ActiveRecord columns_hash on non-ActiveRecord objects.
6
22
 
7
23
  0.5.2 02/07/2022
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
22
22
  s.files = `git ls-files`.split("\n").sort
23
23
  s.test_files = `git ls-files -- spec/*`.split("\n")
24
24
 
25
- s.required_ruby_version = '>= 2.5'
25
+ s.required_ruby_version = '> 2.5'
26
26
 
27
27
  s.add_runtime_dependency 'rails', '~> 5.2'
28
28
  s.add_runtime_dependency 'schema_validations'
@@ -57,7 +57,7 @@ Gem::Specification.new do |s|
57
57
  s.add_development_dependency 'machinist_redux'
58
58
 
59
59
  # dummy app dependencies
60
- s.add_development_dependency 'paperclip'
60
+ s.add_development_dependency 'kt-paperclip'
61
61
  s.add_development_dependency 'rufus-mnemo'
62
62
  s.add_development_dependency 'devise'
63
63
  end
@@ -99,13 +99,15 @@ module IntrospectiveGrape
99
99
  # As routes are nested keep track of the routes, we are preventing siblings from
100
100
  # appending to the routes array here:
101
101
  routes = build_routes(routes, model)
102
- define_routes(routes, whitelist)
103
102
 
104
103
  # Top level declaration of the Grape::API namespace for the resource:
105
104
  resource routes.first.name.pluralize do
106
- # yield to append additional routes under the root namespace
105
+ # yield to prepend user-defined routes under the root namespace first,
107
106
  yield if block_given?
108
107
  end
108
+
109
+ # Then define IntrospectiveGrape's routes:
110
+ define_routes(routes, whitelist)
109
111
  end
110
112
 
111
113
  def define_routes(routes, api_params)
@@ -209,12 +211,15 @@ module IntrospectiveGrape
209
211
  end
210
212
 
211
213
  # rubocop:enable Metrics/AbcSize
212
- def define_destroy(dsl, routes, _model, _api_params)
214
+ def define_destroy(dsl, routes, model, _api_params)
213
215
  klass = routes.first.klass
214
- name = routes.last.name.singularize
216
+ name = routes.last.name.singularize
215
217
  dsl.desc "destroy a #{name}" do
216
218
  detail klass.destroy_documentation(name)
217
219
  end
220
+ dsl.params do
221
+ requires routes.last.swagger_key, type: klass.param_type(model, model.primary_key)
222
+ end
218
223
  dsl.delete ":#{routes.last.swagger_key}" do
219
224
  authorize @model, :destroy?
220
225
  present status: (klass.find_leaf(routes, @model, params).destroy ? true : false)
@@ -91,7 +91,7 @@ module IntrospectiveGrape
91
91
 
92
92
  if timestamp_filter(klass, model, field)
93
93
  op = field.ends_with?('_start') ? '>=' : '<='
94
- records.where("#{timestamp_filter(klass, model, field)} #{op} ?", Time.zone.parse(params[field]))
94
+ records.where(ActiveRecord::Base.sanitize_sql_array(["#{timestamp_filter(klass, model, field)} #{op} ?", Time.zone.parse(params[field])]))
95
95
  elsif model.respond_to?("#{field}=")
96
96
  records.send("#{field}=", params[field])
97
97
  else
@@ -1,7 +1,9 @@
1
1
  require 'grape/validations'
2
2
  module Grape
3
3
  module Validators
4
- class Json < Grape::Validations::Base
4
+ # Validations::Base becomes Validators::Base somewhere between 1.6.0 and 1.6.2
5
+ validation_class = defined?(Grape::Validations::Base) ? Grape::Validations::Base : Grape::Validations::Validators::Base
6
+ class Json < validation_class
5
7
  def validate_param!(field, params)
6
8
  begin
7
9
  JSON.parse( params[field] )
@@ -11,7 +13,7 @@ module Grape
11
13
  end
12
14
  end
13
15
 
14
- class JsonArray < Grape::Validations::Base
16
+ class JsonArray < validation_class
15
17
  def validate_param!(field, params)
16
18
  begin
17
19
  raise unless JSON.parse( params[field] ).is_a? Array
@@ -21,7 +23,7 @@ module Grape
21
23
  end
22
24
  end
23
25
 
24
- class JsonHash < Grape::Validations::Base
26
+ class JsonHash < validation_class
25
27
  def validate_param!(field, params)
26
28
  begin
27
29
  raise unless JSON.parse( params[field] ).is_a? Hash
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IntrospectiveGrape
4
- VERSION = '0.5.4'
4
+ VERSION = '0.5.7'
5
5
  end
data/spec/dummy/Gemfile CHANGED
@@ -1,19 +1,19 @@
1
1
  source 'https://rubygems.org'
2
- gem 'rails', '5.2.6'
2
+ gem 'rails', '5.2.6.2'
3
3
 
4
4
  gem 'byebug'
5
5
  gem 'camel_snake_keys'
6
6
 
7
7
  gem 'devise'
8
8
  gem 'delayed_paperclip'
9
- #gem 'devise-async'
9
+ gem 'kt-paperclip'
10
10
 
11
11
  gem 'grape'
12
12
  gem 'grape-entity'
13
13
  gem 'grape-kaminari'
14
14
  gem 'grape-swagger'
15
15
  gem 'grape-swagger-entity'
16
- gem 'introspective_grape', path: '~/Dropbox/contrib/introspective_grape'
16
+ gem 'introspective_grape' #, path: '~/Dropbox/contrib/introspective_grape'
17
17
 
18
18
  gem 'paperclip'
19
19
  gem 'pundit'
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.5.4
4
+ version: 0.5.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: 2022-02-24 00:00:00.000000000 Z
11
+ date: 2022-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -291,7 +291,7 @@ dependencies:
291
291
  - !ruby/object:Gem::Version
292
292
  version: '0'
293
293
  - !ruby/object:Gem::Dependency
294
- name: paperclip
294
+ name: kt-paperclip
295
295
  requirement: !ruby/object:Gem::Requirement
296
296
  requirements:
297
297
  - - ">="
@@ -531,7 +531,7 @@ require_paths:
531
531
  - lib
532
532
  required_ruby_version: !ruby/object:Gem::Requirement
533
533
  requirements:
534
- - - ">="
534
+ - - ">"
535
535
  - !ruby/object:Gem::Version
536
536
  version: '2.5'
537
537
  required_rubygems_version: !ruby/object:Gem::Requirement
@@ -540,8 +540,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
540
540
  - !ruby/object:Gem::Version
541
541
  version: '0'
542
542
  requirements: []
543
- rubyforge_project:
544
- rubygems_version: 2.7.3
543
+ rubygems_version: 3.1.6
545
544
  signing_key:
546
545
  specification_version: 4
547
546
  summary: Quickly configure Grape APIs around your database schema and models.