Getting Started with OpenAPI
Basic Setup
Section titled “Basic Setup”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 documentationapp.__openapi.setTitle('My API Documentation');
// Set a description - supports Markdown formattingapp.__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
Accessing OpenAPI
Section titled “Accessing OpenAPI”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 endpointapp.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.
Next Steps
Section titled “Next Steps”- Learn about Server Configuration
- Set up Security Schemas
- Start Documenting Your Endpoints