1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "openApiSpec": `openapi: 3.0.3
12info:
13 title: Swagger Petstore
14 description: A sample API that uses a petstore as an example
15 version: 1.0.0
16servers:
17 - url: https://petstore3.swagger.io/api/v3
18paths:
19 /pet:
20 post:
21 tags:
22 - pet
23 summary: Add a new pet to the store
24 operationId: addPet
25 requestBody:
26 required: true
27 content:
28 application/json:
29 schema:
30 $ref: '#/components/schemas/Pet'
31 responses:
32 '200':
33 description: Successful operation
34 content:
35 application/json:
36 schema:
37 $ref: '#/components/schemas/Pet'
38 put:
39 tags:
40 - pet
41 summary: Update an existing pet
42 operationId: updatePet
43 requestBody:
44 required: true
45 content:
46 application/json:
47 schema:
48 $ref: '#/components/schemas/Pet'
49 responses:
50 '200':
51 description: Successful operation
52 content:
53 application/json:
54 schema:
55 $ref: '#/components/schemas/Pet'
56 /pet/findByStatus:
57 get:
58 tags:
59 - pet
60 summary: Finds Pets by status
61 operationId: findPetsByStatus
62 parameters:
63 - name: status
64 in: query
65 description: Status values that need to be considered for filter
66 required: true
67 schema:
68 type: array
69 items:
70 type: string
71 enum:
72 - available
73 - pending
74 - sold
75 responses:
76 '200':
77 description: successful operation
78 content:
79 application/json:
80 schema:
81 type: array
82 items:
83 $ref: '#/components/schemas/Pet'
84 /pet/{petId}:
85 get:
86 tags:
87 - pet
88 summary: Find pet by ID
89 operationId: getPetById
90 parameters:
91 - name: petId
92 in: path
93 required: true
94 schema:
95 type: integer
96 format: int64
97 responses:
98 '200':
99 description: successful operation
100 content:
101 application/json:
102 schema:
103 $ref: '#/components/schemas/Pet'
104 delete:
105 tags:
106 - pet
107 summary: Deletes a pet
108 operationId: deletePet
109 parameters:
110 - name: petId
111 in: path
112 required: true
113 schema:
114 type: integer
115 format: int64
116 responses:
117 '200':
118 description: Pet deleted
119components:
120 schemas:
121 Pet:
122 type: object
123 required:
124 - name
125 properties:
126 id:
127 type: integer
128 format: int64
129 nullable: true
130 name:
131 type: string
132 example: doggie
133 status:
134 type: string
135 enum:
136 - available
137 - pending
138 - sold
139 default: available`,
140 "format": "yaml",
141 "projectName": "petstore-mcp"
142};
143
144
145const run = await client.actor("vamsi-krishna/openapi-to-mcp-server-generator").call(input);
146
147
148console.log('Results from dataset');
149console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
150const { items } = await client.dataset(run.defaultDatasetId).listItems();
151items.forEach((item) => {
152 console.dir(item);
153});
154
155