Category "pydantic"

Is it possible to extend pydantic models generated using datamodel-code-generator?

I am using the datamodel-code-generator to generate pydantic models from a JSON schema. Here is the JSON schema used. And the generated models after running the

Pydantic validation error for BaseSettings model with local ENV file

I'm developing a simple FastAPI app and I'm using Pydantic for storing app settings. Some settings are populated from the environment variables set by Ansible d

OpenAPI is missing schemas for some of the Pydantic models in FastAPI app

I am building a FastAPI application, which has a lot of Pydantic models. Even though the application is working just fine, as expected the OpenAPI (Swagger UI)

AttributeError: 'BaseModel' object has no attribute '_sa_instance_state'

I have the following code in my app: models.py class MainTable(Base): __tablename__ = "main_table" id = Column(Integer, primary_key=True, index=True)

How to go through all Pydantic validators even if one fails, and then raise multiple ValueErrors in a FastAPI response?

Is it possible to call all validators to get back a full list of errors? @validator('password', always=True) def validate_password1(cls, value): password =

How to change the default Pydantic error message using FastAPI?

Is there any way to change the default response from Pydantic so that "msg" is "message"? { "detail": [ { "loc": [ "body

How to create linked lists using pydantic so auto-completion doesn't break

I am trying to create a linked list using pydantic. The following code works, but I can't get auto-completion to work. As you can see from the attached screensh

Pydantic: Save nested settings

I'm currently trying to automatically save a pydantic.BaseSettings-object to a json-file on change. The model is loaded out of the json-File beforehand. A minim

Graphene throwing input error for Pydantic models with discriminator while generating Input object schema

I am using pydantic validations for my requirements and it uses discriminator. I am writing GraphQL APIs and want to convert those pydantic models into graphene

Define a Request parameter as an optional variable type in fastapi

I would like to define a Request object as an optional variable type in FastAPI, but I got an error: fastapi.exceptions.FastAPIError: Invalid args for response

FastApi pydantic: Json object inside a json object validation error

There is a nested rule of class DocumentSchema in pydantic written in FastApi as follows: class DocumentSchema(BaseModel): clientName: str transactionId

Pydantic Checking if list field is unique

Currently, I am trying to create a pydantic model for a pandas dataframe. I would like to check if a column is unique by the following import pandas as pd from

Why is my pydantic model not displaying any values after setting it?

from pydantic import BaseModel class Test(BaseModel): val1 = str val2 = str test = { "val1": "1010101", "val2": "1010101", } test_value= Test(

How to do exact one-to-one match validation with pydantic model schema?

How can I exactly match the Pydantic schema? The suggested method is to attempt a dictionary conversion to the Pydantic model but that's not a one-one match. I

Pydantic: Define an attribute of type List with nested lists and multiple sub-models

I have to deal with such a schema: { "method": "Data.get", "params": [ [ { # name this "Fetch" "select_": "Downtime

FastApi returns "field required" and "value_error.missing" for one of my parameters, but the field is there

I do a Post with some parameters, but one of them returns "field required" and "value_error.missing", but the field is there and it has a value. See the output

How to specify a BaseSettings Config's env_file based on a field from the same class?

I want to implement this logic from pydantic import BaseSettings class Settings(BaseSettings): ENVIRONMENT: str = 'local' SECRET_KEY: str = 'someke

How to generate Pydantic model for multiple different objects

I need to have a variable covars that contains an unknown number of entries, where each entry is one of three different custom Pydantic models. In this case, ea

`pyyaml` can't parse `pydantic` object if `typing` module is used

Let me start off by saying I wanted to open an issue in pydantic repo. Once I started rubber duck debugging I came up to the conclusion it's actually pyyaml tha

Problems with ABC/Interfaces using pydantic + Mixins pattern

Im trying to implement Mixin patter while Im using Pydantics BaseClass to facilitate the instantiation and validation of data from my class. The problem is that