model_driven_api 2.3.4 → 2.3.9

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: b3732e187808e98168a540463302b48f5c790b636ec3058d8fe1d1368fe8d00c
4
- data.tar.gz: e3cc94ae51641832ad46712014fd5519937d1d2533e1c8866e1fd04a9372f57a
3
+ metadata.gz: 1da45cd3ee59fe0a531f304af8a0333559584977238737395b78864a1020b2c2
4
+ data.tar.gz: 49a829a12437ab3f901cad50689ef4d6de74824db86f42e5be5b050d897f9229
5
5
  SHA512:
6
- metadata.gz: 3cb118e13b3362bd98396a5cf639ba3de1f8e5e161c36e21f04f9bbfacb7c722a985aef6baf5a249fe12fc6ba4572c62277905cdeb148c4b42742abf069b0726
7
- data.tar.gz: 3dddb43d8f95f6203523ef3d770867682179e5d8abc04838bd42ef5809c91b1f458093c799ddee7d3758a008560f6802315b90fce0d9b83b71ff3272849cdea5
6
+ metadata.gz: 24bca1df42a775c4ea9d74d75ec6ac02de6e68e4e4693d433c03c2a1016535db81c9a2e37c419a4f51552f62c928306383db999a20448bf89aeac012449ecf52
7
+ data.tar.gz: 8a345a1bc8d20e846b98d653bec7b8a6da86136cf88d5b38fa278476f10a5fb2785d31f8fe73bf03061b209d95f2fc2c27f426bf73c6cad93682f62507165abc
@@ -129,7 +129,6 @@ class Api::V2::ApplicationController < ActionController::API
129
129
  # puts "Found header #{header}: #{request.headers[header.underscore.dasherize]}"
130
130
  check_authorization("Authorize#{header}".constantize.call(request.headers, request.raw_post)) if request.headers[header.underscore.dasherize]
131
131
  end
132
- return unauthenticated!(OpenStruct.new({message: @auth_errors})) unless @current_user
133
132
 
134
133
  # This is the default one, if the header doesn't have a valid form for one of the other Auth methods, then use this Auth Class
135
134
  check_authorization AuthorizeApiRequest.call(request.headers) unless @current_user
@@ -149,7 +148,11 @@ class Api::V2::ApplicationController < ActionController::API
149
148
  end
150
149
 
151
150
  def json_attrs
152
- ((@model.json_attrs.presence || @json_attrs.presence || {}) rescue {})
151
+ # In order of importance: if you send the configuration via querystring you are ok
152
+ # has precedence over if you have setup the json_attrs in the model concern
153
+ from_params = params[:a].deep_symbolize_keys unless params[:a].blank?
154
+ from_params = params[:json_attrs].deep_symbolize_keys unless params[:json_attrs].blank?
155
+ from_params.presence || @model.json_attrs.presence || @json_attrs.presence || {} rescue {}
153
156
  end
154
157
 
155
158
  def extract_model
@@ -6,7 +6,7 @@ class Api::V2::InfoController < Api::V2::ApplicationController
6
6
 
7
7
  # api :GET, '/api/v2/info/version', "Just prints the APPVERSION."
8
8
  def version
9
- render json: { version: ModelDrivenApi::VERSION }.to_json, status: 200
9
+ render json: { version: "TODO: Find a Way to Dynamically Obtain It" }.to_json, status: 200
10
10
  end
11
11
 
12
12
  # api :GET, '/api/v2/info/roles'
@@ -0,0 +1,8 @@
1
+ # Turns API calls to always UTC, leaving the APP the freedom to use local timezone
2
+ module ActiveSupport
3
+ class TimeWithZone
4
+ def as_json(options = nil)
5
+ utc
6
+ end
7
+ end
8
+ end
@@ -2,13 +2,15 @@ module ApiExceptionManagement
2
2
  extend ActiveSupport::Concern
3
3
 
4
4
  included do
5
- rescue_from NoMethodError, with: :not_found!
6
- rescue_from CanCan::AccessDenied, with: :unauthorized!
7
- rescue_from AuthenticateUser::AccessDenied, with: :unauthenticated!
8
- rescue_from ActionController::RoutingError, with: :not_found!
9
- rescue_from ActiveModel::ForbiddenAttributesError, with: :fivehundred!
10
- rescue_from ActiveRecord::RecordInvalid, with: :invalid!
11
- rescue_from ActiveRecord::RecordNotFound, with: :not_found!
5
+ if Rails.env.production?
6
+ rescue_from NoMethodError, with: :not_found!
7
+ rescue_from CanCan::AccessDenied, with: :unauthorized!
8
+ rescue_from AuthenticateUser::AccessDenied, with: :unauthenticated!
9
+ rescue_from ActionController::RoutingError, with: :not_found!
10
+ rescue_from ActiveModel::ForbiddenAttributesError, with: :fivehundred!
11
+ rescue_from ActiveRecord::RecordInvalid, with: :invalid!
12
+ rescue_from ActiveRecord::RecordNotFound, with: :not_found!
13
+ end
12
14
 
13
15
  def unauthenticated! exception = AuthenticateUser::AccessDenied.new
14
16
  response.headers['WWW-Authenticate'] = "Token realm=Application"
@@ -33,7 +35,7 @@ module ApiExceptionManagement
33
35
 
34
36
  def api_error(status: 500, errors: [])
35
37
  # puts errors.full_messages if !Rails.env.production? && errors.respond_to?(:full_messages)
36
- head status && return if errors.empty?
38
+ head status && return if errors.blank?
37
39
 
38
40
  # For retrocompatibility, I try to send back only strings, as errors
39
41
  errors_response = if errors.respond_to?(:full_messages)
@@ -1,3 +1,3 @@
1
1
  module ModelDrivenApi
2
- VERSION = "#{`git describe --tags $(git rev-list --tags --max-count=1)`}"
2
+ VERSION = "#{`git describe --tags $(git rev-list --tags --max-count=1)`.chomp}"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: model_driven_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.4
4
+ version: 2.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriele Tassoni
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-10 00:00:00.000000000 Z
11
+ date: 2021-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thecore_backend_commons
@@ -142,6 +142,7 @@ files:
142
142
  - config/initializers/after_initialize_for_model_driven_api.rb
143
143
  - config/initializers/cors_api_thecore.rb
144
144
  - config/initializers/knock.rb
145
+ - config/initializers/time_with_zone.rb
145
146
  - config/initializers/wrap_parameters.rb
146
147
  - config/routes.rb
147
148
  - lib/concerns/api_exception_management.rb