easy-jsonapi 1.0.4 → 1.0.5

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: 0ba6257960cd5fce1e43183afd073ef8effb8de8a7fa2d162eed112948be93e4
4
- data.tar.gz: 3f33c8373a9015e27a426a92d64c8939bbe8a7caabc7a2eb190c4a60d04135bf
3
+ metadata.gz: f07199316723dad3e81762871162c088abf1a0d4a6c5096e2033bace38ab2339
4
+ data.tar.gz: 58691051c1a6e488155ddc878695a3c186a4c852aedd967f0e914fb5dfe2fa0b
5
5
  SHA512:
6
- metadata.gz: 496393be7c0e4f1bd1914c724ddb560e0439d048644c09d73093391a75a837956626c1f9ae077da993875a7ed72dde22abe117ad84be56afb6999a51461b4560
7
- data.tar.gz: 5558d5124d369612ac2482d6a1bbb2e2fbf7e0c5b0cec9a5515fcf1bc93c20d2b098d1a016998eab0371730c67ee026381db7d66a15e7e8e97808fd62912d659
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: ${{ github.ref }}
55
- release_name: Release ${{ github.ref }}
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- easy-jsonapi (1.0.4)
4
+ easy-jsonapi (1.0.5)
5
5
  oj (~> 3.10)
6
6
 
7
7
  GEM
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 ***500 unit tests*** allowing developers to spend less time debugging and more time creating.
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'easy-jsonapi'
5
- spec.version = '1.0.4'
5
+ spec.version = '1.0.5'
6
6
  spec.authors = ['Joshua DeMoss, Joe Viscomi']
7
7
  spec.email = ['demoss.joshua@gmail.com']
8
8
 
@@ -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
- return err_msg unless err_msg.nil?
42
+ raise err_msg unless err_msg.nil?
43
43
  end
44
44
 
45
45
  class << self
@@ -33,7 +33,7 @@ module JSONAPI
33
33
  end
34
34
 
35
35
  err_msg = JSONAPI::Exceptions::UserDefinedExceptions.check_user_query_param_requirements(rack_req_params, config_manager, opts)
36
- return err_msg unless err_msg.nil?
36
+ raise err_msg unless err_msg.nil?
37
37
 
38
38
  nil
39
39
  end
@@ -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? || config_manager.default?
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? || config_manager.default?
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 || JSONAPI::Exceptions::UserDefinedExceptions::InvalidHeader => e
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 || JSONAPI::Exceptions::UserDefinedExceptions::InvalidQueryParam => e
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 || JSONAPI::Exceptions::UserDefinedExceptions::InvalidDocument => e
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
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-29 00:00:00.000000000 Z
11
+ date: 2021-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack