Repository navigation
Commit 982c149
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
- schemas
- actor-builds
- actor-runs
- key-value-stores
- webhooks
- paths
- actor-tasks
- actors
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
4 | 2 | | |
5 | 3 | | |
6 | 4 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | 2 | | |
7 | 3 | | |
8 | 4 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | 2 | | |
6 | 3 | | |
7 | 4 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
4 | 2 | | |
5 | 3 | | |
6 | 4 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
| 188 | + | |
| 189 | + | |
188 | 190 | | |
189 | 191 | | |
190 | 192 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
| 180 | + | |
| 181 | + | |
180 | 182 | | |
181 | 183 | | |
182 | 184 | | |
| |||
0 commit comments