Skip to content

responsibleapi/responsible

Repository files navigation

ResponsibleAPI

TypeScript tooling for defining OpenAPI 3.1 contracts and validating Hono handlers against them.

Packages

Define An API

bun add @responsibleapi/ts
import { GET, object, responsibleAPI, resp, string } from "@responsibleapi/ts"

export const api = responsibleAPI({
  partialDoc: {
    openapi: "3.1.0",
    info: {
      title: "Example API",
      version: "1.0.0",
    },
  },
  routes: {
    "/hello": GET({
      res: {
        200: resp({
          description: "OK",
          body: object({
            message: string(),
          }),
        }),
      },
    }),
  },
})

Use With Hono

bun add @responsibleapi/hono
import { openApiRouter } from "@responsibleapi/hono"
import { Hono } from "hono"
import type { oas31 } from "openapi3-ts"

new Hono().route(
  "",
  openApiRouter({
    handlers,
    securityHandlers,
    doc: api as oas31.OpenAPIObject,
  }),
)

Development

task check

About

A small language that compiles to OpenAPI

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors