Skip to content

Commit 982c149

Browse files
Pijukatelclaude
andauthored
docs(openapi): Autofix OpenAPI spec validation errors (#2763)
## Summary Autogenerated OpenAPI fixes suggestions based on validation errors generated from running API integration tests with OpenAPI validator turned on. **apify-core version:** https://github.com/apify/apify-core/tree/a300e63c18aaa9ae0b8cbaa334adf8a1fb8ad163 ## Detailed changes description ### Error fixes #### `402` on actor `run-sync-get-dataset-items` (GET) - **Files:** `apify-api/openapi/paths/actors/acts@{actorId}@run-sync-get-dataset-items.yaml` (GET responses) - **Error:** `no schema defined for status code '402' in the openapi spec` - `GET /v2/actors/{actorId}/run-sync-get-dataset-items` - **Root cause:** Starting a run (memory or concurrency limit exceeded, or not enough remaining usage to run a paid Actor) throws a payment-required error defined with HTTP status `402` before the run can start. The spec did not declare `402` for this endpoint. - **Reference:** https://github.com/apify/apify-core/tree/a300e63c18aaa9ae0b8cbaa334adf8a1fb8ad163/src/packages/errors/src/errors/actor.ts#L33 #### `402` on run `resurrect` (POST) - **Files:** `apify-api/openapi/components/objects/actor-runs/resurrect.yaml` - **Error:** `no schema defined for status code '402' in the openapi spec` - `POST /v2/actor-runs/{runId}/resurrect` - **Root cause:** Resurrecting a run re-runs the same quota and payment checks as starting a run and can therefore return the same `402` payment-required error. - **Reference:** https://github.com/apify/apify-core/tree/a300e63c18aaa9ae0b8cbaa334adf8a1fb8ad163/src/api/src/routes/actor_runs/run_resurrect.ts #### `408` on actor-task `run-sync-get-dataset-items` (POST) - **Files:** `apify-api/openapi/paths/actor-tasks/actor-tasks@{actorTaskId}@run-sync-get-dataset-items.yaml` (POST responses) - **Error:** `no schema defined for status code '408' in the openapi spec` - `POST /v2/actor-tasks/{actorTaskId}/run-sync-get-dataset-items` - **Root cause:** A synchronous run that does not reach a terminal status within the endpoint wait limit throws `runTimeoutExceeded`, which is defined with HTTP status `408`. The spec did not declare `408` for this endpoint. - **Reference:** https://github.com/apify/apify-core/tree/a300e63c18aaa9ae0b8cbaa334adf8a1fb8ad163/src/api/src/routes/actor_tasks/run_sync_dataset.ts#L53 #### Missing `readCount` on key-value store stats (POST, 200) - **Files:** `apify-api/openapi/components/schemas/key-value-stores/KeyValueStoreStats.yaml` - **Error:** `must have required property 'readCount'` - `POST /v2/key-value-stores` (`/response/data/stats/readCount`) - **Root cause:** All store stats fields are optional in apify-core and the API serializes only fields that already exist; a freshly created store has no `readCount` yet, so it is absent from the response. The spec incorrectly marked `readCount` (and the other counters) required, matching neither the DB schema nor the sibling `DatasetStats`/`RequestQueueStats` schemas which mark nothing required. - **Reference:** https://github.com/apify/apify-core/tree/a300e63c18aaa9ae0b8cbaa334adf8a1fb8ad163/src/api/src/lib/key_value_stores.ts#L680 ### Refactoring Generalized the key-value store stats fix to the other stats schemas whose counters are optional and lazily populated in apify-core, so the same `must have required property` validation error cannot occur for run, build and webhook stats: - `apify-api/openapi/components/schemas/actor-runs/RunStats.yaml` - drop `required: [restartCount, resurrectCount, computeUnits]` - `apify-api/openapi/components/schemas/actor-builds/BuildStats.yaml` - drop `required: [computeUnits]` - `apify-api/openapi/components/schemas/webhooks/WebhookStats.yaml` - drop `required: [totalDispatches]` Root cause is identical to the key-value store case - these counters are declared optional in the apify-core stats sub-documents, so requiring them in the spec makes valid responses fail response validation. Reference: https://github.com/apify/apify-core/tree/a300e63c18aaa9ae0b8cbaa334adf8a1fb8ad163/src/packages/schemas/src/key_value_stores.ts#L90 ## Issues Partially implements: #2286 --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent f486088 commit 982c149

7 files changed

Lines changed: 6 additions & 11 deletions

File tree

‎apify-api/openapi/components/objects/actor-runs/resurrect.yaml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ sharedResurrect: &sharedResurrect
1212
$ref: ../../responses/BadRequest.yaml
1313
"401":
1414
$ref: ../../responses/Unauthorized.yaml
15+
"402":
16+
$ref: ../../responses/PaymentRequired.yaml
1517
"403":
1618
$ref: ../../responses/Forbidden.yaml
1719
"404":

‎apify-api/openapi/components/schemas/actor-builds/BuildStats.yaml‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
title: BuildStats
2-
required:
3-
- computeUnits
42
type: object
53
properties:
64
durationMillis:

‎apify-api/openapi/components/schemas/actor-runs/RunStats.yaml‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
title: RunStats
2-
required:
3-
- restartCount
4-
- resurrectCount
5-
- computeUnits
62
type: object
73
properties:
84
inputBodyLen:

‎apify-api/openapi/components/schemas/key-value-stores/KeyValueStoreStats.yaml‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
title: KeyValueStoreStats
2-
required:
3-
- readCount
4-
- writeCount
52
type: object
63
properties:
74
readCount:

‎apify-api/openapi/components/schemas/webhooks/WebhookStats.yaml‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
title: WebhookStats
2-
required:
3-
- totalDispatches
42
type: object
53
properties:
64
totalDispatches:

‎apify-api/openapi/paths/actor-tasks/actor-tasks@{actorTaskId}@run-sync-get-dataset-items.yaml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ post:
185185
$ref: ../../components/responses/NotFound.yaml
186186
"405":
187187
$ref: ../../components/responses/MethodNotAllowed.yaml
188+
"408":
189+
$ref: ../../components/responses/Timeout.yaml
188190
"413":
189191
$ref: ../../components/responses/PayloadTooLarge.yaml
190192
"415":

‎apify-api/openapi/paths/actors/acts@{actorId}@run-sync-get-dataset-items.yaml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ get:
177177
$ref: ../../components/responses/BadRequest.yaml
178178
"401":
179179
$ref: ../../components/responses/Unauthorized.yaml
180+
"402":
181+
$ref: ../../components/responses/PaymentRequired.yaml
180182
"403":
181183
$ref: ../../components/responses/Forbidden.yaml
182184
"404":

0 commit comments

Comments
 (0)