model_driven_api 3.11.0 → 3.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f10db84ebc3b2fbb5b3461fcaa14c879096999fcdef4c90353172ac8313af7eb
|
|
4
|
+
data.tar.gz: ca43a58797580f249f6b48c80f3be07b607731a6a1973d04dc6d9af64adc654c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 39ca452f1c60589d6406de607425ce798a84882a366aa42ad648a8dc6b16e05e9535d6db18a8ea578b623ba6fcf1ec2a9c241a667369dd0fc03f505acad1a96f
|
|
7
|
+
data.tar.gz: 1c2dfe78a0c08f66eaf09bc6550213a988c42295549f0e7ffb23a66d13bea8a134ce52fb06dc60e65e67cca91f3dbe818929ffd5743bbc2cb460318e2551b982
|
|
@@ -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:
|
|
9
|
+
render json: { version: ModelDrivenApi.app_version }.to_json, status: 200
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
# api :GET, '/api/v2/info/roles'
|
|
@@ -3,7 +3,12 @@ module ApiExceptionManagement
|
|
|
3
3
|
|
|
4
4
|
included do
|
|
5
5
|
if Rails.env.production?
|
|
6
|
-
|
|
6
|
+
# ORDER MATTERS: Rails tries rescue_from handlers from the LAST declared to the
|
|
7
|
+
# first, so the StandardError catch-all must be declared FIRST. Declared last (as it
|
|
8
|
+
# was until 3.11.0) it shadowed every specific handler below: in production every
|
|
9
|
+
# AccessDenied (wrong login credentials), RecordNotFound, RecordInvalid, CanCan
|
|
10
|
+
# denial... answered 500. Covered by spec/lib/concerns/api_exception_management_spec.rb.
|
|
11
|
+
rescue_from StandardError, with: :fivehundred!
|
|
7
12
|
rescue_from CanCan::AccessDenied, with: :unauthorized!
|
|
8
13
|
rescue_from AuthenticateUser::AccessDenied, with: :unauthenticated!
|
|
9
14
|
rescue_from ActionController::RoutingError, with: :not_found!
|
|
@@ -17,8 +22,12 @@ module ApiExceptionManagement
|
|
|
17
22
|
rescue_from ActiveRecord::RecordNotUnique, with: :invalid!
|
|
18
23
|
# Rescue Stale Object in Optimistick locking with stale!
|
|
19
24
|
rescue_from ActiveRecord::StaleObjectError, with: :stale!
|
|
20
|
-
rescue_from EndpointValidationError, with: :
|
|
21
|
-
|
|
25
|
+
rescue_from EndpointValidationError, with: :endpoint_invalid!
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# api_error takes keywords only, so it can't be a rescue_from handler itself.
|
|
29
|
+
def endpoint_invalid! exception = EndpointValidationError.new
|
|
30
|
+
return api_error status: 501, errors: exception.message
|
|
22
31
|
end
|
|
23
32
|
|
|
24
33
|
def stale! exception = StandardError.new
|
data/lib/model_driven_api.rb
CHANGED
|
@@ -28,6 +28,14 @@ require "api/v3/serializer_factory"
|
|
|
28
28
|
module ModelDrivenApi
|
|
29
29
|
UTC_ZONE_NAMES = %w[UTC Etc/UTC].freeze
|
|
30
30
|
|
|
31
|
+
# The host app's deployed version: the `version` file in its root (Thecore release convention —
|
|
32
|
+
# CI builds and deploys when it changes; the image is `ADD . /app`, so it ships in Rails.root).
|
|
33
|
+
# nil when the app has no such file. Served by GET /api/v2|v3/info/version.
|
|
34
|
+
def self.app_version
|
|
35
|
+
file = Rails.root.join("version")
|
|
36
|
+
file.file? ? file.read.strip.presence : nil
|
|
37
|
+
end
|
|
38
|
+
|
|
31
39
|
# Raises unless the app is UTC-only: +time_zone+ is config.time_zone, +db_zone+ is
|
|
32
40
|
# config.active_record.default_timezone (nil = Rails' default, :utc). Called at boot by
|
|
33
41
|
# ModelDrivenApi::Engine's :enforce_utc_time_zone initializer.
|