https://github.com/cofob/pyfa-converter-v2
🪛 Pydantic to FastAPI model converter.
https://github.com/cofob/pyfa-converter-v2
fastapi pydantic python3
Last synced: 8 months ago
JSON representation
🪛 Pydantic to FastAPI model converter.
- Host: GitHub
- URL: https://github.com/cofob/pyfa-converter-v2
- Owner: cofob
- License: lgpl-3.0
- Created: 2023-11-06T16:40:06.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-04-08T14:01:39.000Z (about 1 year ago)
- Last Synced: 2025-04-08T15:22:12.973Z (about 1 year ago)
- Topics: fastapi, pydantic, python3
- Language: Python
- Homepage:
- Size: 27.3 KB
- Stars: 7
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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](https://github.com/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](https://github.com/dotX12/pyfa-converter/issues/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?
```python3
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}
```
Available converters: `QueryDepends`, `BodyDepends` and `FormDepends`. You can add new types via `PyFaDepends`.