You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor: Generate all models and TypedDicts from OpenAPI spec (#765)
Closes: #758
## Summary
Every Pydantic model and TypedDict now comes from the
OpenAPI spec — no more hand-maintained shapes alongside the generated
ones.
- Deleted the hand-written `src/apify_client/_models.py` and
`src/apify_client/_typeddicts.py`.
- Renamed `_models_generated.py` → `_models.py`,
`_typeddicts_generated.py` → `_typeddicts.py`. The `_generated` suffix
is no longer needed now that there is no parallel hand-written file.
- Regenerated models pick up the new `WebhookRepresentation` schema
added in apify/apify-docs#2469.
### Knock-on changes
- `WebhookRepresentationList` class is gone — replaced by a single
`encode_webhooks_to_base64()` helper in `_utils.py`. Callers in
`actor.py` / `task.py` simplified to
`webhooks=encode_webhooks_to_base64(webhooks)`.
- `_wait_for_finish` already returns a plain dict and each caller
validates it against the concrete `Run` / `Build` model, so the
hand-written `ActorJob` / `ActorJobResponse` shapes are no longer
needed.
- `RequestInput` → `RequestDraft`, `RequestDeleteInput` →
`RequestDraftDelete` (and matching `*Dict` names) — these were
hand-rolled aliases for shapes that are already in the spec under the
canonical names. The v3 upgrade guide is updated to match.
- Bumped `RESOURCE_INPUT_TYPEDDICTS` in
`scripts/postprocess_generated_models.py` to seed the typed-dict
reachability walk with `RequestDraft`, `RequestDraftDelete`, and
`WebhookRepresentation`.
- Updated lint per-file-ignores from `_*_generated.py` to
`_{models,typeddicts}.py` to match the new filenames.
## Pairs with
- apify/apify-docs#2469 — adds the `WebhookRepresentation` schema
component and references it from the `webhooks` query parameter. The
docs PR should land first; this PR's regenerated models depend on it.
Copy file name to clipboardExpand all lines: .rules.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ uv run poe type-check # Run ty type checker
19
19
uv run poe unit-tests # Run unit tests
20
20
uv run poe check-docstrings # Verify async docstrings match sync
21
21
uv run poe fix-docstrings # Auto-fix async docstrings
22
-
uv run poe generate-models # Regenerate _models_generated.py and _typeddicts_generated.py from live OpenAPI spec
22
+
uv run poe generate-models # Regenerate _models.py and _typeddicts.py from live OpenAPI spec
23
23
uv run poe generate-models-from-file <path># Regenerate from a local OpenAPI spec file
24
24
25
25
# Run a single test
@@ -73,7 +73,7 @@ Docstrings are written on sync clients and **automatically copied** to async cli
73
73
74
74
### Data Models
75
75
76
-
`src/apify_client/_models_generated.py` and `src/apify_client/_typeddicts_generated.py` are **auto-generated** — do not edit them manually. The hand-maintained `src/apify_client/_models.py` and `src/apify_client/_typeddicts.py` hold only shapes that are not exposed by the OpenAPI spec (or that need local logic); import generated types directly from the `_*_generated` modules.
76
+
`src/apify_client/_models.py` and `src/apify_client/_typeddicts.py` are **auto-generated** — do not edit them manually. Every Pydantic model and TypedDict comes from the OpenAPI spec.
77
77
78
78
- Generated by `datamodel-code-generator` from the OpenAPI spec at `https://docs.apify.com/api/openapi.json` (config in `pyproject.toml` under `[tool.datamodel-codegen]`, aliases in `datamodel_codegen_aliases.json`)
79
79
- After generation, `scripts/postprocess_generated_models.py` is run to apply additional fixes
0 commit comments