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

🐛 Fix JSON Schema for dataclasses, supporting the fixes in Pydantic 1.9 #4272

Merged
merged 2 commits into from
Dec 12, 2021

Conversation

PrettyWood
Copy link
Contributor

With model

@dataclass
class Item:
    name: str
    price: float
    tags: List[str] = field(default_factory=list)
    description: Optional[str] = None
    tax: Optional[float] = None

only name and price should be required

⚠️ needs pydantic/pydantic#2557

with model

```py
@DataClass
class Item:
    name: str
    price: float
    tags: List[str] = field(default_factory=list)
    description: Optional[str] = None
    tax: Optional[float] = None
```

only `name` and `price` should be required
…classes

while keeping compatibility in tests for the current Pydantic version
@tiangolo tiangolo changed the title fix: dataclass schema 🐛 Fix JSON Schema for dataclasses, supporting the fixes in Pydantic 1.9 Dec 12, 2021
@codecov
Copy link

codecov bot commented Dec 12, 2021

Codecov Report

Merging #4272 (9b7d120) into master (0a87bc8) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master     #4272   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          409       409           
  Lines        10264     10270    +6     
=========================================
+ Hits         10264     10270    +6     
Impacted Files Coverage Δ
...test_tutorial/test_dataclasses/test_tutorial002.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0a87bc8...9b7d120. Read the comment docs.

@tiangolo tiangolo merged commit b0cd4d7 into fastapi:master Dec 12, 2021
@PrettyWood PrettyWood deleted the fix/dataclass-schema branch December 12, 2021 11:37
@tiangolo
Copy link
Member

Amazing, thanks for all your work with Pydantic! 🚀🙇

I updated it to make it pass tests now with the current version and also with the next, that way I can merge it right away. I already made a release (0.70.1) just to unblock you there on the Pydantic PR.

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

Successfully merging this pull request may close these issues.

None yet

2 participants