MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / openApiSpec

Function openApiSpec

packages/core/test-servers/src/worker.ts:244–276  ·  view source on GitHub ↗
(request: Request)

Source from the content-addressed store, hash-verified

242 );
243
244const 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
278const handleOpenApi = (request: Request) => {
279 const url = new URL(request.url);

Callers 1

handleOpenApiFunction · 0.85

Calls 1

jsonFunction · 0.70

Tested by

no test coverage detected