| 242 | ); |
| 243 | |
| 244 | const openApiSpec = (request: Request) => { |
| 245 | const url = new URL(request.url); |
| 246 | const apiBaseUrl = `${url.origin}/openapi`; |
| 247 | const spec = OpenApi.fromApi( |
| 248 | (OpenApiEchoApi as HttpApi.AnyWithProps).annotateMerge( |
| 249 | OpenApi.annotations({ |
| 250 | servers: [{ url: apiBaseUrl }], |
| 251 | transform: (source) => ({ |
| 252 | ...source, |
| 253 | components: { |
| 254 | ...(typeof source.components === "object" && source.components !== null |
| 255 | ? source.components |
| 256 | : {}), |
| 257 | securitySchemes: { |
| 258 | oauth2: { |
| 259 | type: "oauth2", |
| 260 | flows: { |
| 261 | authorizationCode: { |
| 262 | authorizationUrl: `${url.origin}/authorize`, |
| 263 | tokenUrl: `${url.origin}/token`, |
| 264 | scopes: { read: "Read test resources" }, |
| 265 | }, |
| 266 | }, |
| 267 | }, |
| 268 | }, |
| 269 | }, |
| 270 | security: [{ oauth2: ["read"] }], |
| 271 | }), |
| 272 | }), |
| 273 | ), |
| 274 | ); |
| 275 | return json(spec); |
| 276 | }; |
| 277 | |
| 278 | const handleOpenApi = (request: Request) => { |
| 279 | const url = new URL(request.url); |