{"id":13705622,"url":"https://nf1s.github.io/sanic-pydantic/","last_synced_at":"2025-05-05T16:33:22.315Z","repository":{"id":40363474,"uuid":"252673392","full_name":"nf1s/sanic-pydantic","owner":"nf1s","description":"A library for parsing and validating http requests for sanic web-framework using pydantic library","archived":true,"fork":false,"pushed_at":"2023-02-11T01:45:39.000Z","size":1890,"stargazers_count":7,"open_issues_count":5,"forks_count":3,"subscribers_count":0,"default_branch":"master","last_synced_at":"2024-10-02T23:14:42.281Z","etag":null,"topics":["json","json-parser","pydantic","sanic","sanic-framework","web","webargs"],"latest_commit_sha":null,"homepage":"https://ahmednafies.github.io/sanic-pydantic/","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/nf1s.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-04-03T08:24:55.000Z","updated_at":"2024-07-20T10:00:03.000Z","dependencies_parsed_at":"2024-01-14T21:10:17.061Z","dependency_job_id":"665eb53f-a79f-4a2a-aed9-095d06ee50d9","html_url":"https://github.com/nf1s/sanic-pydantic","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nf1s%2Fsanic-pydantic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nf1s%2Fsanic-pydantic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nf1s%2Fsanic-pydantic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nf1s%2Fsanic-pydantic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nf1s","download_url":"https://codeload.github.com/nf1s/sanic-pydantic/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224193158,"owners_count":17271238,"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","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":["json","json-parser","pydantic","sanic","sanic-framework","web","webargs"],"created_at":"2024-08-02T22:00:45.043Z","updated_at":"2024-11-13T13:30:43.532Z","avatar_url":"https://github.com/nf1s.png","language":"Python","funding_links":[],"categories":["Extensions"],"sub_categories":["Utils"],"readme":"# Sanic Pyndatic\n\n[![CircleCI](https://circleci.com/gh/nf1s/sanic-pydantic.svg?style=shield)](https://circleci.com/gh/nf1s/sanic-pydantic) [![codecov](https://codecov.io/gh/nf1s/sanic-pydantic/branch/master/graph/badge.svg)](https://codecov.io/gh/nf1s/sanic-pydantic) ![GitHub Pipenv locked Python version](https://img.shields.io/github/pipenv/locked/python-version/nf1s/sanic-pydantic) [![Downloads](https://pepy.tech/badge/sanic-pydantic)](https://pepy.tech/project/sanic-pydantic) ![license](https://img.shields.io/badge/license-MIT-green)\n\n## Description\nA library for parsing and validating http requests for sanic web-framework using pydantic library \n\nFull documentation [here](https://nf1s.github.io/sanic-pydantic/)\n\n## Requirements\n\n\tpython \u003e= 3.7\n\n## How to install\n\n```bash\npip install sanic-pydantic\n```\n\n## Dependencies\n\n\tpydantic\n\n## Example\n\n```python\n\nfrom sanic_pydantic import webargs\n\nfrom sanic import Sanic\nfrom sanic.response import json\nfrom pydantic import BaseModel\n\napp = Sanic(\"new app\")\n\n\nclass PathModel(BaseModel):\n    id: int\n\n\nclass QueryModel(BaseModel):\n    name: str\n\n\nclass BodyModel(BaseModel):\n    age: int\n\n\nclass HeadersModel(BaseModel):\n    api_key: str = Field(alias=\"x-api-key\")\n\n\n@app.route(\"/get/\u003cid:int\u003e\", methods=[\"GET\"])\n@webargs(path=PathModel, headers=HeadersModel)\ndef example_get_endpoint_params(request, id, **kwargs):\n    response = json({\"id\":id})\n    return response\n\n@app.route(\"/get-request\", methods=[\"GET\"])\n@webargs(query=QueryModel)\ndef example_get_endpoint(request, **kwargs):\n    print(kwargs)\n    response = json(kwargs)\n    return response\n\n\n@app.route(\"/post-request\", methods=[\"POST\"])\n@webargs(query=QueryModel, body=BodyModel)\ndef example_post_endpoint(request, **kwargs):\n    print(kwargs)\n    response = json(kwargs)\n    return response\n\n\n@app.route(\"/async-get-request\", methods=[\"GET\"])\n@webargs(query=QueryModel)\nasync def async_example_get_endpoint(request, **kwargs):\n    print(kwargs)\n    response = json(kwargs)\n    return response\n\n\n@app.route(\"/async-post-request\", methods=[\"POST\"])\n@webargs(query=QueryModel, body=BodyModel)\nasync def async_example_post_endpoint(request, **kwargs):\n    print(kwargs)\n    response = json(kwargs)\n    return response\n\nif __name__ == \"__main__\":\n    app.run(host=\"0.0.0.0\", port=8000)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/nf1s.github.io%2Fsanic-pydantic%2F","html_url":"https://awesome.ecosyste.ms/projects/nf1s.github.io%2Fsanic-pydantic%2F","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/nf1s.github.io%2Fsanic-pydantic%2F/lists"}