We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Is your feature request related to a problem? Please describe.
given a schema like
components: schemas: HereBeDragons: type: string pattern: here PassMe: type: object properties: mangled_string: anyOf: - $ref: '#/components/schemas/PettyNumber' - $ref: '#/components/schemas/HereBeDragons' PettyNumber: type: string pattern: '[0-9]{2,8}'
multiple root types are created and in turn create object indirection
from pydantic import BaseModel, Field, RootModel, constr class HereBeDragons(RootModel[constr(pattern=r"here")]): root: constr(pattern=r"here") class MoreValues(BaseModel): name: str age: int | None = None class PettyNumber(RootModel[constr(pattern=r"[0-9]{2,8}")]): root: constr(pattern=r"[0-9]{2,8}") class PassMe(BaseModel): mangled_string: PettyNumber | HereBeDragons | None = None
Describe the solution you'd like
decare the types more directly like
# using python 3.12+ syntax from pydantic import BaseModel, Field, StringConstraints type HereBeDragons = Annotated[str, StringConstraints(pattern=r"here")] type PrettyNumber = Annotated[str, StringConstraints(pattern=r"[0-9]{2,8}")] class PassMe(BaseModel): mangled_string: PettyNumber | HereBeDragons | None = None
Additional context Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Is your feature request related to a problem? Please describe.
given a schema like
multiple root types are created and in turn create object indirection
Describe the solution you'd like
decare the types more directly like
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: