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

Middleware breaks OpenAPI YAML #556

Closed
arjunyel opened this issue Jun 3, 2024 · 0 comments · Fixed by #557
Closed

Middleware breaks OpenAPI YAML #556

arjunyel opened this issue Jun 3, 2024 · 0 comments · Fixed by #557

Comments

@arjunyel
Copy link
Contributor

arjunyel commented Jun 3, 2024

Works without the middleware field: "Error: Tag not resolved for AsyncFunction value"

import { bearerAuth } from 'hono/bearer-auth'
import { stringify } from "yaml"

describe("Generate YAML", () => {
  it("Should generate YAML with Middleware", async () => {
    const app = new OpenAPIHono()
    app.openapi(
      createRoute({
        method: 'get',
        path: '/books',
        middleware: [bearerAuth({
          verifyToken: (_, __) => {
            return true;
          },
        })],
        responses: {
          200: {
            description: 'Books',
            content: {
              'application/json': {
                schema: z.array(
                  z.object({
                    title: z.string(),
                  })
                ),
              },
            },
          },
        },
      }),
      (c) => c.json([{ title: 'foo' }])
    )
    const doc = app.getOpenAPI31Document({
      openapi: '3.1.0',
      info: {
        title: 'My API',
        version: '1.0.0',
      }
    });
    expect(() => stringify(doc)).to.not.throw();
  })
});
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 a pull request may close this issue.

1 participant