Skip to content

Commit 5586305

Browse files
refactor: fetch API endpoint catalog on demand and harden apify api
Download https://docs.apify.com/api/openapi.json at runtime when --list-endpoints is used, instead of bundling a pre-generated api-endpoints.json. Drops the prepack fetch step and the fetch-api-endpoints script so the list can no longer go stale between releases. While here, address staff-review findings on the apify api command: - ^v2\/? could over-strip paths like "v2things/x"; require a trailing slash and accept it case-insensitively. - --body was silently sent on GET/HEAD, triggering an unfriendly fetch TypeError. Reject early with a clear validation message. - Custom headers could duplicate Content-Type due to case differences; apply overrides case-insensitively. - On non-2xx responses, write the JSON response body to stdout (matches gh api) so pipelines like `apify api ... | jq` still receive the payload; status line stays on stderr. - Document the one-header-per-invocation restriction in --header. - Reset process.exitCode in beforeEach and capture actorId before assertions so the api-tests don't pass on inherited state or leak actors when an assertion fails. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 735090e commit 5586305

7 files changed

Lines changed: 162 additions & 726 deletions

File tree

docs/reference.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ FLAGS
7878
"-" to read from stdin.
7979
-H, --header=<value> Additional HTTP header(s). Pass a
8080
single "key:value" string, or a JSON object like '{"X-Foo":
81-
"bar", "X-Baz": "qux"}' to send multiple headers.
81+
"bar", "X-Baz": "qux"}' to send multiple headers. The flag
82+
can only be used once; use the JSON form for multiple
83+
headers.
8284
-l, --list-endpoints List all available Apify API
8385
endpoints.
8486
-X, --method=<option> The HTTP method to use. Defaults to

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@
1717
"format": "biome format . && prettier --check \"**/*.{md,yml,yaml}\"",
1818
"format:fix": "biome format --write . && prettier --write \"**/*.{md,yml,yaml}\"",
1919
"clean": "rimraf dist",
20-
"fetch-api-endpoints": "tsx scripts/fetch-api-endpoints.ts",
2120
"build": "yarn clean && tsc && tsup",
2221
"build-bundles": "bun run scripts/build-cli-bundles.ts",
23-
"prepack": "yarn insert-cli-metadata && (yarn fetch-api-endpoints || echo 'Warning: Failed to fetch API endpoints, using existing file') && yarn build && yarn update-docs",
22+
"prepack": "yarn insert-cli-metadata && yarn build && yarn update-docs",
2423
"insert-cli-metadata": "tsx scripts/insert-cli-metadata.ts",
2524
"update-docs": "tsx scripts/generate-cli-docs.ts",
2625
"postinstall": "node -e \"console.log('We have an active developer community on Discord. You can find it on https://discord.gg/crawlee-apify-801163717915574323.');\"",

scripts/fetch-api-endpoints.ts

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)