Files
openapi-first/openapi_first/templates/model_app/models.py
Vishesh 'ironeagle' Bangotra a3c063b569 docs(templates): document CRUD and model CRUD apps and expose them in mkdocs
- Add comprehensive module and function docstrings to crud_app and model_app templates
- Document OpenAPI-first guarantees, non-goals, and usage patterns in templates
- Add template-level __init__.py files with CLI and client usage examples
- Update mkdocs.yml to include CRUD and model-based CRUD template documentation
- Ensure template documentation follows strict package-bound mkdocstrings rules
2026-01-11 21:42:30 +05:30

51 lines
1.2 KiB
Python

"""
Pydantic domain models for the CRUD example.
This module defines Pydantic models that represent the domain entities
used by the service. These models are referenced by the OpenAPI
specification for request and response schemas.
The models are declarative and framework-agnostic. They contain no
persistence logic, validation beyond type constraints, or business
behavior.
This module is not part of the ``openapi_first`` library API surface.
It exists solely to support the example application template.
"""
from pydantic import BaseModel
class ItemBase(BaseModel):
"""
Base domain model for an item.
Defines fields common to all item representations.
"""
name: str
price: float
class ItemCreate(ItemBase):
"""
Domain model for item creation requests.
This model is used for request bodies when creating new items.
It intentionally excludes the ``id`` field, which is assigned
by the service.
"""
pass
class Item(ItemBase):
"""
Domain model for a persisted item.
This model represents the full item state returned in responses,
including the server-assigned identifier.
"""
id: int