## Summary
Resolve `{ENV_VAR}` placeholders in the OpenAPI spec before serving it. Replace the monolithic `x-introspect-url` extension with composable `x-server-url` + individual `x-*-path` fields so auth endpoints are configurable per-environment without hardcoding.
## Changes
- **`openapi_first/app.py`** — add `_resolve_spec_env_vars()` that replaces `{ENV_VAR}` patterns (e.g. `{AUTH_SERVER}`) with the corresponding OS environment variable before returning the spec JSON. Called in `__init__` after spec load.
- **`openapi_first/security.py`** — build the introspection URL dynamically from `x-server-url` + `x-introspect-path` extensions on the `bearerAuth` security scheme, instead of reading a single `x-introspect-url`.
## Migration
Existing specs using `x-introspect-url: "https://auth.example.com/introspect"` must switch to the new extension format:
```yaml
components:
securitySchemes:
bearerAuth:
type: http
scheme: bearer
x-server-url: "{AUTH_SERVER}"
x-login-path: "/login"
x-register-path: "/register"
x-logout-path: "/logout"
x-me-path: "/me"
x-introspect-path: "/introspect"
Reviewed-on: #3
Co-authored-by: Vishesh 'ironeagle' Bangotra <aetoskia@gmail.com>
Co-committed-by: Vishesh 'ironeagle' Bangotra <aetoskia@gmail.com>
105 lines
2.2 KiB
TOML
105 lines
2.2 KiB
TOML
[build-system]
|
|
requires = ["setuptools>=68", "wheel"]
|
|
build-backend = "setuptools.build_meta"
|
|
|
|
|
|
[project]
|
|
name = "openapi-first"
|
|
version = "0.0.5"
|
|
description = "Strict OpenAPI-first application bootstrap for FastAPI."
|
|
readme = "README.md"
|
|
requires-python = ">=3.10"
|
|
license = { text = "MIT" }
|
|
|
|
authors = [
|
|
{ name = "Aetos Skia", email = "dev@aetoskia.com" }
|
|
]
|
|
maintainers = [
|
|
{ name = "Aetos Skia", email = "dev@aetoskia.com" }
|
|
]
|
|
|
|
|
|
keywords = [
|
|
"fastapi",
|
|
"openapi",
|
|
"openapi-first",
|
|
"contract-first",
|
|
"api",
|
|
"asgi",
|
|
"microservices",
|
|
]
|
|
|
|
classifiers = [
|
|
"Development Status :: 3 - Alpha",
|
|
"Intended Audience :: Developers",
|
|
"License :: OSI Approved :: MIT License",
|
|
"Programming Language :: Python :: 3",
|
|
"Programming Language :: Python :: 3.10",
|
|
"Programming Language :: Python :: 3.11",
|
|
"Programming Language :: Python :: 3.12",
|
|
"Framework :: FastAPI",
|
|
"Topic :: Software Development :: Libraries",
|
|
"Topic :: Internet :: WWW/HTTP :: HTTP Servers",
|
|
]
|
|
|
|
|
|
dependencies = [
|
|
# Core framework
|
|
"fastapi>=0.110.0",
|
|
|
|
# OpenAPI validation
|
|
"openapi-spec-validator>=0.7.1",
|
|
|
|
# YAML support (optional but recommended)
|
|
"pyyaml>=6.0.1",
|
|
|
|
# Code generation
|
|
"datamodel-code-generator>=0.25.0",
|
|
|
|
# HTTP client for service-to-service (token introspection)
|
|
"httpx>=0.27.0",
|
|
]
|
|
|
|
[project.scripts]
|
|
openapi-first = "openapi_first.cli:main"
|
|
|
|
[project.optional-dependencies]
|
|
dev = [
|
|
"pytest>=8.0.0",
|
|
"pytest-cov>=4.1.0",
|
|
"ruff>=0.3.0",
|
|
"mypy>=1.8.0",
|
|
]
|
|
|
|
docs = [
|
|
"mkdocs>=1.5.0",
|
|
"mkdocs-material>=9.5.0",
|
|
"mkdocstrings[python]>=0.24.0",
|
|
]
|
|
|
|
|
|
[project.urls]
|
|
Homepage = "https://git.aetoskia.com/aetos/openapi-first"
|
|
Documentation = "https://git.aetoskia.com/aetos/openapi-first#readme"
|
|
Repository = "https://git.aetoskia.com/aetos/openapi-first.git"
|
|
Issues = "https://git.aetoskia.com/aetos/openapi-first/issues"
|
|
Versions = "https://git.aetoskia.com/aetos/openapi-first/tags"
|
|
|
|
|
|
[tool.setuptools]
|
|
packages = { find = { include = ["openapi_first*"] } }
|
|
|
|
[tool.setuptools.package-data]
|
|
openapi_first = ["templates/**/*"]
|
|
|
|
|
|
[tool.ruff]
|
|
line-length = 100
|
|
target-version = "py310"
|
|
|
|
|
|
[tool.mypy]
|
|
python_version = "3.10"
|
|
strict = true
|
|
ignore_missing_imports = true
|