raise when you find a Literal type we dont support in openapi generator

This commit is contained in:
Ashwin Bharambe 2025-04-28 10:37:14 -07:00
parent abd6280cb8
commit 78da66016f

View file

@ -479,7 +479,7 @@ class JsonSchemaGenerator:
return ret
elif origin_type is Literal:
if len(typing.get_args(typ)) != 1:
print(f"Literal type {typ} has {len(typing.get_args(typ))} arguments")
raise ValueError(f"Literal type {typ} has {len(typing.get_args(typ))} arguments")
(literal_value,) = typing.get_args(typ) # unpack value of literal type
schema = self.type_to_schema(type(literal_value))
schema["const"] = literal_value