1
Fork 0
mirror of https://github.com/thegeneralist01/twitter-openapi synced 2026-01-11 15:40:26 +01:00
Signed-off-by: ふぁ <yuki@yuki0311.com>
This commit is contained in:
ふぁ 2023-07-25 23:11:08 +09:00
parent 305609f839
commit b6c703fa7b
No known key found for this signature in database
GPG key ID: 83A8A5E74872A8AA
4 changed files with 18 additions and 3 deletions

View file

@ -109,6 +109,23 @@ class RemoveDiscriminator(SchemasHookBase):
return value
class ReplaceLegacyDiscriminator(SchemasHookBase):
def hook(self, value: dict):
if value.get("oneOf") is not None:
value = {
"type": "object",
"example": ",".join(
list(x["$ref"].split("/")[-1] for x in value["oneOf"])
),
# "required": [value["discriminator"]["propertyName"]],
"properties": {
f"oneOf_schema_{x}_validator": y
for x, y in enumerate(value["oneOf"])
},
}
return value
# RequestHookBase extends