Metadata-Version: 2.5
Name: standard-fastapi
Version: 0.2.1
Summary: FastAPI integration for the Standard Python library
Project-URL: Documentation, https://appunni-m.github.io/python-standard/api/
Project-URL: Repository, https://github.com/appunni-m/python-standard
Author: Standard contributors
License-Expression: MIT
License-File: LICENSE
Keywords: fastapi,pydantic-settings,standard
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Typing :: Typed
Requires-Python: >=3.11
Requires-Dist: fastapi<1,>=0.115
Requires-Dist: standard==0.2.1
Description-Content-Type: text/markdown

# standard-fastapi

FastAPI integration for the [`standard`](https://pypi.org/project/standard/)
Python library. After publication, install it directly with
`python -m pip install standard-fastapi` or use the `standard[fastapi]` extra.

Define the application's settings model in `core/settings.py`:

```python
from std.config import YamlSettings


class Settings(YamlSettings):
    std_config_file = "settings.yaml"
    service_name: str
```

In `main.py`, create the app and inject that settings instance once:

```python
from fastapi import Depends, FastAPI
from app.core.settings import Settings
from std.fastapi import settings_dependency


def create_app() -> FastAPI:
    settings = Settings()  # Create once in the application composition root.
    app = FastAPI()
    app.state.settings = settings
    settings_dep = settings_dependency(Settings)

    @app.get("/health")
    async def health(settings: Settings = Depends(settings_dep)) -> dict[str, str]:
        return {"service": settings.service_name}

    return app
```

Create `Settings()` once in `main.py` and assign the instance to
`app.state.settings`. The dependency returns that injected instance and never
constructs or reloads settings.

The integration includes `APIConfig` and `FastAPISetup` for app construction,
`LifecycleManager` for injected background services, `AppTokenAuth` and
`TokenAuthMiddleware`, health-check endpoints, request logging middleware, and
the Pydantic Settings dependency helper. Core service lifecycle types remain
available as `std.service` from `standard`.

The core library and this package are versioned independently. The `std`
command and core modules remain in the `standard` distribution. See the
[API reference](https://appunni-m.github.io/python-standard/api/) for public
signatures, behavior, and examples.
