npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

hono-openapi-better-response

v1.0.0

Published

`hono-openapi-better-response` is a TypeScript utility library for building OpenAPI response objects for `hono-openapi`.

Readme

hono-openapi-better-response

hono-openapi-better-response is a TypeScript utility library for building OpenAPI response objects for hono-openapi.

Current version: 1.0.0.

It provides:

  • A generic OpenApiResponse function for any status code.
  • A generic OpenApiResponses function to merge multiple response objects.
  • A large set of prebuilt helpers such as OpenApiOkResponse, OpenApiBadRequestResponse, and OpenApiInternalServerErrorResponse.
  • Standard Schema integration through hono-openapi's resolver(schema).

Installation

Install the package with your preferred package manager:

npm install hono-openapi-better-response
pnpm add hono-openapi-better-response
yarn add hono-openapi-better-response
bun add hono-openapi-better-response

hono-openapi-better-response expects these peer dependencies:

  • hono-openapi
  • openapi-types
  • typescript

Build (for contributors)

This project uses Bun + tsdown.

bun install
bun run build

Usage

1) Generic function

import { OpenApiResponse } from 'hono-openapi-better-response'

const responses = OpenApiResponse(200, 'Success')
// => { 200: { description: 'Success' } }

2) Status helper

import { OpenApiCreatedResponse } from 'hono-openapi-better-response'

const responses = OpenApiCreatedResponse('Resource created')
// => { 201: { description: 'Resource created' } }

3) With schema (hono-openapi resolver)

If a Standard Schema-compatible object is provided, the library adds:

  • content['application/json'].schema = resolver(schema)
import { OpenApiOkResponse } from 'hono-openapi-better-response'
import { z } from 'zod'

const userSchema = z.object({
  id: z.string(),
  name: z.string(),
  email: z.string().email(),
})

const responses = OpenApiOkResponse('User fetched', userSchema)

4) Merge multiple responses

Use OpenApiResponses to combine multiple response objects into one:

import {
  OpenApiOkResponse,
  OpenApiBadRequestResponse,
  OpenApiResponses,
} from 'hono-openapi-better-response'

const responses = OpenApiResponses(
  OpenApiOkResponse('Success'),
  OpenApiBadRequestResponse('Invalid request'),
)

API

OpenApiResponse(code: number, description: string, schema?) => Record<string, OpenAPIV3_1.ResponseObject | OpenAPIV3_1.ReferenceObject>
OpenApiResponses(...responses: Array<Record<string, OpenAPIV3_1.ResponseObject | OpenAPIV3_1.ReferenceObject>>) => Record<string, OpenAPIV3_1.ResponseObject | OpenAPIV3_1.ReferenceObject>
  • code: HTTP status code.
  • description: OpenAPI response description.
  • schema (optional): a Standard Schema-compatible schema that can be consumed by hono-openapi resolver.
  • responses: one or more response objects to merge; later entries override earlier keys when status codes collide.

Exported Helper Families

The package exports helpers for many HTTP status codes:

  • 1xx: OpenApiContinueResponse, OpenApiSwitchingProtocolsResponse, ...
  • 2xx: OpenApiOkResponse, OpenApiCreatedResponse, OpenApiNoContentResponse, ...
  • 3xx: OpenApiMovedPermanentlyResponse, OpenApiTemporaryRedirectResponse, ...
  • 4xx: OpenApiBadRequestResponse, OpenApiUnauthorizedResponse, OpenApiNotFoundResponse, ...
  • 5xx: OpenApiInternalServerErrorResponse, OpenApiBadGatewayResponse, OpenApiServiceUnavailableResponse, ...

All helpers share the same signature:

(description: string, schema?) => Record<string, OpenAPIV3_1.ResponseObject | OpenAPIV3_1.ReferenceObject>

Type Notes

  • The library uses openapi-types types (OpenAPIV3_1).
  • It accepts Standard Schema-compatible inputs and delegates schema conversion to hono-openapi.
  • It is authored in TypeScript and ships both ESM and CJS builds.