1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "spec": {
12 "openapi": "3.0.0",
13 "info": {
14 "title": "Pet API",
15 "version": "1"
16 },
17 "servers": [
18 {
19 "url": "https://api.example.com"
20 }
21 ],
22 "paths": {
23 "/pets/{id}": {
24 "get": {
25 "operationId": "getPet",
26 "summary": "Get a pet",
27 "parameters": [
28 {
29 "name": "id",
30 "in": "path",
31 "required": true,
32 "schema": {
33 "type": "integer"
34 },
35 "description": "Pet id"
36 }
37 ]
38 }
39 },
40 "/pets": {
41 "post": {
42 "operationId": "addPet",
43 "summary": "Add a pet",
44 "requestBody": {
45 "required": true,
46 "content": {
47 "application/json": {
48 "schema": {
49 "type": "object",
50 "required": [
51 "name"
52 ],
53 "properties": {
54 "name": {
55 "type": "string"
56 }
57 }
58 }
59 }
60 }
61 }
62 }
63 }
64 }
65 }
66};
67
68
69const run = await client.actor("colt2822/openapi-to-mcp-converter").call(input);
70
71
72console.log('Results from dataset');
73console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
74const { items } = await client.dataset(run.defaultDatasetId).listItems();
75items.forEach((item) => {
76 console.dir(item);
77});
78
79