Skip to content

docs(openapi): Autofix OpenAPI spec validation errors - #3204

Closed
Pijukatel wants to merge 1 commit into
masterfrom
claude/funny-ptolemy-phf4wv
Closed

Pijukatel wants to merge 1 commit into
masterfrom
claude/funny-ptolemy-phf4wv

Conversation

@Pijukatel

Copy link
Copy Markdown
Contributor

Summary

Autogenerated OpenAPI fixes suggestions based on validation errors generated from running API integration tests with OpenAPI validator turned on.

Replaces #3200, which GitHub closed after a branch force-push and will not reopen.

Error log: Production response-validation log exported from Mezmo (6d31d9db-errors, 318 lines, Oct 30 – Nov 6 2026), supplied manually. There is no public link; the log is not reproducible in the PR test environment.

apify-core version: https://github.com/apify/apify-core/tree/8870ffca6640f3f60e8aeaee328a13f3ac90d8c4 (develop at the time the log was processed)

Stop reason: The scope of this iteration was limited to endpoints that are completely missing from the spec. Of the three such endpoints in the log, only GET /v2/openapi.json belongs in the public reference and is added here. The deprecated direct-upload-url endpoint and the internal POST /v2/meta/github-leaked-tokens webhook stay undocumented on purpose, and the remaining "not found" errors are malformed URLs that Express serves leniently. All of these are skipped in the validator instead, see the companion apify-core branch claude/funny-ptolemy-phf4wv (commits https://github.com/apify/apify-core/commit/753b48854aa744d6040d3f0822464fec91f1fc98 and https://github.com/apify/apify-core/commit/e72e879303adb3f4bcfb74d6e6182c5bd4e8324f). All other errors in the log are schema errors on existing endpoints and are listed below without fixes.

The PR test environment was not run for this change (push to the validator branch was not available in this session). Regression check was done statically: the bundled openapi.json built from this branch differs from the one built from master only by the added path and the added tag (OpenAPI). Every pre-existing path, schema, tag and tag group is unchanged. pnpm openapi:lint passes.

Detailed changes description

Error fixes

Add missing GET /v2/openapi.json

Refactoring

None.

Unfixed errors

False positives

Requests with a doubled slash after /v2 reported as "not found" (88 occurrences)

Misspelled runs/last-successded served as runs/last (3 occurrences)

Paths with a URL-encoded query string (...runs/last/dataset/items%3Ftoken%3D..., 8 occurrences, 401)

POST /v2/meta/github-leaked-tokens (2 occurrences, 204)

GET /v2/key-value-stores/{storeId}/records/{recordKey}/direct-upload-url (56 occurrences, 201)

Potential API bugs

runs/last* wildcard routes accept arbitrary suffixes

direct-upload-url returns the raw store document and 201 on a GET

Out of scope errors

Schema errors on existing endpoints (not in this iteration's scope)

  • Error: GET /v2/store must be string at /response/data/items/{n}/categories/0 (126) and must be array at /response/data/items/{n}/categories (24); GET /v2/actors/{actorId} must be string at /response/data/categories/0 (1); GET /v2/request-queues/{queueId} and POST /v2/request-queues must be >= 0 at /response/data/totalRequestCount (26); POST /v2/actors no schema defined for status code '409' (7); POST /v2/actor-runs/{runId}/reboot and /metamorph must be string at /response/data/integrationTracking/appId (7); POST /v2/actor-runs/{runId}/abort meta.origin not in enum (2); GET /v2/store no schema defined for status code '402' (1); GET /v2/actors/{actorId}/versions/0.0 must be array at /response/data/sourceFiles (1).
  • Root cause: These are property-level schema mismatches on endpoints that already exist in the spec. This iteration was explicitly limited to completely missing endpoints, so they are left for a follow-up.

Issues

Partially implements: #2286


Generated by Claude Code

Error: {"errors":[{"message":"not found","path":"/v2/openapi.json"}],"method":"GET","msg":"Response OpenAPI validation error","rt":"misc.openApi","statusCode":200.0,"url":"/v2/openapi.json"} (also logged with statusCode 304.0)
Files: apify-api/openapi/paths/tools/openapi.json.yaml:1, apify-api/openapi/openapi.yaml:810, apify-api/openapi/components/tags.yaml:450, apify-api/openapi/components/x-tag-groups.yaml:46
Root cause: The API serves the public, unauthenticated `misc.openApi` route (GET `/v2/openapi.json`) which returns the bundled OpenAPI definition, but the spec had no path for it, so the validator reports every response as "not found". Express sends the body via `res.send`, which adds an `ETag` and answers a matching `If-None-Match` with an empty 304, so the 304 response is documented as well. A new `OpenAPI` tag is added under the "Utility tools" group so the endpoint gets a docs page.
Reference: https://github.com/apify/apify-core/tree/8870ffca6640f3f60e8aeaee328a13f3ac90d8c4/src/api/src/routes/misc/openapi.ts#L17 and https://github.com/apify/apify-core/tree/8870ffca6640f3f60e8aeaee328a13f3ac90d8c4/src/api/src/routes/routes_config.ts#L1398

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@apify-service-account

apify-service-account commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

🗑️ Preview for this PR was deleted.

@Pijukatel Pijukatel closed this Nov 6, 2026
@apify-service-account

Copy link
Copy Markdown
Contributor

API behavior and specification alignment:

  • 401 is not documented: the endpoint needs no token, but a request that carries an invalid token gets rejected. Request: GET /v2/openapi.json?token=<invalid> (same with Authorization: Bearer <invalid>). Response: 401 {"error":{"type":"user-or-token-not-found","message":"User was not found or authentication token is not valid"}}

Reviewed commit: 484c960

@Pijukatel
Pijukatel deleted the claude/funny-ptolemy-phf4wv branch November 6, 2026 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants