1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "baseline_json": `{
12 "openapi": "3.1.0",
13 "info": {"title": "Orders API", "version": "1.0.0"},
14 "paths": {
15 "/orders/{id}": {
16 "get": {
17 "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "string"}}],
18 "responses": {"200": {"content": {"application/json": {"schema": {"type": "object", "properties": {"id": {"type": "string"}, "total": {"type": "number"}}}}}}}
19 }
20 }
21 }
22}`,
23 "candidate_json": `{
24 "openapi": "3.1.0",
25 "info": {"title": "Orders API", "version": "1.1.0"},
26 "paths": {
27 "/orders/{id}": {
28 "get": {
29 "parameters": [
30 {"name": "id", "in": "path", "required": true, "schema": {"type": "string"}},
31 {"name": "tenant", "in": "header", "required": true, "schema": {"type": "string"}}
32 ],
33 "responses": {"200": {"content": {"application/json": {"schema": {"type": "object", "properties": {"id": {"type": "string"}}}}}}}
34 }
35 }
36 }
37}`,
38 "consumers_json": `{
39 "schema_version": "openapi-consumer-registry@1",
40 "consumers": [
41 {"consumer_id": "checkout", "criticality": "critical", "operations": ["GET /orders/{id}"]},
42 {"consumer_id": "reporting", "criticality": "medium", "operations": ["GET /orders/{id}"]}
43 ]
44}`
45};
46
47
48const run = await client.actor("biztoolsus/openapi-consumer-impact").call(input);
49
50
51console.log('Results from dataset');
52console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
53const { items } = await client.dataset(run.defaultDatasetId).listItems();
54items.forEach((item) => {
55 console.dir(item);
56});
57
58