easy-jsonapi 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/publish.yml +2 -2
- data/CHANGELOG.md +7 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/easy-jsonapi.gemspec +1 -1
- data/lib/easy/jsonapi/exceptions/headers_exceptions.rb +1 -1
- data/lib/easy/jsonapi/exceptions/query_params_exceptions.rb +1 -1
- data/lib/easy/jsonapi/exceptions/user_defined_exceptions.rb +6 -2
- data/lib/easy/jsonapi/middleware.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f07199316723dad3e81762871162c088abf1a0d4a6c5096e2033bace38ab2339
|
4
|
+
data.tar.gz: 58691051c1a6e488155ddc878695a3c186a4c852aedd967f0e914fb5dfe2fa0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6922ea8ef89f1ac9c28943ddb946bc12066268aec49ac402a997367e945388453fb09b3f67c1155c40a622b9df19c62dfa28e95bc087c978c65f7aa7545c4b66
|
7
|
+
data.tar.gz: 99b888ed918f0b783b4bf22a61b76b6b44ac0fffc8b4fc414727a32e5ac621f1573233526a37f1efb54394be7618d52afe7401309c63523018a8d9ee2457b5a3
|
@@ -51,7 +51,7 @@ jobs:
|
|
51
51
|
env:
|
52
52
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
|
53
53
|
with:
|
54
|
-
tag_name:
|
55
|
-
release_name: Release
|
54
|
+
tag_name: 1.0.5
|
55
|
+
release_name: Release 1.0.5
|
56
56
|
draft: false
|
57
57
|
prerelease: false
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## 1.0.5 - 2020-03-30
|
4
|
+
|
5
|
+
- Fixed bug in JSONAPI::Exceptions::HeadersExceptions that didn't check for user required headers requirements
|
6
|
+
- Fixed bug in JSONAPI::Exceptions::QueryParamExceptions that didn't check for user required query param requirements
|
7
|
+
- Added more tests to the middleware
|
8
|
+
- Updated Documentation
|
9
|
+
|
3
10
|
## 1.0.4 - 2020-03-28
|
4
11
|
|
5
12
|
- Fixed JSONAPI::ExceptionsHeadersExceptions bug
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -21,7 +21,7 @@ Ever wanted the benefits of [JSONAPI](https://jsonapi.org/) without the learning
|
|
21
21
|
2. A `parser` to interact with requests in a typical Object-Oriented Fashion, providing convenient and efficient access to headers, query parameters, and document members.
|
22
22
|
3. A `validator` to check your serialized responses for [JSONAPI](https://jsonapi.org/) compliance.
|
23
23
|
|
24
|
-
With its only gem dependency being [Oj](https://github.com/ohler55/oj), ***easy-jsonapi*** is a lightweight, dependable tool, featuring comprehensive error messages and over ***
|
24
|
+
With its only gem dependency being [Oj](https://github.com/ohler55/oj), ***easy-jsonapi*** is a lightweight, dependable tool, featuring comprehensive error messages and over ***525 unit tests*** allowing developers to spend less time debugging and more time creating.
|
25
25
|
|
26
26
|
As a bonus, flexible user configurations can be added to the middleware providing custom screening on all requests or individual requests depending on the resource type of the endpoint and the user-defined document, header, or query param restrictions.
|
27
27
|
|
data/easy-jsonapi.gemspec
CHANGED
@@ -39,7 +39,7 @@ module JSONAPI
|
|
39
39
|
hdrs = JSONAPI::Parser::HeadersParser.parse(env)
|
40
40
|
usr_opts = { http_method: opts[:http_method], path: opts[:path] }
|
41
41
|
err_msg = JSONAPI::Exceptions::UserDefinedExceptions.check_user_header_requirements(hdrs, config_manager, usr_opts)
|
42
|
-
|
42
|
+
raise err_msg unless err_msg.nil?
|
43
43
|
end
|
44
44
|
|
45
45
|
class << self
|
@@ -62,8 +62,10 @@ module JSONAPI
|
|
62
62
|
# with underscores instead of dashes.
|
63
63
|
# @param config (see #check_user_document_requirements)
|
64
64
|
def check_user_header_requirements(headers, config_manager, opts)
|
65
|
-
return if config_manager.nil?
|
65
|
+
return if config_manager.nil?
|
66
|
+
|
66
67
|
config = get_config(config_manager, opts[:http_method], opts[:path])
|
68
|
+
return if config.default? && config_manager.size.positive?
|
67
69
|
|
68
70
|
err =
|
69
71
|
check_for_required_headers(headers, config.required_headers)
|
@@ -77,8 +79,10 @@ module JSONAPI
|
|
77
79
|
# @param rack_req_params [Hash] The hash of the query parameters given by Rack::Request
|
78
80
|
# @param config (see #check_user_document_requirements)
|
79
81
|
def check_user_query_param_requirements(rack_req_params, config_manager, opts)
|
80
|
-
return if config_manager.nil?
|
82
|
+
return if config_manager.nil?
|
83
|
+
|
81
84
|
config = get_config(config_manager, opts[:http_method], opts[:path])
|
85
|
+
return if config.default? && config_manager.size.positive?
|
82
86
|
|
83
87
|
err =
|
84
88
|
check_for_required_params(rack_req_params, config.required_query_params)
|
@@ -111,7 +111,7 @@ module JSONAPI
|
|
111
111
|
# @return [NilClass | Array] Nil meaning no error or a 400 level http response
|
112
112
|
def check_headers_compliance(env, body, config_manager, opts)
|
113
113
|
JSONAPI::Exceptions::HeadersExceptions.check_request(env, body, config_manager, opts)
|
114
|
-
rescue JSONAPI::Exceptions::HeadersExceptions::InvalidHeader
|
114
|
+
rescue JSONAPI::Exceptions::HeadersExceptions::InvalidHeader, JSONAPI::Exceptions::UserDefinedExceptions::InvalidHeader => e
|
115
115
|
raise if environment_development?(env)
|
116
116
|
|
117
117
|
[e.status_code, {}, []]
|
@@ -122,7 +122,7 @@ module JSONAPI
|
|
122
122
|
# @return [NilClass | Array] Nil meaning no error or a 400 level http response
|
123
123
|
def check_query_param_compliance(env, query_params, config_manager, opts)
|
124
124
|
JSONAPI::Exceptions::QueryParamsExceptions.check_compliance(query_params, config_manager, opts)
|
125
|
-
rescue JSONAPI::Exceptions::QueryParamsExceptions::InvalidQueryParameter
|
125
|
+
rescue JSONAPI::Exceptions::QueryParamsExceptions::InvalidQueryParameter, JSONAPI::Exceptions::UserDefinedExceptions::InvalidQueryParam => e
|
126
126
|
raise if environment_development?(env)
|
127
127
|
|
128
128
|
[e.status_code, {}, []]
|
@@ -133,7 +133,7 @@ module JSONAPI
|
|
133
133
|
# @raise If the document body is not JSONAPI compliant
|
134
134
|
def check_req_body_compliance(env, body, config_manager, opts)
|
135
135
|
JSONAPI::Exceptions::DocumentExceptions.check_compliance(body, config_manager, opts)
|
136
|
-
rescue JSONAPI::Exceptions::DocumentExceptions::InvalidDocument
|
136
|
+
rescue JSONAPI::Exceptions::DocumentExceptions::InvalidDocument, JSONAPI::Exceptions::UserDefinedExceptions::InvalidDocument => e
|
137
137
|
raise if environment_development?(env)
|
138
138
|
|
139
139
|
[e.status_code, {}, []]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easy-jsonapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua DeMoss, Joe Viscomi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03-
|
11
|
+
date: 2021-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|