{"id":17108433,"url":"https://github.com/dotx12/pyfa-converter","last_synced_at":"2025-08-13T15:31:21.075Z","repository":{"id":38390374,"uuid":"477564770","full_name":"dotX12/pyfa-converter","owner":"dotX12","description":"🪛 A simple pydantic to Form FastAPI model converter.","archived":false,"fork":false,"pushed_at":"2024-02-20T13:52:04.000Z","size":80,"stargazers_count":38,"open_issues_count":2,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-20T10:47:35.203Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dotX12.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-04-04T05:44:05.000Z","updated_at":"2025-07-08T05:54:31.000Z","dependencies_parsed_at":"2024-02-20T14:55:24.246Z","dependency_job_id":null,"html_url":"https://github.com/dotX12/pyfa-converter","commit_stats":{"total_commits":62,"total_committers":5,"mean_commits":12.4,"dds":0.532258064516129,"last_synced_commit":"ba91c2ae44c210376ea89799c8a78614da434591"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"purl":"pkg:github/dotX12/pyfa-converter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotX12%2Fpyfa-converter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotX12%2Fpyfa-converter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotX12%2Fpyfa-converter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotX12%2Fpyfa-converter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dotX12","download_url":"https://codeload.github.com/dotX12/pyfa-converter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotX12%2Fpyfa-converter/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270264571,"owners_count":24554793,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-13T02:00:09.904Z","response_time":66,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T16:05:21.830Z","updated_at":"2025-08-13T15:31:20.975Z","avatar_url":"https://github.com/dotX12.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pyfa-converter\nAllows you to convert pydantic models for fastapi param models - query, form, header, cookie, body, etc.\n\n\n\n### How to install?\n`pip install pyfa_converter`\n\n### How to simplify your life?\n```python3\nfrom datetime import datetime\nfrom typing import Optional\n\nfrom fastapi import FastAPI, UploadFile, File, Form\nfrom pydantic import BaseModel, Field\n\nfrom pyfa_converter import FormDepends, PyFaDepends\n\napp = FastAPI()\n\n\nclass PostContractBodySchema(BaseModel):\n    title: str = Field(..., description=\"Description title\")\n    date: Optional[datetime] = Field(\n        None, description=\"Example: 2021-12-14T09:56:31.056Z\"\n    )\n\n\n@app.post(\"/form-data-body\")\nasync def example_foo_body_handler(\n    data1: PostContractBodySchema = PyFaDepends(model=PostContractBodySchema, _type=Form),\n    document: UploadFile = File(...),\n):\n    return {\"title\": data.title, \"date\": data.date, \"file_name\": document.filename}\n```\n\n---\n\n### What do I need to do?\n```python3\nfrom pyfa_converter import PyFaDepends, FormDepends, QueryDepends\nfrom fastapi import Header, Form\n...\n\nasync def foo(data: MyCustomModel = PyFaDepends(MyCustomModel, _type=Header)): ...\nasync def foo(data: MyCustomModel = PyFaDepends(MyCustomModel, _type=Form)): ...\n\nasync def foo(data: MyCustomModel = FormDepends(MyCustomModel)): ...\nasync def foo(data: MyCustomModel = QueryDepends(MyCustomModel)): ...\n```\n\n---\n\nIf you want to accept a file on an endpoint, then the content-type for that endpoint changes from application/json to www-form-data.\n\nFastAPI does not know how to override the pydantic schema so that parameters are passed as form.\nEven if you do\n\n`foo: CustomPydanticModel = Depends()`\nall model attributes will be passed as query, but we want them to become body, that's what this library exists for.\n\n### Usually you use something along the lines of:\n![image](https://user-images.githubusercontent.com/64792903/161484700-642e3d0e-242f-49f6-82e8-45c5e912a2c2.png)\n\nBut, if we accept a lot of fields, then the function becomes very large (the number of attributes for the endpoint increases and it does not look very good).\n\nThanks to this library, it is possible to force the conversion of Field fields into fields of FastAPI Form with full preservation of all attributes (alias, gt, te, description, title, example and more...)\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotx12%2Fpyfa-converter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdotx12%2Fpyfa-converter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotx12%2Fpyfa-converter/lists"}