@devidw/trpc-openapi
TypeScript icon, indicating that this package has built-in type declarations

12024.6.28 • Public • Published

trpc-openapi with model schema support

in your script where you generate your specs you can now pass a object of the schemas you want to be defined as components/schemas in the output doc

import { generateOpenApiDocument } from "trpc-openapi";
import { z } from "zod";

const SomeSchema = z.object({
  a: z.literal(69),
});

generateOpenApiDocument(appRouter, {
  // ...
  defs: {
    SomeSchema,
  },
});

which will be included in the response object definition like

{
  "$ref": "#/components/schemas/SomeSchema"
}

and in the actual schemas list like

{
  "components": {
    "schemas": {
      "SomeSchema": "..."
    }
  }
}

/@devidw/trpc-openapi/

    Package Sidebar

    Install

    npm i @devidw/trpc-openapi

    Weekly Downloads

    7

    Version

    12024.6.28

    License

    MIT

    Unpacked Size

    129 kB

    Total Files

    84

    Last publish

    Collaborators

    • devidw