{"id":27959385,"url":"https://github.com/sourabh-kumar04/pydantic-basic","last_synced_at":"2026-03-01T04:08:10.365Z","repository":{"id":291288452,"uuid":"976746351","full_name":"Sourabh-Kumar04/Pydantic-Basic","owner":"Sourabh-Kumar04","description":"A comprehensive collection of examples demonstrating Pydantic's capabilities for data validation and modeling in Python, including integration with FastAPI.","archived":false,"fork":false,"pushed_at":"2025-05-03T21:31:02.000Z","size":26,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-08T23:27:43.975Z","etag":null,"topics":["fastapi","field-constraints","learning","nested-models","pydantic","python","serialization","validator"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Sourabh-Kumar04.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-05-02T17:11:01.000Z","updated_at":"2025-08-21T08:22:13.000Z","dependencies_parsed_at":"2025-05-03T17:19:41.097Z","dependency_job_id":"bd3cfc01-f24e-42b5-b4b6-cecef522fb27","html_url":"https://github.com/Sourabh-Kumar04/Pydantic-Basic","commit_stats":null,"previous_names":["sourabh-kumar04/pydantic-basic"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Sourabh-Kumar04/Pydantic-Basic","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sourabh-Kumar04%2FPydantic-Basic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sourabh-Kumar04%2FPydantic-Basic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sourabh-Kumar04%2FPydantic-Basic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sourabh-Kumar04%2FPydantic-Basic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Sourabh-Kumar04","download_url":"https://codeload.github.com/Sourabh-Kumar04/Pydantic-Basic/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sourabh-Kumar04%2FPydantic-Basic/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29960235,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-01T01:47:18.291Z","status":"online","status_checked_at":"2026-03-01T02:00:07.437Z","response_time":124,"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":["fastapi","field-constraints","learning","nested-models","pydantic","python","serialization","validator"],"created_at":"2025-05-07T18:29:52.324Z","updated_at":"2026-03-01T04:08:10.318Z","avatar_url":"https://github.com/Sourabh-Kumar04.png","language":"Python","readme":"# 🧰 Pydantic-Basic\r\n\r\nWelcome to **Pydantic-Basic**, a curated collection of examples demonstrating the capabilities of [Pydantic](https://docs.pydantic.dev/latest/) for data validation and modeling in Python. This repository is designed to help developers understand and utilize Pydantic's features effectively, from foundational concepts to integration with FastAPI.\r\n\r\n---\r\n\r\n## 📂 Repository Structure\r\n\r\n```\r\n\r\nPydantic-Basic/\r\n├── 01\\_foundation/\r\n├── 02\\_fields/\r\n├── 03\\_model\\_behaviour/\r\n├── 04\\_nested\\_model/\r\n├── 05\\_serialization/\r\n├── fastapi/\r\n├── main.py\r\n├── README.md\r\n├── LICENSE\r\n├── pyproject.toml\r\n└── uv.lock\r\n\r\n````\r\n\r\n- **01_foundation/**: Introduction to basic Pydantic models and type annotations.\r\n- **02_fields/**: Exploration of field types, default values, and field constraints.\r\n- **03_model_behaviour/**: Understanding model behaviors, including validators and computed fields.\r\n- **04_nested_model/**: Working with nested and recursive models.\r\n- **05_serialization/**: Demonstrating serialization and custom JSON encoding.\r\n- **fastapi/**: Integrating Pydantic models with FastAPI for building APIs.\r\n\r\n---\r\n\r\n## 🚀 Getting Started\r\n\r\n### Prerequisites\r\n\r\nEnsure you have Python 3.9 or higher installed. You can check your Python version using:\r\n\r\n```bash\r\npython --version\r\n````\r\n\r\n### Installation\r\n\r\n1. **Clone the repository:**\r\n\r\n   ```bash\r\n   git clone https://github.com/Sourabh-Kumar04/Pydantic-Basic.git\r\n   cd Pydantic-Basic\r\n   ```\r\n\r\n2. **Install `uv`:**\r\n\r\n   If you haven't installed `uv` yet, you can do so using pip:\r\n\r\n   ```bash\r\n   pip install uv\r\n   ```\r\n\r\n3. **Install project dependencies:**\r\n\r\n   ```bash\r\n   uv sync\r\n   ```\r\n\r\n   This command will install all the dependencies specified in `pyproject.toml` and lock them in `uv.lock`.\r\n\r\n---\r\n\r\n## 🧪 Usage\r\n\r\nEach directory contains Python scripts that can be run independently to observe Pydantic's features in action.\r\n\r\nFor example, to run the foundational examples:\r\n\r\n```bash\r\nuv run 01_foundation/example.py\r\n```\r\n\r\nTo start the FastAPI application:\r\n\r\n```bash\r\nuv run fastapi/fastapi_examples.py\r\n```\r\n\r\n---\r\n\r\n## 📖 Examples Overview\r\n\r\n### ✅ 01\\_foundation\r\n\r\n* Basic model creation using `BaseModel`.\r\n* Type enforcement and automatic data parsing.\r\n\r\n### 🛠️ 02\\_fields\r\n\r\n* Field definitions with default values.\r\n* Field constraints and aliases.\r\n\r\n### 🔄 03\\_model\\_behaviour\r\n\r\n* Custom validators using `@validator`.\r\n* Computed fields with `@property`.\r\n\r\n### 🧩 04\\_nested\\_model\r\n\r\n* Nested models to represent complex data structures.\r\n* Recursive models for hierarchical data like comments.\r\n\r\n### 📤 05\\_serialization\r\n\r\n* Model serialization to dictionaries and JSON.\r\n* Custom JSON encoders for complex types like `datetime`.\r\n\r\n### 🌐 fastapi\r\n\r\n* Building API endpoints with FastAPI.\r\n* Request and response models using Pydantic.\r\n\r\n---\r\n\r\n## 📘 License\r\n\r\nThis project is licensed under the [Apache-2.0 License](LICENSE).\r\n\r\n---\r\n\r\n## 🙋‍♂️ Author\r\n\r\n**Sourabh Kumar**\r\n\r\n* 💼 [LinkedIn](https://linkedin.com/in/sourabh-kumar04)\r\n* 📧 [Email](mailto:sourabh404sourabh@gmail.com)\r\n\r\nFeel free to reach out for collaborations or queries related to this project.\r\n\r\n---\r\n\r\n## ⭐ Acknowledgments\r\n\r\n* [Pydantic Documentation](https://docs.pydantic.dev/latest/)\r\n* [FastAPI Documentation](https://fastapi.tiangolo.com/)\r\n* [uv Documentation](https://docs.astral.sh/uv/)\r\n\r\n---\r\n\r\n```\r\nThis `README.md` reflects the use of `uv` for dependency management and running the FastAPI application. If you need assistance with setting up `pyproject.toml` or have further questions, feel free to ask! \r\n```\r\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsourabh-kumar04%2Fpydantic-basic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsourabh-kumar04%2Fpydantic-basic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsourabh-kumar04%2Fpydantic-basic/lists"}