Skip to content

Getting Started with OpenAPI

First, initialize your Yelix app and set up basic metadata:

import { YelixHono } from '@yelix/hono';
const app = new YelixHono();
// Set the API title - appears at the top of your documentation
app.__openapi.setTitle('My API Documentation');
// Set a description - supports Markdown formatting
app.__openapi.setDescription('Some Markdown description about your API');

What this does:

  • Creates a new Yelix application instance
  • Sets the title that will appear in your OpenAPI/Swagger UI
  • Adds a description that can include formatted Markdown text

After setting up basic configuration, you can access the OpenAPI specification:

import { YelixHono, openapi } from '@yelix/hono';
const app = new YelixHono();
app.__openapi.setTitle('My API');
app.__openapi.setDescription('My API Description');
// Expose OpenAPI JSON endpoint
app.get('/openapi.json', openapi({ hide: true }), (c) => {
return c.json(app.getOpenAPI());
});
Deno.serve(app.fetch);

Now you can access the OpenAPI specification at http://localhost:8000/openapi.json.