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

incorrect work with type recursion #119

Open
ilyhalight opened this issue Apr 28, 2024 · 0 comments
Open

incorrect work with type recursion #119

ilyhalight opened this issue Apr 28, 2024 · 0 comments

Comments

@ilyhalight
Copy link

If we set the response type as an object containing recursion, an error occurs when opening the endpoint in swagger (and incorrect types are displayed in the example), while scalar stops working altogether.

Full code example:

import { Elysia, t } from "elysia";
import { swagger } from "@elysiajs/swagger";

const app = new Elysia()
  .use(
    swagger({
      provider: "swagger-ui", // scalar doesn't work bruh
      path: "/docs",
      documentation: {
        info: {
          title: "test",
          version: "1.0.0",
        },
        tags: [
          { name: "App", description: "General endpoints" },
          { name: "Users", description: "User endpoints" },
        ],
      },
    })
  )
  .get(
    "/test",
    () => {
      return {
        test: "321",
        part: {
          test: "32133",
        },
      };
    },
    {
      response: {
        200: t.Recursive((This) =>
          t.Object({
            test: t.String(),
            part: t.Optional(This),
          })
        ),
      },
    }
  )
  .listen({
    port: 3000,
    hostname: "0.0.0.0",
  });

console.log(
  `🦊 Elysia is running at ${app.server?.hostname}:${app.server?.port}`
);

изображение
изображение

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