json_schemer-rails 0.1.0 → 0.2.0
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 +4 -4
- data/lib/json_schemer/rails/open_api_validator.rb +10 -4
- data/lib/json_schemer/rails/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2cd6978d4847f016630e34ddb387d5d4228b31bfb002eac0f1b66292d98e4774
|
|
4
|
+
data.tar.gz: d1e0f21111b828e1990b4bdd7b2b36102ac8feb7fbcecfcb4d0ebab8011d7b1a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3964c292102e360abda120a088609fd4153fefdb514c8f62fa6a7c1c400c27b435833bf1bcc75cad834a1d112141feac8aa27b8f3e6b99b648cdfefdbc7cc2df
|
|
7
|
+
data.tar.gz: 5740942a99cc04f2593e296a7d2ce7d8619769edd8796ec32fd1f9e8d73f91e6f57d3959fd9bf03f524d7740c5a3c4983b7a388b28af67d5e193e0efc6367fc3
|
|
@@ -29,9 +29,7 @@ module JsonSchemer
|
|
|
29
29
|
|
|
30
30
|
# cast any parameters that are not part of the OpenAPI specification
|
|
31
31
|
def validated_params
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
param_specs.each do |spec|
|
|
32
|
+
parameter_specs.each do |spec|
|
|
35
33
|
case spec["in"]
|
|
36
34
|
when "query"
|
|
37
35
|
validate_query_param(spec)
|
|
@@ -43,6 +41,14 @@ module JsonSchemer
|
|
|
43
41
|
|
|
44
42
|
private
|
|
45
43
|
|
|
44
|
+
# @return [Array<Hash>] An array of parameter specifications from the OpenAPI document.
|
|
45
|
+
# @raises RequestValidationError if the OpenAPI specification cannot be found.
|
|
46
|
+
def parameter_specs
|
|
47
|
+
document.ref(request_openapi_path).value["parameters"] || []
|
|
48
|
+
rescue JSONSchemer::InvalidRefPointer
|
|
49
|
+
raise RequestValidationError, "Unable to find OpenAPI specification for #{request_openapi_path}"
|
|
50
|
+
end
|
|
51
|
+
|
|
46
52
|
def should_validate_body?
|
|
47
53
|
return false if %w[delete get].include?(request.method.downcase) # no body to verify
|
|
48
54
|
|
|
@@ -106,7 +112,7 @@ module JsonSchemer
|
|
|
106
112
|
def json_ref_for_path
|
|
107
113
|
params = request.path_parameters.except(:controller, :action)
|
|
108
114
|
path = CGI.unescape(request.path).tr(" ", "+")
|
|
109
|
-
|
|
115
|
+
params.excluding("controller", "action", "format").each_key do |parameter|
|
|
110
116
|
path.gsub!(params[parameter], "%7B#{parameter}%7D") if params[parameter]
|
|
111
117
|
end
|
|
112
118
|
path.gsub("/", "~1")
|