mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 21:13:36 +00:00
openapi: Add hacky support for oneOf parameter types.
This is required for the upcoming type behavior of the "anchor" parameter. This change is the minimal work required to have our OpenAPI code not fail when checking a union-type value of this form. We'll likely want to, in the future, do something nicer, but it'd require more extensive infrastructure for parsing of OpenAPI data that it's worth with our current approach (we may want to switch to using a library).
This commit is contained in:
@@ -377,9 +377,15 @@ do not match the types declared in the implementation of {}.\n""".format(functio
|
||||
openapi_params = set() # type: Set[Tuple[str, Union[type, Tuple[type, object]]]]
|
||||
for element in openapi_parameters:
|
||||
name = element["name"] # type: str
|
||||
_type = VARMAP[element["schema"]["type"]]
|
||||
schema = element["schema"]
|
||||
if 'oneOf' in schema:
|
||||
# Hack: Just use the type of the first value
|
||||
# Ideally, we'd turn this into a Union type.
|
||||
_type = VARMAP[schema['oneOf'][0]['type']]
|
||||
else:
|
||||
_type = VARMAP[schema["type"]]
|
||||
if _type == list:
|
||||
items = element["schema"]["items"]
|
||||
items = schema["items"]
|
||||
if "anyOf" in items.keys():
|
||||
subtypes = []
|
||||
for st in items["anyOf"]:
|
||||
|
||||
Reference in New Issue
Block a user