Skip to content

Commit 6145c34

Browse files
vdusekclaude
andauthored
docs: add Python API client model generation pipeline to AGENTS.md (#2402)
Add a new section to AGENTS.md documenting the cross-repo CI pipeline that automatically regenerates Pydantic models in `apify-client-python` whenever OpenAPI specs change in this repo. Covers both the trigger flow from `openapi-ci.yaml` and the regeneration workflow in the Python client repo. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 4eaf40e commit 6145c34

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ Add code samples by creating files in `apify-api/openapi/code_samples/{javascrip
6464
- Prefer automatically generated examples from schema over explicit examples.
6565

6666
#### Error responses
67+
6768
- Re-use schemas for error responses defined in `/apify-api/openapi/components/responses`
6869
- Each endpoint should have at least following error responses: 400 (Bad Request), 405 (Method Not Allowed), 429 (Too Many Requests).
6970
- Endpoints that define `security: []` do not use any authentication.
@@ -87,6 +88,26 @@ schema:
8788
const: "constantValue"
8889
```
8990
91+
### Python API client model generation
92+
93+
OpenAPI spec changes in this repo automatically trigger Pydantic model regeneration in `apify-client-python`. The pipeline:
94+
95+
1. **This repo** (`.github/workflows/openapi-ci.yaml`):
96+
- On PR with changes to `apify-api/openapi/**`: lint, build, and validate the bundled spec
97+
- Upload `static/api/openapi.{json,yaml}` as artifacts
98+
- `trigger-client-model-regeneration` job calls `gh workflow run regenerate_models.yaml` in `apify/apify-client-python`, passing `docs_pr_number` and `docs_workflow_run_id`
99+
- On PR close: `cleanup-client-model-pr` job closes the corresponding PR in `apify-client-python` and deletes its branch
100+
101+
2. **apify-client-python** (`.github/workflows/manual_regenerate_models.yaml`):
102+
- Triggered via `workflow_dispatch` (automatically from this repo's CI or manually from GitHub UI)
103+
- Downloads the OpenAPI spec artifact from this repo's workflow run (or fetches from `https://docs.apify.com/api/openapi.json` for manual runs)
104+
- Runs `datamodel-codegen` to generate Pydantic models into `src/apify_client/_models.py`
105+
- Runs `scripts/postprocess_generated_models.py` to fix known codegen issues (e.g. camelCase discriminator fields)
106+
- Commits to branch `update-models-docs-pr-{PR_NUMBER}`, creates/updates a PR
107+
- Posts a cross-repo comment on the original docs PR linking to the generated client PR
108+
109+
Branch naming convention `update-models-docs-pr-{N}` links the two PRs.
110+
90111
### Theme system
91112

92113
Uses `@apify/docs-theme` package - a shared theme across all 6+ documentation repos. Don't modify theme files directly. Changes to the theme propagate via CI to all projects.

0 commit comments

Comments
 (0)