Skip to content

refactor: Generate all models and TypedDicts from OpenAPI spec#765

Merged
vdusek merged 2 commits intomasterfrom
refactor/generate-all-models
Apr 29, 2026
Merged

refactor: Generate all models and TypedDicts from OpenAPI spec#765
vdusek merged 2 commits intomasterfrom
refactor/generate-all-models

Conversation

@vdusek
Copy link
Copy Markdown
Contributor

@vdusek vdusek commented Apr 28, 2026

Summary

Resolves #758. 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 feat(openapi): Add WebhookRepresentation schema for ad-hoc webhooks 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.
  • RequestInputRequestDraft, RequestDeleteInputRequestDraftDelete (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

@vdusek vdusek added adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team. labels Apr 28, 2026
@vdusek vdusek self-assigned this Apr 28, 2026
@vdusek vdusek requested a review from Pijukatel April 28, 2026 08:05
@github-actions github-actions Bot added this to the 139th sprint - Tooling team milestone Apr 28, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 28, 2026

Codecov Report

❌ Patch coverage is 86.76471% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.67%. Comparing base (4d7b67d) to head (960e861).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/apify_client/_utils.py 30.76% 18 Missing ⚠️
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     
Flag Coverage Δ
integration 95.67% <86.76%> (-0.51%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@vdusek vdusek force-pushed the refactor/generate-all-models branch from 7b4117a to f449d55 Compare April 28, 2026 08:20
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.
@vdusek vdusek force-pushed the refactor/generate-all-models branch from f449d55 to 6683d01 Compare April 28, 2026 08:45
@vdusek vdusek requested a review from janbuchar April 28, 2026 13:27
@vdusek vdusek merged commit fe6546b into master Apr 29, 2026
24 checks passed
@vdusek vdusek deleted the refactor/generate-all-models branch April 29, 2026 21:43
…ll-models

# Conflicts:
#	src/apify_client/_models_generated.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generate all models and TypedDicts from the OpenAPI spec

3 participants