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

Nested route with HonoJS should have better documentations #162

Open
kice opened this issue Jul 11, 2024 · 0 comments
Open

Nested route with HonoJS should have better documentations #162

kice opened this issue Jul 11, 2024 · 0 comments

Comments

@kice
Copy link

kice commented Jul 11, 2024

I just get confused as a 🔥Hono user. My issue is in the comment in the code.

const api = new Hono();
const openapi = fromHono(api, {
    // only use "base" option if schema.servers do not append nested route, like "https://api.example.com"
    // and okay with /v1/ everywhere on the Swagger UI
    // base: "/v1",   
    
    // but here it is okay either use "/docs" or "docs",
    docs_url: "/docs",

    // must not use the default "/openapi.json" will not work
    openapi_url: 'openapi.json',
    schema: {
        servers: [
            {
                // this must be set and the append the nested route, or "Try it out" button will break
                url: 'https://api.example.com/v1',
            }
        ]
    }
});

// the final url for this endpoint will be "https://api.example.com/v1/api/tasks"
openapi.get("/api/tasks", TaskList);

const app = new Hono();
app.route('/v1', api);
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