|
|
@@ -335,8 +335,8 @@ filter_check_request_and_translate_body(Request, RequestMeta) ->
|
|
|
filter_check_request(Request, RequestMeta) ->
|
|
|
translate_req(Request, RequestMeta, fun check_only/3).
|
|
|
|
|
|
-translate_req(Request, #{module := Module, path := Path, method := Method}, CheckFun) ->
|
|
|
- #{Method := Spec} = apply(Module, schema, [Path]),
|
|
|
+translate_req(Request, ReqMeta = #{module := Module}, CheckFun) ->
|
|
|
+ Spec = find_req_apispec(ReqMeta),
|
|
|
try
|
|
|
Params = maps:get(parameters, Spec, []),
|
|
|
Body = maps:get('requestBody', Spec, []),
|
|
|
@@ -349,6 +349,12 @@ translate_req(Request, #{module := Module, path := Path, method := Method}, Chec
|
|
|
{400, 'BAD_REQUEST', Msg}
|
|
|
end.
|
|
|
|
|
|
+find_req_apispec(#{apispec := Spec}) ->
|
|
|
+ Spec;
|
|
|
+find_req_apispec(#{module := Module, path := Path, method := Method}) ->
|
|
|
+ #{Method := Spec} = apply(Module, schema, [Path]),
|
|
|
+ Spec.
|
|
|
+
|
|
|
check_and_translate(Schema, Map, Opts) ->
|
|
|
hocon_tconf:check_plain(Schema, Map, Opts).
|
|
|
|