New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect TS type is generated when involving Tuple
#11
Comments
Tuple
Tuple
Hi, thanks for finding this. It's a bit of a funky one It seems that the issue is resolved if the json schema has from typing import List, Tuple
from pydantic import BaseModel
class Model(BaseModel):
tuple: Tuple[str, int]
list_of_tuples: List[Tuple[str, int]]
class Config:
@staticmethod
def schema_extra(schema: dict) -> None:
"""Customize the generated JSON schema via mutation"""
schema["properties"]["tuple"]["minItems"] = 2
schema["properties"]["list_of_tuples"]["items"]["minItems"] = 2 However, it appears that they already talked about adding this functionality into pydantic but decided against it: We can certainly implement it ourselves by adding some behavior to the |
To reproduce:
yields:
Expected
The above Pydantic model should generate this:
Versions:
python: 3.7.9
pydantic: 1.6 | 1.8.2
pydantic-to-typescript: 1.0.7
The text was updated successfully, but these errors were encountered: