SHELL := /usr/bin/env bash .DEFAULT_GOAL := help API_DIR := $(CURDIR) ROOT_DIR := $(abspath $(API_DIR)/..) CODEGEN_PYTHON ?= $(API_DIR)/.venv-codegen/bin/python BOOTSTRAP_PYTHON ?= python3 REDOCLY ?= $(API_DIR)/node_modules/.bin/redocly ##@ API contracts .PHONY: install install: ## Install pinned OpenAPI tooling @if [ ! -x "$(CODEGEN_PYTHON)" ]; then $(BOOTSTRAP_PYTHON) -m venv "$(API_DIR)/.venv-codegen"; fi "$(CODEGEN_PYTHON)" -m pip install --disable-pip-version-check -r "$(ROOT_DIR)/scripts/requirements-codegen.txt" npm ci --prefix "$(API_DIR)" --ignore-scripts --no-audit --no-fund .PHONY: bundle bundle: ## Merge split schemas and create public and ML bundles "$(CODEGEN_PYTHON)" "$(ROOT_DIR)/scripts/merge-schemas.py" "$(API_DIR)/core" "$(CODEGEN_PYTHON)" "$(ROOT_DIR)/scripts/merge-schemas.py" "$(API_DIR)/ml" "$(REDOCLY)" bundle "$(API_DIR)/core/openapi.yml" --output "$(API_DIR)/core/openapi.bundle.yml" "$(REDOCLY)" bundle "$(API_DIR)/ml/openapi.yml" --output "$(API_DIR)/ml/openapi.bundle.yml" .PHONY: lint lint: bundle ## Lint both bundled contracts "$(REDOCLY)" lint --config "$(API_DIR)/redocly.yaml" "$(API_DIR)/core/openapi.bundle.yml" "$(REDOCLY)" lint --config "$(API_DIR)/redocly.yaml" "$(API_DIR)/ml/openapi.bundle.yml" .PHONY: check check: lint ## Build and lint both contract bundles PYTHONDONTWRITEBYTECODE=1 "$(CODEGEN_PYTHON)" -m unittest discover -s "$(ROOT_DIR)/scripts" -p 'test_merge_schemas.py' PYTHONDONTWRITEBYTECODE=1 "$(CODEGEN_PYTHON)" -m unittest discover -s "$(ROOT_DIR)/scripts" -p 'test_contract_copies.py' .PHONY: check-compat check-compat: bundle ## Compare the public contract with API_BASE_REF API_BASE_REF="$(API_BASE_REF)" REDOCLY="$(REDOCLY)" CODEGEN_PYTHON="$(CODEGEN_PYTHON)" bash "$(ROOT_DIR)/scripts/check-api-compat.sh" .PHONY: check-toolchain check-toolchain: ## Check OpenAPI 3.2.0 support with ogen, Orval, and Pydantic on the compatibility fixture "$(REDOCLY)" lint --config "$(API_DIR)/redocly.yaml" "$(API_DIR)/testdata/openapi-3.2.0.yml" $(MAKE) -C "$(ROOT_DIR)/backend" check-ogen-compat $(MAKE) -C "$(ROOT_DIR)/frontend" check-orval-compat $(MAKE) -C "$(ROOT_DIR)/ml" check-pydantic-compat .PHONY: fmt fmt: ## Format handwritten OpenAPI YAML files "$(API_DIR)/node_modules/.bin/prettier" --write "$(API_DIR)/**/*.yml" "$(API_DIR)/redocly.yaml" .PHONY: fmt-check fmt-check: ## Check OpenAPI YAML formatting "$(API_DIR)/node_modules/.bin/prettier" --check "$(API_DIR)/**/*.yml" "$(API_DIR)/redocly.yaml" .PHONY: verify verify: check check-toolchain ## Run contract lint and generator compatibility checks ##@ Help .PHONY: help help: ## Show available targets @awk 'BEGIN{FS=":.*##"; printf "\nUsage:\n make -C api \n"} /^[a-zA-Z0-9_-]+:.*##/ {printf " %-16s %s\n", $$1, $$2} /^##@/ {printf "\n%s\n", substr($$0, 5)}' $(MAKEFILE_LIST)