I am retrofitting an existing hand-crafted REST API (in Python Flask) to leverage OpenAPI 3.0 and I am a bit at a loss about what to do here. My endpoint will take an arbitrary list of filters:
[{"prop":"is_automatic", "operator":"equal", "value":"true"},
:
{"prop":"brand", "operator":"equal", "value":"Sumsang"}]
and use them to query a database. As far as my current implementation goes, the client does this:
var myFormData = new FormData();
this.filters.forEach((filter) => {
allFilters.push({
prop: filter.prop,
operator: filter.operator,
value: filter.value
})
})
myFormData.append("filters",JSON.stringify(allFilters));
and the server accepts and decodes that data with:
filtersJson = request.form.get('filters')
:
filters = json.loads(filtersJson)
I understand this is not particularly elegant, but it gets the job done. Now my problem. I am trying to do things the OpenAPI 3.0 way and I can't seem to find a good way. Whatever I try, I keep bumping my head against deepObject and "the behavior for nested objects and arrays is undefined". Btw: This SO answer appears to be the closest to what I am asking, but it does not quite dissipate the doubt that I may be missing something.
Am I missing something? Is there an elegant OpenAPI way to implement what already works for me today? Is "packaging all my filters into a string that happens to be JSON" frowned upon by people with a lot of experience in writing Swagger/OpenAPI APIs?