Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Add additional parameters to Schema for validation and annotation #311
Add additional parameters to Schema for validation and annotation, in a single declaration.
Integrates and uses
As a result, a current model created as:
from pydantic import BaseModel, constr, Schema class Foo(BaseModel): a: constr(min_length=2, max_length=10) = Schema('bar')
can also be created as:
from pydantic import BaseModel, Schema class Foo(BaseModel): a: str = Schema('bar', min_length=2, max_length=10)
by being able to declare
The generated JSON Schema will output validation keywords of
For numbers validations like
Other option for the parameters would be to use the literal name used in JSON Schema, as
And other option would be using JSON Schema names and change them to snake-case, as
But I imagine the preferred option is to keep the same parameter names used in the rest of the code, as in
Specific parameters added to
@@ Coverage Diff @@ ## json-schema-extra #311 +/- ## ================================================ Coverage 100% 100% ================================================ Files 13 14 +1 Lines 1708 1770 +62 Branches 323 338 +15 ================================================ + Hits 1708 1770 +62
Do you want me to mark as "resolved" the comments in the review that are already done?
I'm leaving them there so you can come back, check and confirm, before marking them as resolved. But let me know if you want me to mark the ones that are done and don't have a pending discussion.