1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "previousSpec": `{
12 "openapi": "3.1.2",
13 "info": {
14 "title": "Synthetic Orders API",
15 "version": "1.0"
16 },
17 "paths": {
18 "/orders": {
19 "get": {
20 "parameters": [
21 {
22 "name": "state",
23 "in": "query",
24 "required": false,
25 "schema": {
26 "type": "string",
27 "enum": [
28 "open",
29 "closed"
30 ]
31 }
32 }
33 ],
34 "responses": {
35 "200": {
36 "description": "Order count",
37 "content": {
38 "application/json": {
39 "schema": {
40 "type": "integer"
41 }
42 }
43 }
44 }
45 }
46 }
47 },
48 "/legacy": {
49 "get": {
50 "responses": {
51 "200": {
52 "description": "Legacy"
53 }
54 }
55 }
56 }
57 }
58}`,
59 "currentSpec": `{
60 "openapi": "3.1.2",
61 "info": {
62 "title": "Synthetic Orders API",
63 "version": "2.0"
64 },
65 "paths": {
66 "/orders": {
67 "get": {
68 "parameters": [
69 {
70 "name": "state",
71 "in": "query",
72 "required": true,
73 "schema": {
74 "type": "string",
75 "enum": [
76 "open"
77 ]
78 }
79 }
80 ],
81 "responses": {
82 "200": {
83 "description": "Order count",
84 "content": {
85 "application/json": {
86 "schema": {
87 "type": "integer"
88 }
89 }
90 }
91 }
92 }
93 }
94 }
95 }
96}`
97};
98
99
100const run = await client.actor("fluffy_ingot/openapi-change-preflight").call(input);
101
102
103console.log('Results from dataset');
104console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
105const { items } = await client.dataset(run.defaultDatasetId).listItems();
106items.forEach((item) => {
107 console.dir(item);
108});
109
110