Skip to content
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

Custom __root__ dict models generated as empty types #39

Open
mikewilli opened this issue Aug 10, 2023 · 1 comment
Open

Custom __root__ dict models generated as empty types #39

mikewilli opened this issue Aug 10, 2023 · 1 comment

Comments

@mikewilli
Copy link

I am seeing an issue when generating typescript types from pydantic models that consist of a custom root dict field, like this:

Pydantic model:

class CustomModel(BaseModel):
    __root__: dict[str, int]

Expected result:

export interface CustomModel {
  [k: string]: int;
}

Actual result:

export interface CustomModel {}

I can work around this issue by setting extra=Extra.allow on the pydantic model, but I would rather avoid having to do this. This comment explains why the workaround is necessary.

Python 3.10
Pydantic 1.10
pydantic-to-typescript 1.0.10

@marcelomarkus
Copy link

try add a CustomModel
class Config:
validate_assignment = True
allow_population_by_field_name = True

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants