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

Fix Unable to dereference schema with 'undefined' when using t.Ref #314

Merged
merged 2 commits into from
Nov 16, 2023

Conversation

dungps
Copy link
Contributor

@dungps dungps commented Nov 16, 2023

When I define a typebox object with $id at Elysia.model and I use t.Ref in hooks then it will throw the error Unable to dereference schema with $id 'undefined' when starting the server.

This PR will add model references to TypeCompiler.Compile to fix this issue.

Error example:

new Elysia()
    .model({
        user: t.Object(
            {
                id: t.Number()
            },
            {
                $id: "user"
            }
        )
    })
    .get(
        "/",
        () => ({
            success: true,
            data: {
                id: 1
            }
        }),
        {
            response: {
                200: t.Object({
                    success: t.Boolean(),
                    data: t.Ref("user")
                })
            }
        }
    )
    .listen(3000)

@SaltyAom
Copy link
Member

SaltyAom commented Nov 16, 2023

Error occurs from sensitive header case, will fix that on local.

Thanks for your contribution.

@SaltyAom SaltyAom merged commit 63bb87b into elysiajs:main Nov 16, 2023
1 check failed
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

Successfully merging this pull request may close these issues.

2 participants