1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "oldSpec": `{
12 "openapi": "3.0.3",
13 "info": {
14 "title": "Order API",
15 "version": "1.0"
16 },
17 "paths": {
18 "/orders/{id}": {
19 "parameters": [
20 {
21 "name": "id",
22 "in": "path",
23 "required": true,
24 "schema": {
25 "type": "string"
26 }
27 }
28 ],
29 "get": {
30 "responses": {
31 "200": {
32 "description": "OK",
33 "content": {
34 "application/json": {
35 "schema": {
36 "type": "object",
37 "required": [
38 "id",
39 "status"
40 ],
41 "properties": {
42 "id": {
43 "type": "string"
44 },
45 "status": {
46 "type": "string",
47 "enum": [
48 "open",
49 "paid"
50 ]
51 }
52 }
53 }
54 }
55 }
56 }
57 }
58 },
59 "post": {
60 "requestBody": {
61 "required": true,
62 "content": {
63 "application/json": {
64 "schema": {
65 "type": "object",
66 "required": [
67 "status"
68 ],
69 "properties": {
70 "status": {
71 "type": "string",
72 "enum": [
73 "open",
74 "paid"
75 ]
76 }
77 }
78 }
79 }
80 }
81 },
82 "responses": {
83 "204": {
84 "description": "Updated"
85 }
86 }
87 }
88 }
89 }
90}`,
91 "newSpec": `{
92 "openapi": "3.0.3",
93 "info": {
94 "title": "Order API",
95 "version": "2.0"
96 },
97 "paths": {
98 "/orders/{id}": {
99 "parameters": [
100 {
101 "name": "id",
102 "in": "path",
103 "required": true,
104 "schema": {
105 "type": "string"
106 }
107 }
108 ],
109 "get": {
110 "responses": {
111 "200": {
112 "description": "OK",
113 "content": {
114 "application/json": {
115 "schema": {
116 "type": "object",
117 "required": [
118 "id",
119 "status"
120 ],
121 "properties": {
122 "id": {
123 "type": "string"
124 },
125 "status": {
126 "type": "string",
127 "enum": [
128 "open",
129 "paid",
130 "refunded"
131 ]
132 }
133 }
134 }
135 }
136 }
137 }
138 },
139 "parameters": [
140 {
141 "name": "X-Tenant",
142 "in": "header",
143 "required": true,
144 "schema": {
145 "type": "string"
146 }
147 }
148 ]
149 },
150 "post": {
151 "requestBody": {
152 "required": true,
153 "content": {
154 "application/json": {
155 "schema": {
156 "type": "object",
157 "required": [
158 "status"
159 ],
160 "properties": {
161 "status": {
162 "type": "string",
163 "enum": [
164 "open"
165 ]
166 }
167 }
168 }
169 }
170 }
171 },
172 "responses": {
173 "202": {
174 "description": "Queued"
175 }
176 }
177 }
178 },
179 "/health": {
180 "get": {
181 "responses": {
182 "200": {
183 "description": "Healthy"
184 }
185 }
186 }
187 }
188 }
189}`,
190 "severityFilter": [
191 "high",
192 "warning",
193 "info"
194 ]
195};
196
197
198const run = await client.actor("afkdigital/openapi-breaking-change-detector").call(input);
199
200
201console.log('Results from dataset');
202console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
203const { items } = await client.dataset(run.defaultDatasetId).listItems();
204items.forEach((item) => {
205 console.dir(item);
206});
207
208