| 172 | // running HTTP server, all the way through the compiled binary → |
| 173 | // MCP → QuickJS → openapi-invoker → HttpClient chain. |
| 174 | const startOpenApiServer = () => { |
| 175 | const Pet = { |
| 176 | type: "object", |
| 177 | properties: { |
| 178 | id: { type: "integer" }, |
| 179 | name: { type: "string" }, |
| 180 | tag: { type: "string" }, |
| 181 | }, |
| 182 | required: ["id", "name"], |
| 183 | }; |
| 184 | |
| 185 | const spec = { |
| 186 | openapi: "3.0.0", |
| 187 | info: { title: "Petstore Smoke API", version: "0.0.1" }, |
| 188 | paths: { |
| 189 | "/pets": { |
| 190 | get: { |
| 191 | operationId: "listPets", |
| 192 | responses: { |
| 193 | "200": { |
| 194 | description: "ok", |
| 195 | content: { |
| 196 | "application/json": { schema: { type: "array", items: Pet } }, |
| 197 | }, |
| 198 | }, |
| 199 | }, |
| 200 | }, |
| 201 | }, |
| 202 | "/pets/{petId}": { |
| 203 | get: { |
| 204 | operationId: "getPet", |
| 205 | parameters: [ |
| 206 | { |
| 207 | name: "petId", |
| 208 | in: "path", |
| 209 | required: true, |
| 210 | schema: { type: "integer" }, |
| 211 | }, |
| 212 | ], |
| 213 | responses: { |
| 214 | "200": { |
| 215 | description: "ok", |
| 216 | content: { "application/json": { schema: Pet } }, |
| 217 | }, |
| 218 | "404": { description: "not found" }, |
| 219 | }, |
| 220 | }, |
| 221 | }, |
| 222 | }, |
| 223 | }; |
| 224 | |
| 225 | // Seed the in-memory store so the GET-driven smoke can verify list + |
| 226 | // path-param round-trips. Body-bearing POST/PUT is gated by the |
| 227 | // executor's approval flow and is covered by separate non-compiled tests. |
| 228 | const pets: Array<{ id: number; name: string; tag?: string }> = [ |
| 229 | { id: 1, name: "Fido", tag: "dog" }, |
| 230 | { id: 2, name: "Whiskers", tag: "cat" }, |
| 231 | ]; |