openapi_first 0.10.1 → 0.10.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 +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +1 -1
- data/benchmarks/Gemfile.lock +1 -1
- data/lib/openapi_first/request_validation.rb +9 -1
- data/lib/openapi_first/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: 49ebcf2af159defac87d97f5d9cc1b2c76a1f76ce09376f209bc38458c2eee07
|
4
|
+
data.tar.gz: dbe17ecf51792614df624c91a704f9a319bf1bf2b1b1cded454a748f193c2e21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d478201cf1e856d745dff02e4977552b95c09500956be61c6d169cf179a1f15968bca460a63a9ce76fb97bba0c5d5713e94d5e802d8fe0446428fdfd6b3feb8
|
7
|
+
data.tar.gz: dac17e6ec186b821a6fbdf09c47c20478f43bb21d30175b5d3e8150e0e99cf98110b2a7c01e143207176733485b52df1972277bc6790a7730c6a365dde32e3b1
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.10.2
|
4
|
+
- Return 400 if request body has invalid JSON ([issue](https://github.com/ahx/openapi_first/issues/73)) thanks Thomas Frütel
|
5
|
+
|
6
|
+
## 0.10.1
|
7
|
+
- Fix duplicated key in `required` when generating JSON schema for `some[thing]` parameters
|
8
|
+
|
3
9
|
## 0.10.0
|
4
10
|
- Add support for query parameters named `"some[thing]"` ([issue](https://github.com/ahx/openapi_first/issues/40))
|
5
11
|
|
data/Gemfile.lock
CHANGED
data/benchmarks/Gemfile.lock
CHANGED
@@ -44,7 +44,7 @@ module OpenapiFirst
|
|
44
44
|
schema = request_body_schema(content_type, operation)
|
45
45
|
return unless schema
|
46
46
|
|
47
|
-
parsed_request_body =
|
47
|
+
parsed_request_body = parse_request_body!(body)
|
48
48
|
errors = validate_json_schema(schema, parsed_request_body)
|
49
49
|
if errors.any?
|
50
50
|
halt(error_response(400, serialize_request_body_errors(errors)))
|
@@ -52,6 +52,14 @@ module OpenapiFirst
|
|
52
52
|
env[INBOX].merge! env[REQUEST_BODY] = parsed_request_body
|
53
53
|
end
|
54
54
|
|
55
|
+
def parse_request_body!(body)
|
56
|
+
MultiJson.load(body)
|
57
|
+
rescue MultiJson::ParseError => e
|
58
|
+
err = { title: 'Failed to parse body as JSON' }
|
59
|
+
err[:detail] = e.cause unless ENV['RACK_ENV'] == 'production'
|
60
|
+
halt(error_response(400, [err]))
|
61
|
+
end
|
62
|
+
|
55
63
|
def validate_request_content_type!(content_type, operation)
|
56
64
|
return if operation.request_body.content[content_type]
|
57
65
|
|