doc endpoint returns 500 with no errors in logs

I am running on Lambda. I have used ts-to-zod to convert some of my types to zod definitions. I have the following code:
const app = new OpenAPIHono<{ Bindings: Bindings }>();
app.use("*", cors());
app.get("/v2/hello", async (c) => {
return c.json({ message: "Hello, World!" });
});
...
app.openapi(
createRoute({
method: apiConfig.method,
path: `/v2${apiConfig.path}`,
responses: schema ? {
200: {
description: "Successful response",
content: {
"application/json": {
schema: schema
},
},
},
} : null,
}),
async (c) => {
console.log("Hello Hono!");
const resp = await config.handlerFunc(c.env.event, c.env.lambdaContext);
console.log("resp", resp);
return c.json(resp);
},
);
...
app.doc("/v2/doc", { info: { title: "My API", version: "v2" }, openapi: "3.1.0"});
app.get('/v2/swagger', swaggerUI({url: '/v2/doc'}));
const app = new OpenAPIHono<{ Bindings: Bindings }>();
app.use("*", cors());
app.get("/v2/hello", async (c) => {
return c.json({ message: "Hello, World!" });
});
...
app.openapi(
createRoute({
method: apiConfig.method,
path: `/v2${apiConfig.path}`,
responses: schema ? {
200: {
description: "Successful response",
content: {
"application/json": {
schema: schema
},
},
},
} : null,
}),
async (c) => {
console.log("Hello Hono!");
const resp = await config.handlerFunc(c.env.event, c.env.lambdaContext);
console.log("resp", resp);
return c.json(resp);
},
);
...
app.doc("/v2/doc", { info: { title: "My API", version: "v2" }, openapi: "3.1.0"});
app.get('/v2/swagger', swaggerUI({url: '/v2/doc'}));
The api endpoints are working as expected, but the swaggerUI doesn't work because the /v2/doc endpoint returns a 500. There are no errors in the logs. Any ideas? I am looking to figure out how I can serve the swagger.json file itself.
1 Reply
Probotect0r
Probotect0rOP3mo ago
Ah nvm, I think I might have figured out what's wrong. My schemas are not populated correctly Okay, now I am populating the schemas correctly, but still getting a 500 back Okay figured it out, it's working now. Some of the routes didn't have a proper schema.
Want results from more Discord servers?
Add your server