-
-
Notifications
You must be signed in to change notification settings - Fork 315
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
msgspec output of a directory input where a schema only contains a root model is missing imports #1607
Comments
Investigating this it would appear that it maybe because the Although there is obviously some interaction with the |
Which codes are you talking about specifically? |
The MR #1609 doesn't currently fix this unfortunately. Running the following on the test data added in that MR is still missing the › datamodel-codegen --input tests/data/jsonschema/duplicate_field_constraints \
--input-file-type jsonschema \
--output tests/data/expected/main/duplicate_field_constraints_msgspec \
--disable-timestamp --enable-version-header \
--output-model-type msgspec.Struct \
--target-python 3.9
› cat tests/data/expected/main/duplicate_field_constraints_msgspec/common.py
# generated by datamodel-codegen:
# filename: common.yml
# version: 0.0.0
from __future__ import annotations
from typing import Annotated, Any
Model = Any
Ulid = Annotated[str, Meta(pattern='[0-9ABCDEFGHJKMNPQRSTVWXYZ]{26,26}')] |
Describe the bug
Similar to #1495 when using a directory input with a annotated constrainted
RootModel
where the schema ends up generating solelyRootModel
s in the generated python, the module is missing the required imports.To Reproduce
Example schema:
Used commandline:
Expected behavior
Generated modules that only root models that are annotated with
Meta
constraints import the required classes.eg:
Version:
The text was updated successfully, but these errors were encountered: