Doc pages breaking with Zod's bigint type
juliangehring opened this issue · 0 comments
juliangehring commented
Using the bigint
type of Zod seems to be breaking the /docs
and redocs
pages. A simple example based on the user guide, modified to use Zod's bigint
instead of the normal Int
:
import { OpenAPIRouter, OpenAPIRoute, Path, Int } from '@cloudflare/itty-router-openapi';
import { z } from 'zod'
export class ToDoFetch extends OpenAPIRoute {
static schema = {
parameters: {
todoId: Path(z.coerce.bigint().nonnegative(), { // <-- using `bigint` here
description: 'ToDo ID',
}),
},
}
async handle(
request: Request,
env: any,
context: any,
data: any
) {
const { todoId } = data.params
return new Response(todoId);
}
}
const router = OpenAPIRouter()
router.get('/todos/:todoId', ToDoFetch)
export default {
fetch: router.handle,
}
The docs
page then throws: "Failed to load API definition. Fetch error response status is 500 /openapi.json"
The redocs
page is stuck in "Loading..."
When using the standard Int
type instead, the doc pages load normally.