fix for base64 choices #204

This commit is contained in:
collerek
2021-05-20 16:12:33 +02:00
parent 22676750dd
commit 40f1076443
3 changed files with 6 additions and 5 deletions

View File

@ -76,7 +76,7 @@ class UndefinedType: # pragma no cover
Undefined = UndefinedType()
__version__ = "0.10.8"
__version__ = "0.10.9"
__all__ = [
"Integer",
"BigInteger",

View File

@ -251,9 +251,10 @@ def overwrite_binary_format(schema: Dict[str, Any], model: Type["Model"]) -> Non
and model.Meta.model_fields[field_id].represent_as_base64_str
):
prop["format"] = "base64"
prop["enum"] = [
base64.b64encode(choice).decode() for choice in prop["enum"]
]
if prop.get("enum"):
prop["enum"] = [
base64.b64encode(choice).decode() for choice in prop.get("enum", [])
]
def construct_modify_schema_function(fields_with_choices: List) -> SchemaExtraCallable:

View File

@ -7,7 +7,7 @@ typing_extensions>=3.7,<=3.7.4.3
orjson
cryptography
# Async database drivers
# Async database driversy
aiomysql
aiosqlite
aiopg