openapi_first 3.4.1 → 3.4.3
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 +8 -0
- data/lib/openapi_first/builder.rb +4 -3
- data/lib/openapi_first/request.rb +1 -8
- data/lib/openapi_first/request_body_parsers.rb +8 -9
- 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: aa35ee9098e786a73c8d0de102d691cb0f5cec972e60e9a8d96d439f63eef872
|
|
4
|
+
data.tar.gz: b6f8461c433753a49563055b4fd3156cbbacf0c89d5f7e2f2a7f1366c2c3b32c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2146d351211ebc10237dd8f6d30381d15d99ac15bf0cfa05a9095b6f493738b48c4e406b0d359fcc6f11c9910702b0e3ad4003b6513d32cd2390c81a356fd21b
|
|
7
|
+
data.tar.gz: 2235965c286c2d182a77b491422c18a25010f69c0e91e87e50731334aa5515fdbe3cd06d03a4a509c3f07b07f1405a928b50a6b037ed022fc0dd3b60e8bf1be9
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 3.4.3
|
|
6
|
+
|
|
7
|
+
Fixed: Loading a document no longer raises `NoMethodError: undefined method 'schema' for nil` when a Media Type Object has no `schema` (e.g. it only declares an `example`). `schema` is optional in a Media Type Object; such media types now impose no body-schema constraint.
|
|
8
|
+
|
|
9
|
+
## 3.4.2
|
|
10
|
+
|
|
11
|
+
Fixed: Parsing of JSON-formatted query params [issue #476](https://github.com/ahx/openapi_first/issues/476) (thanks @Drowze)
|
|
12
|
+
|
|
5
13
|
## 3.4.1
|
|
6
14
|
|
|
7
15
|
Fixed: Added missing ERB and css file to the gem
|
|
@@ -110,7 +110,8 @@ module OpenapiFirst
|
|
|
110
110
|
def resolve_parameters(parameters)
|
|
111
111
|
parameters&.map do |parameter|
|
|
112
112
|
result = parameter.resolved
|
|
113
|
-
|
|
113
|
+
_media_type, media_type_object = parameter['content']&.first
|
|
114
|
+
result['schema'] = (media_type_object || parameter)['schema'].resolved
|
|
114
115
|
result
|
|
115
116
|
end.to_a
|
|
116
117
|
end
|
|
@@ -139,7 +140,7 @@ module OpenapiFirst
|
|
|
139
140
|
end
|
|
140
141
|
required_body = operation_object['requestBody']&.resolved&.fetch('required', false) == true
|
|
141
142
|
content_objects.map do |content_type, content_object|
|
|
142
|
-
content_schema = content_object['schema']
|
|
143
|
+
content_schema = content_object['schema']&.schema(
|
|
143
144
|
configuration: schemer_configuration,
|
|
144
145
|
after_property_validation: config.after_request_body_property_validation
|
|
145
146
|
)
|
|
@@ -170,7 +171,7 @@ module OpenapiFirst
|
|
|
170
171
|
responses.flat_map do |status, response_object|
|
|
171
172
|
headers = build_response_headers(response_object['headers'])
|
|
172
173
|
response_object['content']&.map do |content_type, content_object|
|
|
173
|
-
content_schema = content_object['schema']
|
|
174
|
+
content_schema = content_object['schema']&.schema(
|
|
174
175
|
configuration: schemer_configuration,
|
|
175
176
|
after_property_validation: config.after_response_body_property_validation
|
|
176
177
|
)
|
|
@@ -54,9 +54,6 @@ module OpenapiFirst
|
|
|
54
54
|
@operation['operationId']
|
|
55
55
|
end
|
|
56
56
|
|
|
57
|
-
MULTIPART_CONTENT_TYPE = %r{\Amultipart/form-data\b}i
|
|
58
|
-
private_constant :MULTIPART_CONTENT_TYPE
|
|
59
|
-
|
|
60
57
|
private
|
|
61
58
|
|
|
62
59
|
def parse_request(request, route_params:)
|
|
@@ -82,11 +79,7 @@ module OpenapiFirst
|
|
|
82
79
|
end
|
|
83
80
|
|
|
84
81
|
def build_body_parser(content_type, encoding)
|
|
85
|
-
|
|
86
|
-
RequestBodyParsers::MultipartBodyParser.new(encoding: encoding || {})
|
|
87
|
-
else
|
|
88
|
-
RequestBodyParsers[content_type]
|
|
89
|
-
end
|
|
82
|
+
RequestBodyParsers[content_type, { encoding: encoding || {} }]
|
|
90
83
|
end
|
|
91
84
|
end
|
|
92
85
|
end
|
|
@@ -14,9 +14,12 @@ module OpenapiFirst
|
|
|
14
14
|
parsers[pattern] = parser
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
def [](content_type)
|
|
17
|
+
def [](content_type, options = {})
|
|
18
18
|
key = parsers.keys.find { content_type.match?(_1) }
|
|
19
|
-
parsers.fetch(key) { DEFAULT }
|
|
19
|
+
parser = parsers.fetch(key) { DEFAULT }
|
|
20
|
+
return parser.new(options) if parser.is_a?(Class)
|
|
21
|
+
|
|
22
|
+
parser
|
|
20
23
|
end
|
|
21
24
|
end
|
|
22
25
|
|
|
@@ -44,12 +47,8 @@ module OpenapiFirst
|
|
|
44
47
|
# `contentType: application/json` (or any */json), the field's raw value
|
|
45
48
|
# is JSON-parsed before schema validation.
|
|
46
49
|
class MultipartBodyParser
|
|
47
|
-
def initialize(
|
|
48
|
-
@encoding = encoding || {}
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def self.call(request)
|
|
52
|
-
new.call(request)
|
|
50
|
+
def initialize(options)
|
|
51
|
+
@encoding = options[:encoding] || {}
|
|
53
52
|
end
|
|
54
53
|
|
|
55
54
|
def call(request)
|
|
@@ -89,7 +88,7 @@ module OpenapiFirst
|
|
|
89
88
|
end
|
|
90
89
|
end
|
|
91
90
|
|
|
92
|
-
register(
|
|
91
|
+
register(%r{\Amultipart/form-data\b}i, MultipartBodyParser)
|
|
93
92
|
|
|
94
93
|
register('application/x-www-form-urlencoded', lambda(&:POST))
|
|
95
94
|
end
|