tortoise / tortoise/tortoise-orm
JSON field in pydantic model creator should be set as dict type
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.6k
- Forks
- 516
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 9
Description
Is your feature request related to a problem? Please describe.
Whenever I declare a field as fields.JSONFields and use it in a pydantic model by calling pydantic model creator it comes as string field in swagger. This leads to an error on sending the request through swagger on not changing the field type manually.
Describe the solution you'd like
It should come as a dict field.
Describe alternatives you've considered
# Json fields
# elif field_type is fields.JSONField:
# pannotations[fname] = Any # type: ignore
removing this in the file creator.py should help.
Additional context
Add any other context about the feature request here.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in creator.py at the pydantic model creator handling of fields.JSONField, then reproduce the generated Swagger schema for a model containing a JSON field. Confirm that the schema represents the field as an object or dict and that Swagger accepts an object request without manual type changes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100