Standard API response DTOs using Pydantic (framework-agnostic)
Project description
pydantic-response-models
Standard API response DTOs using Pydantic (framework-agnostic).
Installation
pip install pydantic-response-models
Usage
from pydantic_response_models import (
SuccessResponse,
ErrorResponse,
PaginatedResponse,
MessageResponse,
email_field,
token_field
)
from pydantic import BaseModel
# Success response
response = SuccessResponse(data={"id": 1, "name": "John"})
# Error response
error = ErrorResponse(error="Not found", code="404")
# Paginated response
paginated = PaginatedResponse(
items=[...],
total=100,
page=1,
page_size=20,
pages=5
)
# Use field factories in your models
class LoginRequest(BaseModel):
email: str = email_field()
token: str = token_field()
Features
- ✅ Generic response wrappers
- ✅ Type-safe with Pydantic
- ✅ Framework-agnostic (works with FastAPI, Flask, Django, etc.)
- ✅ Consistent field definitions
- ✅ Pagination support
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pydantic_response_models-0.1.0.tar.gz.
File metadata
- Download URL: pydantic_response_models-0.1.0.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d829df4349b7c9ee63b8215a769ffdcd94edda0b9b847e5dd64a35307aad619
|
|
| MD5 |
54c56df4b8fa2287b09a819d6436ceb4
|
|
| BLAKE2b-256 |
888336de9e5fe23484ca8976dbe17b654f8d91df3ae7b389d3951d0b9bce1c31
|
File details
Details for the file pydantic_response_models-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pydantic_response_models-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f443d75d5f73588890af1d8f941460b98ead7a6795ba77fcb6a80c4bfeddf11
|
|
| MD5 |
8203c7cb620527bbd78bdf8e8bec07fb
|
|
| BLAKE2b-256 |
bf0a838a3c11ae374f2a08b2754dde0e8fc3928900bc237e64413aedfdb74fdf
|