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

pydantic_model_creator should support JSONField annotation (type hints) #1702

Open
LanceMoe opened this issue Aug 31, 2024 · 0 comments
Open

Comments

@LanceMoe
Copy link

Is your feature request related to a problem? Please describe.

The types of JSONField are all displayed as Any in swagger:

image

I need to import openapi.json into a TypeScript project for use, and this makes the generated openapi.json very poor in usability.

Describe the solution you'd like

I found in tortoise/contrib/pydantic/creator.py has

        # Json fields
        elif field_type is JSONField:
            properties[fname] = Any

I think we can avoid any by adding an optional type json_schema when defining the field, like this:

image

Or is there any better way to achieve this?

@LanceMoe LanceMoe changed the title pydantic_model_creator should support JSONField annotation (type hints) pydantic_model_creator should support JSONField annotation (type hints) Aug 31, 2024
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

1 participant