Issue with validation in deep nested parameters
Closed this issue · 1 comments
Hi,
I have made a simple webservice with this :
standard_sample_input = {"raw_data": {'a': 1, 'b': 1}}
standard_sample_output = {'a': 1, 'b': 1, "a+b": 2}
@input_schema('raw_data', StandardPythonParameterType(standard_sample_input))
@output_schema(StandardPythonParameterType(standard_sample_output))
def run(raw_data):
a = raw_data["a"]
b = raw_data["b"]
return {'a': a, "b": b, "a+b": a + b}
When I make a call with a payload like this :
{"raw_data":{"a":1,"b":2}}
It works as expected.
When I make a call with a payload like this (bad data on first level) :
{"raw_data":"bad"}
It works as expected :
Invalid input data type to parse. Expected:
<class 'dict'> but got
<class 'str'>
The Issue :
When I make a call with a payload like this (bad data on second level) :
{"raw_data":{"a":1,"b":"bad"}}
It doesn't validate, and generate an error in the code.
Is it expected, or is it a bug ?
We don't yet have support for that level of nested examination. So while we do look and see that the parameter provided matched the sample at the first level, in this case a dictionary, we don't go through the dictionary and make sure that all of the internal types match.
This is something I've been aware of, just haven't had time to introduce the feature.