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