### Install @hono/mcp using pnpm Source: https://github.com/rhinobase/docs/blob/main/content/docs/hono-mcp/index.mdx Installs the @hono/mcp package using the pnpm package manager. ```bash pnpm add @hono/mcp ``` -------------------------------- ### Install @hono/mcp using bun Source: https://github.com/rhinobase/docs/blob/main/content/docs/hono-mcp/index.mdx Installs the @hono/mcp package using the bun package manager. ```bash bun add @hono/mcp ``` -------------------------------- ### Install @hono/mcp using yarn Source: https://github.com/rhinobase/docs/blob/main/content/docs/hono-mcp/index.mdx Installs the @hono/mcp package using the yarn package manager. ```bash yarn install @hono/mcp ``` -------------------------------- ### Install @hono/mcp using npm Source: https://github.com/rhinobase/docs/blob/main/content/docs/hono-mcp/index.mdx Installs the @hono/mcp package using the npm package manager. ```bash npm install @hono/mcp ``` -------------------------------- ### Install hono-openapi and @hono/standard-validator Source: https://github.com/rhinobase/docs/blob/main/content/docs/openapi/index.mdx Installs the hono-openapi package along with the @hono/standard-validator dependency, which is often required for integrating validation schemas with Honojs applications. ```bash hono-openapi @hono/standard-validator ``` -------------------------------- ### Install hono-openapi and standard-validator Source: https://github.com/rhinobase/docs/blob/main/content/docs/openapi/migration.mdx Installs the necessary packages for migrating to hono-openapi, including the main library and the standard validator. ```bash hono-openapi @hono/standard-validator ``` -------------------------------- ### Install js-yaml Source: https://github.com/rhinobase/docs/blob/main/content/docs/openapi/persisting.mdx Installs the `js-yaml` package, which is required to convert the OpenAPI specification object into YAML format. ```bash js-yaml ``` -------------------------------- ### Generate OpenAPI Spec with Hono OpenAPI Source: https://github.com/rhinobase/docs/blob/main/content/docs/openapi/effect.mdx Shows how to serve the OpenAPI specification using `openAPIRouteHandler` from `hono-openapi`. This example serves the spec at `/openapi.json`. ```typescript import { Hono } from "hono"; import { openAPIRouteHandler } from "hono-openapi"; // Other hono apps import routes from "./routes"; const main = new Hono(); main.get( "/openapi.json", openAPIRouteHandler(routes, { documentation: { info: { title: "Hono", version: "1.0.0", description: "API for greeting users", }, }, }), ); ``` -------------------------------- ### Serve OpenAPI Spec with Hono OpenAPI Source: https://github.com/rhinobase/docs/blob/main/content/docs/openapi/valibot.mdx Provides an example of using `openAPIRouteHandler` from `hono-openapi` to serve the generated OpenAPI specification for Hono applications. ```typescript import { Hono } from "hono"; import { openAPIRouteHandler } from "hono-openapi"; // Other hono apps import routes from "./routes"; const main = new Hono(); main.get( "/openapi.json", openAPIRouteHandler(routes, { documentation: { info: { title: "Hono", version: "1.0.0", description: "API for greeting users", }, }, }), ); ``` -------------------------------- ### Serve MCP Server with Hono Source: https://github.com/rhinobase/docs/blob/main/content/docs/hono-mcp/index.mdx Creates a Hono application that serves an MCP server at the '/mcp' endpoint using StreamableHTTPTransport. This example demonstrates the integration of McpServer with Hono's streaming capabilities for environments like Cloudflare Workers or Deno. ```typescript import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js' import { StreamableHTTPTransport } from '@hono/mcp' import { Hono } from 'hono' const app = new Hono() // Your MCP server implementation const mcpServer = new McpServer({ name: 'my-mcp-server', version: '1.0.0', }) app.all('/mcp', async (c) => { const transport = new StreamableHTTPTransport() await mcpServer.connect(transport) return transport.handleRequest(c) }) export default app ``` -------------------------------- ### Generate OpenAPI Spec with Hono OpenAPI Source: https://github.com/rhinobase/docs/blob/main/content/docs/openapi/migration.mdx Illustrates how to generate an OpenAPI specification file using the `openAPIRouteHandler` from `hono-openapi`. ```typescript import { Hono } from "hono"; import { openAPIRouteHandler } from "hono-openapi"; // Other hono apps import routes from "./routes"; const main = new Hono(); main.get( "/openapi.json", openAPIRouteHandler(routes, { documentation: { info: { title: "Hono", version: "1.0.0", description: "API for greeting users", }, }, }), ); ``` -------------------------------- ### Update Zod Import Source: https://github.com/rhinobase/docs/blob/main/content/docs/openapi/migration.mdx Demonstrates the change in importing the Zod library, moving from `@hono/zod-openapi` to the standalone `zod` package. ```typescript - import { z } from "@hono/zod-openapi"; + import { z } from "zod"; ``` -------------------------------- ### Integrate Hono OpenAPI with Effect Schemas Source: https://github.com/rhinobase/docs/blob/main/content/docs/openapi/effect.mdx Shows how to integrate Hono OpenAPI by importing `effectValidator`, `resolver`, and `describeRoute`. This example demonstrates using `resolver` for response body schemas. ```typescript import { Hono } from "hono"; import { validate as effectValidator, resolver, describeRoute, } from "hono-openapi"; const app = new Hono(); app.get( "/", describeRoute({ responses: { 200: { description: "Successful response", content: { "application/json": { schema: resolver(responseSchema), }, }, }, }, }), effectValidator("query", querySchema), (c) => { const query = c.req.valid("query"); return c.text(`Hello ${query?.name ?? "Hono"}!`); }, ); ``` -------------------------------- ### Refactor Route Definition with Hono OpenAPI Source: https://github.com/rhinobase/docs/blob/main/content/docs/openapi/migration.mdx Shows how to redefine a route using `hono-openapi`'s `describeRoute` and `validator` middleware, replacing the older `createRoute` function. ```typescript import { Hono } from "hono"; import { describeRoute, validator, resolver } from "hono-openapi"; const app = new Hono(); app.get( '/users/{id}', describeRoute({ responses: { 200: { content: { 'application/json': { schema: resolver(UserSchema), }, }, }, }, }), validator('params', ParamsSchema), (c) => { // ... } ); ``` -------------------------------- ### Generate Docs with Swagger UI Source: https://github.com/rhinobase/docs/blob/main/content/docs/openapi/ui.mdx Integrates Swagger UI to generate API documentation from an OpenAPI specification. Requires the `@hono/swagger-ui` package and assumes the OpenAPI spec is available at `/openapi.json`. Navigating to `/docs` displays the documentation. ```ts import { swaggerUI } from '@hono/swagger-ui' app.get( '/docs', swaggerUI({ url: '/openapi.json', }) ) ``` -------------------------------- ### Create Stateless MCP Server with Hono Source: https://github.com/rhinobase/docs/blob/main/content/docs/hono-mcp/stateless.mdx This snippet demonstrates how to create a stateless MCP server using Hono and the `@hono/mcp` library. It initializes an MCP server and a `StreamableHTTPTransport`, establishes a connection, and then uses the transport to handle all incoming requests to the `/mcp` endpoint. ```ts import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { StreamableHTTPTransport } from "@hono/mcp"; import { Hono } from "hono"; const app = new Hono(); const mcpServer = new McpServer({ name: "my-mcp-server", version: "1.0.0", }); const transport = new StreamableHTTPTransport(); let isConnected = false; const connectedToServer = mcpServer.connect(transport).then(() => { isConnected = true; }); app.all("/mcp", async (c) => { if (!isConnected) await connectedToServer; return transport.handleRequest(c); }); export default app; ``` -------------------------------- ### Generate Docs with Scalar Source: https://github.com/rhinobase/docs/blob/main/content/docs/openapi/ui.mdx Integrates Scalar to generate interactive API documentation from an OpenAPI specification. Requires the `@scalar/hono-api-reference` package and assumes the OpenAPI spec is available at `/openapi.json`. Navigating to `/docs` displays the documentation. ```ts import { Scalar } from "@scalar/hono-api-reference"; app.get( "/docs", Scalar({ theme: "saturn", url: "/openapi.json", }) ); ``` -------------------------------- ### Create Stateful MCP Server in Hono Source: https://github.com/rhinobase/docs/blob/main/content/docs/hono-mcp/stateful.mdx Demonstrates setting up a Hono application to create a stateful MCP server. It uses middleware to set user context and configures `StreamableHTTPTransport` with a `sessionIdGenerator` to route requests based on user ID, ensuring state is maintained per user. ```typescript import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { StreamableHTTPTransport } from "@hono/mcp"; import { Hono } from "hono"; type HonoEnv = { Variables: { user: { id: string; }; }; }; const app = new Hono().use(async (c, next) => { // Simulate user context c.set("user", { id: "random-user-id" }); await next(); }); function createMCPServer(id: string) { const mcpServer = new McpServer({ name: "my-mcp-server", version: "1.0.0", }); // Here you can add any stateful logic, such as storing user-specific data return mcpServer; } app.all("/mcp", async (c) => { const user = c.get("user"); const transport = new StreamableHTTPTransport({ sessionIdGenerator: () => user.id, }); const mcpServer = createMCPServer(); mcpServer.connect(transport); return transport.handleRequest(c); }); export default app; ``` -------------------------------- ### Integrate Hono OpenAPI with Valibot Schemas Source: https://github.com/rhinobase/docs/blob/main/content/docs/openapi/valibot.mdx Shows how to integrate Hono OpenAPI by importing validation middleware and schema resolvers from `hono-openapi` and using Valibot schemas to describe routes and responses. ```typescript import { Hono } from "hono"; import { validate as vValidator, resolver, describeRoute, } from "hono-openapi"; const app = new Hono(); app.get( "/", describeRoute({ responses: { 200: { description: "Successful response", content: { "application/json": { schema: resolver(responseSchema), }, }, }, }, }), vValidator("query", querySchema), (c) => { const query = c.req.valid("query"); return c.text(`Hello ${query?.name ?? "Hono"}!`); }, ); ``` -------------------------------- ### Serve OpenAPI Spec with Hono Source: https://github.com/rhinobase/docs/blob/main/content/docs/openapi/zod.mdx This snippet demonstrates how to use `openAPIRouteHandler` from `hono-openapi` to automatically generate and serve the OpenAPI specification for a Hono application at `/openapi.json`. It includes basic documentation information. ```typescript import { Hono } from "hono"; import { openAPIRouteHandler } from "hono-openapi"; // Other hono apps import routes from "./routes"; const main = new Hono(); main.get( "/openapi.json", openAPIRouteHandler(routes, { documentation: { info: { title: "Hono", version: "1.0.0", description: "API for greeting users", }, }, }), ); ``` -------------------------------- ### Integrate Hono OpenAPI with Zod Validators Source: https://github.com/rhinobase/docs/blob/main/content/docs/openapi/zod.mdx Shows how to integrate Hono OpenAPI by importing `zValidator`, `resolver`, and `describeRoute` from `hono-openapi` and using them to document routes with Zod schemas. ```typescript import { Hono } from "hono"; import { validate as zValidator, resolver, describeRoute, } from "hono-openapi"; const app = new Hono(); app.get( "/", describeRoute({ responses: { 200: { description: "Successful response", content: { "application/json": { schema: resolver(responseSchema), }, }, }, }, }), zValidator("query", querySchema), (c) => { const query = c.req.valid("query"); return c.text(`Hello ${query?.name ?? "Hono"}!`); }, ); ``` -------------------------------- ### Serve OpenAPI Spec with Hono Source: https://github.com/rhinobase/docs/blob/main/content/docs/openapi/arktype.mdx This snippet demonstrates how to use `openAPIRouteHandler` from `hono-openapi` to automatically generate and serve the OpenAPI specification for a Hono application at `/openapi.json`. It includes basic documentation information. ```typescript import { Hono } from "hono"; import { openAPIRouteHandler } from "hono-openapi"; // Other hono apps import routes from "./routes"; const main = new Hono(); main.get( "/openapi.json", openAPIRouteHandler(routes, { documentation: { info: { title: "Hono", version: "1.0.0", description: "API for greeting users", }, }, }), ); ``` -------------------------------- ### Basic Hono Route with Valibot Validation Source: https://github.com/rhinobase/docs/blob/main/content/docs/openapi/valibot.mdx Demonstrates a basic Hono route that uses Valibot for query parameter validation via the `vValidator` middleware. ```typescript import { Hono } from "hono"; import { vValidator } from "@hono/valibot-validator"; const app = new Hono(); app.get("/", vValidator("query", querySchema), (c) => { const query = c.req.valid("query"); return c.text(`Hello ${query?.name ?? "Hono"}!`); }); ``` -------------------------------- ### Pass Zod Schema Reference (v3) Source: https://github.com/rhinobase/docs/blob/main/content/docs/openapi/zod.mdx Shows how to pass a schema reference for Zod v3 using the `zod-openapi` library and the `.openapi()` method with a `ref` property. ```typescript import "zod-openapi/extend"; const schema = z .object({ myString: z.string(), myUnion: z.union([z.number(), z.boolean()]) }) .describe("My neat object schema").openapi({ ref: "MyNeatObjectSchema", }); ``` -------------------------------- ### Pass Zod Schema Reference (v4) Source: https://github.com/rhinobase/docs/blob/main/content/docs/openapi/zod.mdx Demonstrates how to pass a schema reference for Zod v4 using the `.meta()` method with a `ref` property. ```typescript const schema = z .object({ myString: z.string(), myUnion: z.union([z.number(), z.boolean()]) }) .describe("My neat object schema").meta({ ref: "MyNeatObjectSchema", }); ``` -------------------------------- ### Add Typesense for Response Body with Valibot Source: https://github.com/rhinobase/docs/blob/main/content/docs/openapi/valibot.mdx Demonstrates how to use `describeResponse` with Valibot schemas to automatically provide typesense for different response scenarios (success and error). ```typescript const successResponseSchema = v.object({ message: v.string(), }); const errorResponseSchema = v.object({ error: v.string(), }); app.get( "/", describeResponse( (c) => { return c.json({ message: "Hello Hono!" }, 200); }, { 200: { description: "Success", content: { "application/json": { vSchema: successResponseSchema, }, }, }, 400: { description: "Error", content: { "application/json": { vSchema: errorResponseSchema, }, }, }, }, ), ); ``` -------------------------------- ### Add Typesense for Response Body with Hono OpenAPI Source: https://github.com/rhinobase/docs/blob/main/content/docs/openapi/zod.mdx Illustrates how to add typesense for the response body using `describeResponse` with defined success and error schemas. ```typescript const successResponseSchema = z.object({ message: z.string(), }); const errorResponseSchema = z.object({ error: z.string(), }); app.get( "/", describeResponse( (c) => { return c.json({ message: "Hello Hono!" }, 200); }, { 200: { description: "Success", content: { "application/json": { vSchema: successResponseSchema, }, }, }, 400: { description: "Error", content: { "application/json": { vSchema: errorResponseSchema, }, }, }, }, ), ); ``` -------------------------------- ### Update Router with Effect Validator Source: https://github.com/rhinobase/docs/blob/main/content/docs/openapi/effect.mdx Demonstrates updating a Hono router to use Effect with Hono for request validation. It shows how to apply the `effectValidator` middleware. ```typescript import { Hono } from "hono"; import { effectValidator } from "@hono/effect-validator"; const app = new Hono(); app.get("/", effectValidator("query", querySchema), (c) => { const query = c.req.valid("query"); return c.text(`Hello ${query?.name ?? "Hono"}!`); }); ``` -------------------------------- ### Pass Schema Reference with Valibot Metadata Source: https://github.com/rhinobase/docs/blob/main/content/docs/openapi/valibot.mdx Illustrates how to use Valibot's `metadata` function to pass a reference to a schema, useful for complex or reusable schema definitions. ```typescript const schema = v.pipe( v.object({ myString: v.string(), myUnion: v.union([v.number(), v.boolean()]), }), v.description("My neat object schema"), v.metadata({ ref: "MyNeatObjectSchema", }), ); ``` -------------------------------- ### Add Typesense for Response Body with Hono Source: https://github.com/rhinobase/docs/blob/main/content/docs/openapi/arktype.mdx Demonstrates using `describeResponse` from `hono-openapi` to automatically provide typesense for response bodies by passing Arktype schemas. ```typescript const successResponseSchema = type({ message: "string", }); const errorResponseSchema = type({ error: "string", }); app.get( "/", describeResponse( (c) => { return c.json({ message: "Hello Hono!" }, 200); }, { 200: { description: "Success", content: { "application/json": { vSchema: successResponseSchema, }, }, }, 400: { description: "Error", content: { "application/json": { vSchema: errorResponseSchema, }, }, }, }, ), ); ``` -------------------------------- ### Configure Arktype for Schema References Source: https://github.com/rhinobase/docs/blob/main/content/docs/openapi/arktype.mdx Illustrates how to configure Arktype globally to allow for schema references by defining metadata properties like `ref` in the `ArkEnv` interface. ```typescript // add this anywhere in your project declare global { interface ArkEnv { meta(): { // meta properties should always be optional ref?: string; }; } } const schema = type({ myString: "string", myUnion: "number | boolean", }) .describe("My neat object schema") .configure({ ref: "MyNeatObjectSchema", }); ``` -------------------------------- ### Save OpenAPI Spec to YAML Source: https://github.com/rhinobase/docs/blob/main/content/docs/openapi/persisting.mdx Generates the OpenAPI specification using `hono-openapi` and saves it to a YAML file using the `js-yaml` package. This allows for serving the spec in YAML format. ```typescript import fs from 'node:fs'; import { generateSpecs } from 'hono-openapi'; import yaml from 'js-yaml'; // Your Hono app import mainApp from "./app"; async function main() { const specs = await generateSpecs(mainApp, { // Documentation metadata }); fs.writeFileSync('./path/to/openapi.yaml', yaml.dump(specs)); } main() ``` -------------------------------- ### Integrate Hono OpenAPI with Arktype Schemas Source: https://github.com/rhinobase/docs/blob/main/content/docs/openapi/arktype.mdx Shows how to integrate Hono OpenAPI by importing validation middleware and route description helpers from `hono-openapi`, using `resolver` for Arktype schemas in OpenAPI specifications. ```typescript import { Hono } from "hono"; import { validate as arktypeValidator, resolver, describeRoute, } from "hono-openapi"; const app = new Hono(); app.get( "/", describeRoute({ responses: { 200: { description: "Successful response", content: { "application/json": { schema: resolver(responseSchema), }, }, }, }, }), arktypeValidator("query", querySchema), (c) => { const query = c.req.valid("query"); return c.text(`Hello ${query?.name ?? "Hono"}!`); }, ); ``` -------------------------------- ### Save OpenAPI Spec to JSON Source: https://github.com/rhinobase/docs/blob/main/content/docs/openapi/persisting.mdx Generates the OpenAPI specification using `hono-openapi` and saves it to a JSON file. This is useful for caching or serving the spec from a file, especially in serverless environments. ```typescript import fs from 'node:fs'; import { generateSpecs } from 'hono-openapi'; // Your Hono app import mainApp from "./app"; async function main() { const specs = await generateSpecs(mainApp, { // Documentation metadata }); fs.writeFileSync('./path/to/openapi.json', JSON.stringify(specs, null, 2)); } main() ``` -------------------------------- ### Update Router with Zod Validation (Hono) Source: https://github.com/rhinobase/docs/blob/main/content/docs/openapi/zod.mdx Demonstrates how to use Zod with Hono for request validation using the `zValidator` middleware from `@hono/zod-validator`. ```typescript import { Hono } from "hono"; import { zValidator } from "@hono/zod-validator"; const app = new Hono(); app.get("/", zValidator("query", querySchema), (c) => { const query = c.req.valid("query"); return c.text(`Hello ${query?.name ?? "Hono"}!`); }); ``` -------------------------------- ### Define TypeBox Schemas for Query and Response Source: https://github.com/rhinobase/docs/blob/main/content/docs/openapi/typebox.mdx This snippet demonstrates defining TypeBox schemas for validating incoming query parameters and outgoing response bodies. It uses Type.Partial and Type.Object for query parameters and Type.String for the response. ```typescript import { Type } from '@sinclair/typebox' // Validation for query parameters, eg - `/hello?name=John` const querySchema = Type.Partial( Type.Object({ name: Type.String(), }), ); // Validation for response body, eg - `"Hello, John!"` const responseSchema = Type.String(); ``` -------------------------------- ### Add Typesense for Response Body with Effect Source: https://github.com/rhinobase/docs/blob/main/content/docs/openapi/effect.mdx Illustrates how to add typesense for response bodies using `describeResponse` and Effect schemas. This allows defining different response schemas for different status codes. ```typescript const successResponseSchema = Schema.standardSchemaV1( Schema.Struct({ message: Schema.optional(Schema.String), }), ); const errorResponseSchema = Schema.standardSchemaV1( Schema.Struct({ error: Schema.String, }), ); app.get( "/", describeResponse( (c) => { return c.json({ message: "Hello Hono!" }, 200); }, { 200: { description: "Success", content: { "application/json": { vSchema: successResponseSchema, }, }, }, 400: { description: "Error", content: { "application/json": { vSchema: errorResponseSchema, }, }, }, }, ), ); ``` -------------------------------- ### Add JWT Bearer Security Definition to OpenAPI Source: https://github.com/rhinobase/docs/blob/main/content/docs/openapi/security.mdx Demonstrates how to configure JWT Bearer authentication as a security scheme in an OpenAPI specification using `openAPIRouteHandler`. This includes defining the `securitySchemes` and applying the `bearerAuth` to the specification. ```typescript main.get( "/openapi.json", openAPIRouteHandler(app, { documentation: { components: { securitySchemes: { bearerAuth: { type: "http", scheme: "bearer", bearerFormat: "JWT", }, }, }, security: [ { bearerAuth: [], }, ], servers: [ { url: "http://localhost:3000", description: "Local server", }, ], }, }) ); ``` -------------------------------- ### Define Validation Schemas with Effect Source: https://github.com/rhinobase/docs/blob/main/content/docs/openapi/effect.mdx Defines validation schemas for query parameters and response bodies using Effect's Schema API. These schemas are used for generating OpenAPI specifications. ```typescript import { Schema } from "effect"; // Validation for query parameters, eg - `/hello?name=John` const querySchema = Schema.standardSchemaV1( Schema.Struct({ message: Schema.optional(Schema.String), }), ); // Validation for response body, eg - `"Hello, John!"` const responseSchema = Schema.standardSchemaV1(Schema.String); ``` -------------------------------- ### Define Zod Schemas for Validation Source: https://github.com/rhinobase/docs/blob/main/content/docs/openapi/zod.mdx Defines Zod schemas for query parameters and response bodies, which are used to generate OpenAPI specifications for incoming requests and outgoing responses. ```typescript import z from "zod"; // Or // import z from "zod/v4"; // If you are using Zod v4 // Validation for query parameters, eg - `/hello?name=John` const querySchema = z.object({ name: z.string().optional(), }); // Validation for response body, eg - `"Hello, John!"` const responseSchema = z.string(); ``` -------------------------------- ### Define Valibot Schemas for Hono Source: https://github.com/rhinobase/docs/blob/main/content/docs/openapi/valibot.mdx Defines Valibot schemas for validating query parameters and response bodies in Hono applications. These schemas are used to generate OpenAPI specifications. ```typescript import * as v from "valibot"; // Validation for query parameters, eg - `/hello?name=John` const querySchema = v.object({ name: v.optional(v.string()), }); // Validation for response body, eg - `"Hello, John!"` const responseSchema = v.string(); ``` -------------------------------- ### Update Hono Router with Arktype Validator Source: https://github.com/rhinobase/docs/blob/main/content/docs/openapi/arktype.mdx Demonstrates updating the Hono router to use `arktypeValidator` from `@hono/arktype-validator` for validating incoming requests based on defined Arktype schemas. ```typescript import { Hono } from "hono"; import { arktypeValidator } from "@hono/arktype-validator"; const app = new Hono(); app.get("/", arktypeValidator("query", querySchema), (c) => { const query = c.req.valid("query"); return c.text(`Hello ${query?.name ?? "Hono"}!`); }); ``` -------------------------------- ### Define Arktype Schemas for Hono Source: https://github.com/rhinobase/docs/blob/main/content/docs/openapi/arktype.mdx Defines validation schemas for query parameters and response bodies using Arktype, which are then used to generate OpenAPI specifications. ```typescript import { type } from "arktype"; // Validation for query parameters, eg - `/hello?name=John` const querySchema = type({ "name?": "string", }); // Validation for response body, eg - `"Hello, John!" const responseSchema = type("string"); ``` -------------------------------- ### Hide Route Conditionally with Function Source: https://github.com/rhinobase/docs/blob/main/content/docs/openapi/helpers.mdx Conditionally hide a Hono route from the OpenAPI specification by providing a function to the `hide` property. This function receives the context, path, and method, allowing for dynamic hiding logic. ```typescript app.get( "/", describeRoute({ hide: ({ c, path, method }) => c.env.NODE_ENV === "production", }), ); ``` -------------------------------- ### Hide Route Conditionally with Environment Variable Source: https://github.com/rhinobase/docs/blob/main/content/docs/openapi/helpers.mdx Conditionally hide a Hono route from the OpenAPI specification based on the NODE_ENV environment variable. This is useful for hiding routes in production. ```typescript app.get( "/", describeRoute({ // ... hide: process.env.NODE_ENV === "production", }), (c) => { return c.text("Private Route"); } ); ``` -------------------------------- ### Set OperationId Manually Source: https://github.com/rhinobase/docs/blob/main/content/docs/openapi/helpers.mdx Manually set the operationId for a Hono route by passing a string to the `operationId` property in `describeRoute`. This is useful for custom OpenAPI generation. ```typescript app.get( "/", describeRoute({ operationId: "getHello", }), ); ``` -------------------------------- ### Set OperationId Dynamically with Function Source: https://github.com/rhinobase/docs/blob/main/content/docs/openapi/helpers.mdx Dynamically set the operationId for a Hono route by providing a function to the `operationId` property. This function receives the route object and can generate the operationId based on method and path. ```typescript app.get( "/", describeRoute({ operationId: (route) => `${route.method}-${route.path}`, }), ); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.