refactor: Generate all models and TypedDicts from OpenAPI spec#765
Merged
refactor: Generate all models and TypedDicts from OpenAPI spec#765
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #765 +/- ##
==========================================
- Coverage 96.17% 95.67% -0.51%
==========================================
Files 48 46 -2
Lines 5226 5174 -52
==========================================
- Hits 5026 4950 -76
- Misses 200 224 +24
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
7b4117a to
f449d55
Compare
Drop the hand-written `_models.py` and `_typeddicts.py` and rename the generated files (the `_generated` suffix is no longer needed). All Pydantic models and TypedDicts now come from `datamodel-codegen` against the OpenAPI spec, including `WebhookRepresentation` (added to apify-docs in tandem) and the existing `RequestDraft` / `RequestDraftDelete` shapes. Resolves #758. Notable knock-on changes: - `WebhookRepresentationList` class replaced by a single `encode_webhooks_to_base64` helper in `_utils.py`. - `_wait_for_finish` works against a plain dict (each caller already validates the response into the concrete `Run` / `Build` model), so the hand-written `ActorJob` / `ActorJobResponse` shapes are no longer needed. - `RequestInput` -> `RequestDraft`, `RequestDeleteInput` -> `RequestDraftDelete`, matching the names already used in the spec; the upgrade guide is updated.
f449d55 to
6683d01
Compare
janbuchar
approved these changes
Apr 29, 2026
…ll-models # Conflicts: # src/apify_client/_models_generated.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves #758. Every Pydantic model and TypedDict now comes from the OpenAPI spec — no more hand-maintained shapes alongside the generated ones.
src/apify_client/_models.pyandsrc/apify_client/_typeddicts.py._models_generated.py→_models.py,_typeddicts_generated.py→_typeddicts.py. The_generatedsuffix is no longer needed now that there is no parallel hand-written file.WebhookRepresentationschema added in feat(openapi): Add WebhookRepresentation schema for ad-hoc webhooks apify-docs#2469.Knock-on changes
WebhookRepresentationListclass is gone — replaced by a singleencode_webhooks_to_base64()helper in_utils.py. Callers inactor.py/task.pysimplified towebhooks=encode_webhooks_to_base64(webhooks)._wait_for_finishalready returns a plain dict and each caller validates it against the concreteRun/Buildmodel, so the hand-writtenActorJob/ActorJobResponseshapes are no longer needed.RequestInput→RequestDraft,RequestDeleteInput→RequestDraftDelete(and matching*Dictnames) — 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.RESOURCE_INPUT_TYPEDDICTSinscripts/postprocess_generated_models.pyto seed the typed-dict reachability walk withRequestDraft,RequestDraftDelete, andWebhookRepresentation._*_generated.pyto_{models,typeddicts}.pyto match the new filenames.Pairs with
WebhookRepresentationschema component and references it from thewebhooksquery parameter. The docs PR should land first; this PR's regenerated models depend on it.