cloudflare / cloudflare/chanfana
Doc pages breaking with Zod's bigint type
- Dominant language
- TypeScript
- Stars
- 766
- Forks
- 70
- Avg merge
- 25m
- Merged PRs (30d)
- 4
Description
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`:
```ts
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.
Contributor guide
Research direction
Reproduce the supplied TypeScript example with z.coerce.bigint() and inspect the /openapi.json response used by the /docs and /redocs pages. Compare it with the Int version; done means bigint schemas produce a valid API definition and both documentation pages load normally.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100