Skip to content
Advertisement

Tag: fastapi

Validation error while inputting a record into Postgres

I have created a table using the following query, Following is my models.py Following is my schema.py I use the following code to create an user, The problem is that I’m getting the following error, raise ValidationError(errors, field.type_) pydantic.error_wrappers.ValidationError: 1 validation error for AccountsInfo response -> created_on str type expected (type=type_error.str) what am I missing? Answer raise ValidationError(errors, field.type_) pydantic.error_wrappers.ValidationError:

How to disable schema checking in FastAPI?

I am migrating a service from Flask to FastAPI and using Pydantic models to generate the documentation. However, I’m a little unsure about the schema check. I’m afraid there will be some unexpected data (like a different field format) and it will return an error. In the Pydantic documentation there are ways to create a model without checking the schema:

FastAPI with uvicorn getting 404 Not Found error

I’m trying (failing) to set up a simple FastAPI project and run it with uvicorn. This is my code: This is what I run from the terminal: As you see, I get a 404 Not found. What could be the reason? Some network-related stuff, possibly firewall/vpn blocking this connection or something else? I’m new to this. Thanks in advance! Answer

Pydantic enum field does not get converted to string

I am trying to restrict one field in a class to an enum. However, when I try to get a dictionary out of class, it doesn’t get converted to string. Instead it retains the enum. I checked pydantic documentation, but couldn’t find anything relevant to my problem. This code is representative of what I actually need. I’m trying to get

How to group FastAPI endpoints in Swagger UI? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago. The community reviewed whether to reopen this question 6 months ago and left it closed: Original close reason(s) were not resolved Improve this question I started programming using

How to save UploadFile in FastAPI

I accept the file via POST. When I save it locally, I can read the content using file.read (), but the name via file.name incorrect(16) is displayed. When I try to find it by this name, I get an error. What might be the problem? My code: Answer Background UploadFile is just a wrapper around SpooledTemporaryFile, which can be accessed

Advertisement