Skip to main content

Pydantic to FastAPI model converter.

Project description

pyfa-converter-v2

Allows you to convert Pydantic models for FastAPI param models - query, form, header, cookie, body, etc.

The project is originally written by dotX12 at dotX12/pyfa-converter, but it doesn't support Pydantic v2, so we made a fork of the project with some changes:

  • Added support for pydantic v2
  • Added tests
  • Re-licensed the code to LGPL 3.0
  • Added mypy, flake8, isort checks
  • Removed dead code

The project may be archived if the original package author upgrades to Pydantic v2 (dotX12/pyfa-converter#25).

Currently, the library does not fully reflect the requirements in OpenAPI (e.g. gt parameter will be required, but this will not be specified in FastAPI docs).

How to install?

pip install pyfa_converter_v2

How to simplify your life?

from fastapi import FastAPI
from pydantic import BaseModel

from pyfa_converter_v2 import QueryDepends

app = FastAPI()

class ArticleSchema(BaseModel):
    title: str
    content: str

@app.post("/article")
async def create_article(article: ArticleSchema = QueryDepends(ArticleSchema)):
    return {"id": 1, "title": article.title, "content": article.content}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyfa_converter_v2-2.0.0rc1.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

pyfa_converter_v2-2.0.0rc1-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file pyfa_converter_v2-2.0.0rc1.tar.gz.

File metadata

  • Download URL: pyfa_converter_v2-2.0.0rc1.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.0 CPython/3.8.18 Linux/6.5.9-300.fc39.x86_64

File hashes

Hashes for pyfa_converter_v2-2.0.0rc1.tar.gz
Algorithm Hash digest
SHA256 d505466b29a90d6d7455b3efa77d77eaefa49dcd506670756685d15d5f439843
MD5 74cba68f2b5b9765b5623fd1a015e734
BLAKE2b-256 096487694101871ce7b4a1bd77a7d0dbf6ef9a361945cfac78a6659d94faa9ce

See more details on using hashes here.

File details

Details for the file pyfa_converter_v2-2.0.0rc1-py3-none-any.whl.

File metadata

File hashes

Hashes for pyfa_converter_v2-2.0.0rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 575469d88b3917ff3464b145ae437efb499cbc8dd105733f045846747661e561
MD5 75b27d1c7d5d74cb7bf902f801581656
BLAKE2b-256 d151a3096c63725d652056c71f82d2fef2ab658b5bc9662cbe9362bb37c2d015

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page