| 22 | const unique = (prefix: string) => `${prefix}_${randomBytes(4).toString("hex")}`; |
| 23 | |
| 24 | const pingSpec = (baseUrl: string): string => |
| 25 | JSON.stringify({ |
| 26 | openapi: "3.0.3", |
| 27 | info: { title: "Local Toolkit Ping API", version: "1.0.0" }, |
| 28 | servers: [{ url: baseUrl }], |
| 29 | paths: { |
| 30 | "/ping/{id}": { |
| 31 | get: { |
| 32 | operationId: "getPing", |
| 33 | summary: "Return a ping payload", |
| 34 | security: [{ apiKey: [] }], |
| 35 | parameters: [ |
| 36 | { |
| 37 | name: "id", |
| 38 | in: "path", |
| 39 | required: true, |
| 40 | schema: { type: "string" }, |
| 41 | }, |
| 42 | ], |
| 43 | responses: { |
| 44 | "200": { |
| 45 | description: "A ping payload", |
| 46 | content: { |
| 47 | "application/json": { |
| 48 | schema: { |
| 49 | type: "object", |
| 50 | properties: { |
| 51 | id: { type: "string" }, |
| 52 | path: { type: "string" }, |
| 53 | }, |
| 54 | }, |
| 55 | }, |
| 56 | }, |
| 57 | }, |
| 58 | }, |
| 59 | }, |
| 60 | }, |
| 61 | }, |
| 62 | components: { |
| 63 | securitySchemes: { |
| 64 | apiKey: { type: "apiKey", in: "header", name: "x-e2e-token" }, |
| 65 | }, |
| 66 | }, |
| 67 | }); |
| 68 | |
| 69 | const closeServer = (server: Server): Promise<void> => |
| 70 | new Promise((resolve) => { |