Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doc pages breaking with Zod's bigint type #107

Open
juliangehring opened this issue Dec 4, 2023 · 0 comments
Open

Doc pages breaking with Zod's bigint type #107

juliangehring opened this issue Dec 4, 2023 · 0 comments

Comments

@juliangehring
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant