OpenAPI support for tRPC 🧩

Overview

tRPC-OpenAPI

trpc-openapi

OpenAPI support for tRPC 🧩

  • Easy REST endpoints for your tRPC procedures.
  • Perfect for incremental adoption.
  • OpenAPI version 3.0.3.

Usage

1. Install trpc-openapi.

# npm
npm install trpc-openapi
# yarn
yarn add trpc-openapi

2. Add OpenApiMeta to your tRPC router.

import * as trpc from '@trpc/server';
import { OpenApiMeta } from 'trpc-openapi';

export const appRouter = trpc.router<any, OpenApiMeta /* πŸ‘ˆ */>();

3. Enable openapi support for a procedure.

import * as trpc from '@trpc/server';
import { OpenApiMeta } from 'trpc-openapi';

export const appRouter = trpc.router<any, OpenApiMeta>().query('sayHello', {
  meta: { /* πŸ‘‰ */ openapi: { enabled: true, method: 'GET', path: '/say-hello' } },
  input: z.object({ name: z.string() }),
  output: z.object({ greeting: z.string() }),
  resolve: ({ input }) => {
    return { greeting: `Hello ${input.name}!` };
  },
});

4. Generate OpenAPI v3 document.

import { generateOpenApiDocument } from 'trpc-openapi';

import { appRouter } from '../appRouter';

/* πŸ‘‡ */
export const openApiDocument = generateOpenApiDocument(appRouter, {
  title: 'tRPC OpenAPI',
  version: '1.0.0',
  baseUrl: 'http://localhost:3000',
});

5. Add an trpc-openapi handler to your app.

We currently support adapters for Express, Next.js & node:http.

Fastify & Serverless soonβ„’, PRs are welcomed πŸ™Œ .

import http from 'http';
import { createOpenApiHttpHandler } from 'trpc-openapi';

import { appRouter } from '../appRouter';

const server = http.createServer(createOpenApiHttpHandler({ router: appRouter })); /* πŸ‘ˆ */

server.listen(3000);

6. Profit πŸ€‘

// client.ts
const res = await fetch('http://localhost:3000/say-hello?name=James', { method: 'GET' });
const body = await res.json(); /* { ok: true, data: { greeting: 'Hello James!' } } */

Requirements

Peer dependencies:

  • tRPC Server v9 (@trpc/server@^9.23.0) must be installed.
  • Zod v3 (zod@^3.14.4) must be installed.

For a procedure to support OpenAPI the following must be true:

  • Both input and output parsers are present AND use Zod validation.
  • Query input parsers extend ZodObject<{ [string]: ZodString }> or ZodVoid.
  • Mutation input parsers extend ZodObject<{ [string]: ZodAnyType }> or ZodVoid.
  • meta.openapi.enabled is set to true.
  • meta.openapi.method is GET, DELETE for query OR POST, PUT or PATCH for mutation.
  • meta.openapi.path is a string starting with /.
  • meta.openapi.path parameters exist in input parser as ZodString

Please note:

  • Data transformers are ignored.
  • Trailing slashes are ignored.
  • Routing is case-insensitive.

HTTP Requests

Query procedures accept input via URL query parameters.

Mutation procedures accept input via the request body with a application/json content type.

Path parameters

Both queries & mutations can accept a set of their inputs via URL path parameters. You can add a path parameter to any OpenAPI enabled procedure by using curly brackets around an input name as a path segment in the meta.openapi.path field.

Query

// Router
export const appRouter = trpc.router<Context, OpenApiMeta>().query('sayHello', {
  meta: { openapi: { enabled: true, method: 'GET', path: '/say-hello/{name}' /* πŸ‘ˆ */ } },
  input: z.object({ name: z.string() /* πŸ‘ˆ */, greeting: z.string() }),
  output: z.object({ greeting: z.string() }),
  resolve: ({ input }) => {
    return { greeting: `${input.greeting} ${input.name}!` };
  },
});

// Client
const res = await fetch('http://localhost:3000/say-hello/James?greeting=Hello' /* πŸ‘ˆ */, { method: 'GET' });
const body = await res.json(); /* { ok: true, data: { greeting: 'Hello James!' } } */

Mutation

// Router
export const appRouter = trpc.router<Context, OpenApiMeta>().mutation('sayHello', {
  meta: { openapi: { enabled: true, method: 'POST', path: '/say-hello/{name}' /* πŸ‘ˆ */ } },
  input: z.object({ name: z.string() /* πŸ‘ˆ */, greeting: z.string() }),
  output: z.object({ greeting: z.string() }),
  resolve: ({ input }) => {
    return { greeting: `${input.greeting} ${input.name}!` };
  },
});

// Client
const res = await fetch('http://localhost:3000/say-hello/James' /* πŸ‘ˆ */, {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ greeting: 'Hello' }),
});
const body = await res.json(); /* { ok: true, data: { greeting: 'Hello James!' } } */

HTTP Responses

Inspired by Slack Web API.

Status codes will be 200 by default for any successful requests. In the case of an error, the status code will be derived from the thrown TRPCError or fallback to 500.

You can modify the status code or headers for any response using the responseMeta function.

Please see error status codes here.

{
  "ok": true,
  "data": "This is good" /* tRPC procedure output */
}
{
  "ok": false,
  "error": {
    "message": "This is bad" /* Message from TRPCError */,
    "code": "BAD_REQUEST" /* Code from TRPCError */
  }
}

Authorization

To create protected endpoints, add protect: true to the meta.openapi object of each tRPC procedure. You can then authenticate each request with the createContext function using the Authorization header with the Bearer scheme.

Explore a complete example here.

Server

import * as trpc from '@trpc/server';
import { OpenApiMeta } from 'trpc-openapi';

type User = { id: string; name: string };

const users: User[] = [
  {
    id: 'usr_123',
    name: 'James',
  },
];

export type Context = { user: User | null };

export const createContext = async ({ req, res }): Promise<Context> => {
  let user: User | null = null;
  if (req.headers.authorization) {
    const userId = req.headers.authorization.split(' ')[1];
    user = users.find((_user) => _user.id === userId);
  }
  return { user };
};

export const appRouter = trpc.router<Context, OpenApiMeta>().query('sayHello', {
  meta: { openapi: { enabled: true, method: 'GET', path: '/say-hello', protect: true /* πŸ‘ˆ */ } },
  input: z.void(), // no input expected
  output: z.object({ greeting: z.string() }),
  resolve: ({ input, ctx }) => {
    if (!ctx.user) {
      throw new trpc.TRPCError({ message: 'User not found', code: 'UNAUTHORIZED' });
    }
    return { greeting: `Hello ${ctx.user.name}!` };
  },
});

Client

const res = await fetch('http://localhost:3000/say-hello', {
  method: 'GET',
  headers: { 'Authorization': 'Bearer usr_123' }, /* πŸ‘ˆ */
});
const body = await res.json(); /* { ok: true, data: { greeting: 'Hello James!' } } */

Examples

For advanced use-cases, please find examples in our complete test suite.

With Express

Please see full example here.

import { createExpressMiddleware } from '@trpc/server/adapters/express';
import express from 'express';
import { createOpenApiExpressMiddleware } from 'trpc-openapi';

import { appRouter } from '../appRouter';

const app = express();

app.use('/api/trpc', createExpressMiddleware({ router: appRouter }));
app.use('/api', createOpenApiExpressMiddleware({ router: appRouter })); /* πŸ‘ˆ */

app.listen(3000);

With Next.js

Please see full example here.

// pages/api/[trpc].ts
import { createOpenApiNextHandler } from 'trpc-openapi';

import { appRouter } from '../../server/appRouter';

export default createOpenApiNextHandler({ router: appRouter });

Types

GenerateOpenApiDocumentOptions

Please see full typings here.

Property Type Description Required
title string The title of the API. true
description string A short description of the API. false
version string The version of the OpenAPI document. true
baseUrl string The base URL of the target server. true
docsUrl string A URL to any external documentation. false
tags string[] A list for ordering endpoint groups. false

OpenApiMeta

Please see full typings here.

Property Type Description Required Default
enabled boolean Exposes this procedure to trpc-openapi adapters and on the OpenAPI document. true false
method HttpMethod Method this endpoint is exposed on. Value can be GET/DELETE for queries OR POST/PUT/PATCH for mutations. true undefined
path string Pathname this endpoint is exposed on. Value must start with /, specify path parameters using {}. true undefined
protect boolean Requires this endpoint to use an Authorization header credential with Bearer scheme on OpenAPI document. false false
summary string A short summary of the endpoint included in the OpenAPI document. false undefined
description string A verbose description of the endpoint included in the OpenAPI document. false undefined
tag string A tag used for logical grouping of endpoints in the OpenAPI document. false undefined

CreateOpenApiNodeHttpHandlerOptions

Please see full typings here.

Property Type Description Required
router Router Your application tRPC router. true
createContext Function Passes contextual (ctx) data to procedure resolvers. false
responseMeta Function Returns any modifications to statusCode & headers. false
onError Function Called if error occurs inside handler. false
teardown Function Called after each request is completed. false
maxBodySize number Maximum request body size in bytes (default: 100kb). false

License

Distributed under the MIT License. See LICENSE for more information.

Contact

James Berry - Follow me on Twitter @jlalmes πŸ’š

Comments
  • [Help wanted] T3 Stack and Queryparameters

    [Help wanted] T3 Stack and Queryparameters

    Hey Guys

    I've started using the T3 Stack with trpc / nextjs and wanted to use this awesome package to my Project. Everything works fine and I see the OpenAPI-Docs in the expected route. But i dont understand why this happens

    When looking at my trpc query, I have the following:

    export const exampleRouter = createRouter().query("hello", {
      meta: { openapi: { enabled: true, method: "GET", path: "/api/trpc/example.hello" } },
      input: z.object({ name: z.string() }),
      output: z.object({ greeting: z.string() }),
      resolve: ({ input }) => {
        return { greeting: `Hello ${input.name}!` };
      },
    });
    

    which generated the OpenAPI docs but when i try to execute it throught the UI it generates the URL like this: http://0.0.0.0:3000/api/trpc/example.hello?name=asdf which is of course not wrong. But when looking into the dev-tools on my page the request generated from trpc-client is generated like this: http://localhost:3000/api/trpc/example.hello?batch=1&input={"0":{"json":{"name":"jerome"}}}

    Can i change this behavior for the generation of the OpenAPI docs or how would you recommend trying to fix this?

    Thanks in advanced Jerome

    opened by JeromeK13 13
  • fix/support multiple tags per endpoint

    fix/support multiple tags per endpoint

    I was trying out the package and noticed that each endpoint is limited to a single tag. Please see below.

    const testRouter = createRouter().query("hello", {
    	meta: { openapi: { enabled: true, method: "GET", path: "/hello", tag: "OnlyASingleTag" } },
    	input: z.object({ /** input stuff */ }),
    	output: z.object({ /** output stuff */ }),
    	async resolve({ input }) {
    		/** implementation stuff */
    	},
    });
    

    Maybe this needs to change? Since tags are used to group operations together and a single one could be in two groups. Also, Swagger Docs on the OpenAPI Spec for 3.0.3, states that the tag field should container an Array of string tags. -> string[] https://swagger.io/specification/#operation-object

    opened by SeanCassiere 11
  • RFC: Reduce OpenAPI `meta` complexity

    RFC: Reduce OpenAPI `meta` complexity

    Initially proposed by @mshd (https://github.com/jlalmes/trpc-openapi/issues/55) Additionally raised by @TheoBr (https://youtu.be/YAzzvhaRs6M?t=7086)

    RFC: Reduce OpenAPI meta complexity

    It has been mentioned a few times that the meta required to enable OpenAPI support on a tRPC procedure could be reduced. This RFC proposes setting some sensible defaults (can be overwritten), such that the minimum required meta will be as follows:

    { openapi: { enabled: true } }
    

    Current requirements

    • meta.openapi.enabled: true
    • meta.openapi.method: GET | POST | PUT | PATCH | DELETE
    • meta.openapi.path: string

    Sensible defaults

    • meta.openapi.enabled: defaults to false
    • meta.openapi.method: defaults to GET (query) | POST (mutation)
    • meta.openapi.path: defaults to computed value from tRPC procedure where:
      • nested routers = /
      • path = path.replace(/[A-Z]/g, (m) => "-" + m.toLowerCase())

    Example (v10)

    const postsRouter = t.router({
      getById: t.procedure
        .meta({ openapi: { enabled: true } }),  // { openapi: { enabled: true, method: 'GET', path: '/posts/get-by-id' } }
        .input(z.object({ id: z.string() })),
        .output(postSchema)
        .query(({ input }) => {
           ...
        })
      ...
    })
    
    const appRouter = t.router({
      posts: postsRouter,
      ...
    })
    

    Concerns

    • The defaults will likely not follow proper RESTful API design patterns in most cases, examples:
      • /posts/get-by-id should be /posts/{id}.
      • update endpoints should be using PUT or PATCH.
    • It is not clear when you will be introducing a breaking changes to your public OpenAPI, example:
      • If you refactor a procedure name, its path will change.

    Not fully sold on this change, any thoughts are welcomed (cc @KATT @sachinraja)

    discussion 
    opened by jlalmes 11
  • Defining procedures with no `input`

    Defining procedures with no `input`

    Defining a query/mutation with no input results in

    TRPCError: [query.<queryName>] - Input parser expects a Zod validator
    

    It's possible to workaround this by defining an empty input:

    input: z.object({}),
    

    However, that way an empty object is expected when calling the query via TRPC client. It's a legit use-case to have queries/mutations with no input, right? Can we allow omitting input in such cases?

    opened by dodas 10
  • RFC: Support `number`, `boolean`, `Date` in query params

    RFC: Support `number`, `boolean`, `Date` in query params

    Right now it's not possible to have z.number()'s in your input schema for GET requests. That makes sense since query params are strings (so you get an error like Input parser key: "limit" must be ZodString).

    But often (I'm thinking especially of pagination), you need numbers. Right now, you can recreate similar functionality with z.string().transform((s) => parseInt(s), but it's not ideal since you lose, for example, Zod's built-in min/max validation.

    At a minimum, this deserves a mention in the documentation. If we're feeling more ambitious, we can introduce autoconversions to number/date for common types.

    I'm happy to open a PR, but first wanted to hear what you think, @jlalmes.

    idea discussion stale 
    opened by jqhoogland 9
  • bug: Optional is not reflected in docs

    bug: Optional is not reflected in docs

    I searched previous issues but couldn't find anything like this.

    When using the input

    .input(
        z.object({
          nameOfUser: z.string().optional(),
        }),
      )
    

    I get the following:

    Screenshot 2022-12-30 at 15 57 27

    This is incorrect,

    It should be

    {
      "nameOfUser": "string?"
    }
    
    opened by ollydixon 7
  • Getting Error :  Input parser key:

    Getting Error : Input parser key: "from" must be ZodString

    Hey thanks for this library,

    I am trying to understand why the value of an input objects must be a ZodString. I get following error : Input parser key: "from" must be ZodString

      input: z.object({
            from: z.number(),
            to: z.number(),
        }),
    

    I read here https://github.com/jlalmes/trpc-openapi/blob/next/README.md that the input object is defined as ZodObject<{ [string]: ZodString }> but openApiSpec also allows number/ integer etc

    at least number would be good.

    opened by Manuelbaun 7
  •  TRPCError: Input parser must be a ZodObject

    TRPCError: Input parser must be a ZodObject

    Hi, I am getting the following error: TRPCError: Input parser must be a ZodObject. I am following the nextjs example provided in trpc-openapi/src/examples. Getting the same error on all trpc-open api routes [...trpc] including the openapi.json route.

    I have looked through all the previous issues and can't seem to figure out what I am doing wrong.

    Please let me know if additional details are required.

    Regards, Dawood

    Package.json:

    { "name": "next-boilerplate", "version": "0.1.0", "private": true, "scripts": { "dev": "next dev", "build": "next build", "start": "next start", "lint": "next lint" }, "dependencies": { "@tanstack/react-query": "^4.20.2", "@trpc/client": "^10.5.0", "@trpc/next": "^10.5.0", "@trpc/react-query": "^10.5.0", "@trpc/server": "^10.5.0", "@types/styled-components-react-native": "^5.1.3", "next": "12.1.6", "nextjs-cors": "^2.1.2", "react": "18.1.0", "react-dom": "18.1.0", "react-is": "^18.2.0", "styled-components": "^5.3.5", "superjson": "^1.12.0", "swagger-ui-react": "^4.15.5", "trpc-openapi": "^1.0.0", "zod": "^3.20.2" }, "devDependencies": { "@types/node": "17.0.36", "@types/react": "18.0.9", "@types/react-dom": "18.0.5", "@types/styled-components": "^5.1.25", "@types/swagger-ui-react": "^4.11.0", "eslint": "8.16.0", "eslint-config-next": "12.1.6", "typescript": "4.7.2" }, "resolutions": { "styled-components": "^5" } }

    opened by dawoodaijaz97 6
  • Feat: tRPC V10 Support

    Feat: tRPC V10 Support

    Hi James, Is the tRPC alpha version 10 already supported? If not, when would it be possible? Also since this package is so closely tied and useful to tRPC, has it been considered to be merged into the tRPC monorepo?

    enhancement 
    opened by mshd 6
  • Path params

    Path params

    Hey @jlalmes, this is a great little library!

    I am exploring possibilities and as far as I can understand, there is currently no way to define a path parameter. Consider the petstore swagger example, the uploadFile has petId parameter, which is part of the path.

    Could we try to extract the path params by looking for curly braces in meta.openapi.path, and then find param with the same name in input and mark that param as from: "path" instead of from: "query"?

    WIP attempt to implement the above approach: https://github.com/jlalmes/trpc-openapi/compare/v0.1.0...dodas:feat/path-parameters

    Have you thought about supporting this use case? I am happy to discuss this and potentially take a stab at implementing it.

    Thanks!

    enhancement idea 
    opened by dodas 6
  • RFC: Remove response wrapper

    RFC: Remove response wrapper

    hi!

    i need to satisfy a REST call which i can't influence. is there a way to return the response without the wrapper:

    instead of this:

    {
      "ok": true,
      "data": "This is good" /* Output from tRPC procedure */
    }
    

    return this:

    {
      "name": "trpc", /* Output from tRPC procedure */
      "lang": "TS" /* Output from tRPC procedure */
    }
    

    if not, it would be a nice enhancement since i'm going to be not the only one with this issue. i'm probably going to fork this for now until i'm confident enough to make a PR.

    const successResponseObject = {
        description: 'Successful response',
        content: {
          'application/json': {
            schema: zodSchemaToOpenApiSchemaObject(
              z.object({
                ok: z.literal(true),
                data: schema,
              }),
            ),
          },
        },
      };
    ```
    idea discussion 
    opened by moogmodular 5
  • Bump json5 from 1.0.1 to 1.0.2

    Bump json5 from 1.0.1 to 1.0.2

    Bumps json5 from 1.0.1 to 1.0.2.

    Release notes

    Sourced from json5's releases.

    v1.0.2

    • Fix: Properties with the name __proto__ are added to objects and arrays. (#199) This also fixes a prototype pollution vulnerability reported by Jonathan Gregson! (#295). This has been backported to v1. (#298)
    Changelog

    Sourced from json5's changelog.

    Unreleased [code, diff]

    v2.2.3 [code, diff]

    v2.2.2 [code, diff]

    • Fix: Properties with the name __proto__ are added to objects and arrays. (#199) This also fixes a prototype pollution vulnerability reported by Jonathan Gregson! (#295).

    v2.2.1 [code, diff]

    • Fix: Removed dependence on minimist to patch CVE-2021-44906. (#266)

    v2.2.0 [code, diff]

    • New: Accurate and documented TypeScript declarations are now included. There is no need to install @types/json5. (#236, #244)

    v2.1.3 [code, diff]

    • Fix: An out of memory bug when parsing numbers has been fixed. (#228, #229)

    v2.1.2 [code, diff]

    ... (truncated)

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) You can disable automated security fix PRs for this repo from the Security Alerts page.
    dependencies 
    opened by dependabot[bot] 0
  • errorFormatter returns invalid openapi schema

    errorFormatter returns invalid openapi schema

    I've been using errorFormatter to include Zod errors and more custom errors, but the returned error type in openapi schema doesn't synchronize trpc error formatter: errorFormatter({ shape, error }) { return { ...shape, data: { ...shape.data, errCode: error.cause instanceof CustomTRPCError ? error.cause.errCode : null, zodError: error.code === 'BAD_REQUEST' && error.cause instanceof ZodError ? error.cause.flatten() : null, }, }; }

    return open-api schema: { "message": "string", "code": "string", "issues": [ { "message": "string" } ] }

    real response: { "message": "Input validation failed", "code": "BAD_REQUEST", "issues": [ { "validation": "uuid", "code": "invalid_string", "message": "Invalid uuid", "path": [ "keyRingKeyId" ] } ] }

    enhancement 
    opened by matannahmani 1
  • Bump node-fetch from 2.6.7 to 3.3.0

    Bump node-fetch from 2.6.7 to 3.3.0

    Bumps node-fetch from 2.6.7 to 3.3.0.

    Release notes

    Sourced from node-fetch's releases.

    v3.3.0

    3.3.0 (2022-11-10)

    Features

    v3.2.10

    3.2.10 (2022-07-31)

    Bug Fixes

    v3.2.9

    3.2.9 (2022-07-18)

    Bug Fixes

    • Headers: don't forward secure headers on protocol change (#1599) (e87b093)

    v3.2.8

    3.2.8 (2022-07-12)

    Bug Fixes

    v3.2.7

    3.2.7 (2022-07-11)

    Bug Fixes

    v3.2.6

    3.2.6 (2022-06-09)

    Bug Fixes

    • undefined reference to response.body when aborted (#1578) (1c5ed6b)

    v3.2.5

    3.2.5 (2022-06-01)

    ... (truncated)

    Commits
    Maintainer changes

    This version was pushed to npm by node-fetch-bot, a new releaser for node-fetch since your current version.


    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 0
  • Feat: Fastify adapter

    Feat: Fastify adapter

    opened by SeanCassiere 19
Releases(v1.1.1)
  • v1.1.1(Jan 3, 2023)

    What's Changed

    • Fix: Tighter input parsing content-types (https://github.com/jlalmes/trpc-openapi/pull/230)

    Full Changelog: https://github.com/jlalmes/trpc-openapi/compare/v1.1.0...v1.1.1

    Source code(tar.gz)
    Source code(zip)
  • v1.1.0(Jan 3, 2023)

    What's Changed

    • Fix: Typo in with-nextjs example (https://github.com/jlalmes/trpc-openapi/pull/210)
    • Fix: optional input object (https://github.com/jlalmes/trpc-openapi/pull/218)
    • Feat: coerce input values to primitive types (https://github.com/jlalmes/trpc-openapi/pull/219)
    • Docs: tidy up by (https://github.com/jlalmes/trpc-openapi/pull/221)
    • Feat: Support x-www-form-urlencoded request bodies (https://github.com/jlalmes/trpc-openapi/pull/222)

    New Contributors

    • @anthonyshew made their first contribution πŸš€

    Full Changelog: https://github.com/jlalmes/trpc-openapi/compare/v1.0.0...v1.1.0

    Source code(tar.gz)
    Source code(zip)
  • v1.0.0(Nov 27, 2022)

    Breaking changes

    • Added support for @trpc/server@10
    • Removed meta.openapi.enabled: true requirement
    • Removed { ok: boolean, data/error: ... } response wrapper
    • Removed deprecated meta.openapi.tag property
    • Removed teardown function from adapters

    What's Changed

    • Serverless adapter by @aphex

    Full Changelog: https://github.com/jlalmes/trpc-openapi/compare/v0.7.0...v1.0.0

    Source code(tar.gz)
    Source code(zip)
  • v0.7.0(Aug 25, 2022)

    What's Changed

    • Feat: Support top-level z.preprocess (https://github.com/jlalmes/trpc-openapi/pull/140)
    • Performance: Lazy monkey patching inputs (https://github.com/jlalmes/trpc-openapi/pull/125)
    • Performance: Skip router validation in production (https://github.com/jlalmes/trpc-openapi/pull/125)
    • Docs: Better instructions in examples README (https://github.com/jlalmes/trpc-openapi/pull/138)
    • Chore: Upgraded dependencies (https://github.com/jlalmes/trpc-openapi/pull/139)

    Full Change Log: https://github.com/jlalmes/trpc-openapi/compare/v0.6.1...v0.7.0

    Source code(tar.gz)
    Source code(zip)
  • v0.6.1(Aug 22, 2022)

    What's Changed

    • Feat: Any procedure type can use any HTTP method. (https://github.com/jlalmes/trpc-openapi/pull/123)
    • Fix: Prevent operationId collisions (https://github.com/jlalmes/trpc-openapi/pull/123)
    • Docs: Added cors to with-nextjs example (https://github.com/jlalmes/trpc-openapi/pull/122)
    • Docs: Custom headers (https://github.com/jlalmes/trpc-openapi/pull/121)

    Full Change Log: https://github.com/jlalmes/trpc-openapi/compare/v0.6.0...v0.6.1

    Source code(tar.gz)
    Source code(zip)
  • v0.6.0(Aug 22, 2022)

    What's Changed

    • Feat: support custom headers (https://github.com/jlalmes/trpc-openapi/pull/119)
    • Chore: bump dependencies (https://github.com/jlalmes/trpc-openapi/pull/120)

    Full Change Log: https://github.com/jlalmes/trpc-openapi/compare/v0.5.0...v0.6.0

    Source code(tar.gz)
    Source code(zip)
  • 0.5.0(Aug 8, 2022)

    What's Changed

    • Feat: improved support for ZodEffects (https://github.com/jlalmes/trpc-openapi/pull/102)
    • Fix: fixed zodToJsonSchema $ref strategy (https://github.com/jlalmes/trpc-openapi/pull/104)
    • Chore: deprecated tag in OpenApiMeta (https://github.com/jlalmes/trpc-openapi/pull/92)
    • Chore: bump dependencies (https://github.com/jlalmes/trpc-openapi/pull/103)

    New Contributors :heart:

    • @klapacz made their first contribution in https://github.com/jlalmes/trpc-openapi/pull/84

    Full Change Log: https://github.com/jlalmes/trpc-openapi/compare/v0.4.0...v0.5.0

    Source code(tar.gz)
    Source code(zip)
  • v0.4.0(Jul 22, 2022)

    What's Changed

    • Feat: added support for multiple tags per endpoint (https://github.com/jlalmes/trpc-openapi/pull/84)

    New Contributors :heart:

    • @SeanCassiere made their first contribution in https://github.com/jlalmes/trpc-openapi/pull/84

    Full Change Log: https://github.com/jlalmes/trpc-openapi/compare/v0.3.0...v0.4.0

    Source code(tar.gz)
    Source code(zip)
  • v0.3.0(Jul 19, 2022)

    What's Changed

    • Feat: added operationId property OpenAPI endpoints (https://github.com/jlalmes/trpc-openapi/pull/77)
    • Chore: upgraded dependencies (https://github.com/jlalmes/trpc-openapi/pull/78)

    Full Change Log: https://github.com/jlalmes/trpc-openapi/compare/v0.2.2...v0.3.0

    Source code(tar.gz)
    Source code(zip)
  • v0.2.2(Jul 14, 2022)

    What's Changed

    • Feat: support ZodLazy and ZodIntersection query input (https://github.com/jlalmes/trpc-openapi/pull/69)
    • Chore: refactored procedure iteration logic (https://github.com/jlalmes/trpc-openapi/pull/69)
    • Docs: updated trpc-openapi graph/readme images (https://github.com/jlalmes/trpc-openapi/pull/66)
    • CI: added stale-bot for closing inactive issues (https://github.com/jlalmes/trpc-openapi/pull/62)

    Full Change Log: https://github.com/jlalmes/trpc-openapi/compare/v0.1.3...v0.2.2

    Source code(tar.gz)
    Source code(zip)
  • v0.1.3(Jul 11, 2022)

    What's Changed

    • Fix: No longer requires ts-lib as dependency (https://github.com/jlalmes/trpc-openapi/pull/60)

    Full Change Log: https://github.com/jlalmes/trpc-openapi/compare/v0.1.2...v0.1.3

    Source code(tar.gz)
    Source code(zip)
  • v0.1.2(Jul 5, 2022)

    What's Changed

    • Fix: Schema for optional query input parameters (https://github.com/jlalmes/trpc-openapi/pull/45)
    • Feat: Path parameters must not be optional (https://github.com/jlalmes/trpc-openapi/pull/45)
    • Chore: Upgraded dependencies (https://github.com/jlalmes/trpc-openapi/pull/38)

    Full Change Log: https://github.com/jlalmes/trpc-openapi/compare/v0.1.1...v0.1.2

    Source code(tar.gz)
    Source code(zip)
  • v0.1.1(Jun 13, 2022)

    What's Changed

    • Fix: Yarn not installing peerDependencies (https://github.com/jlalmes/trpc-openapi/pull/18)
    • Fix: Adapters should return void (https://github.com/jlalmes/trpc-openapi/pull/16)

    Full Change Log: https://github.com/jlalmes/trpc-openapi/compare/v0.1.0...v0.1.1

    Source code(tar.gz)
    Source code(zip)
  • v0.1.0(Jun 10, 2022)

    trpc-openapi is stable!

    OpenAPI support for tRPC 🧩

    • Easy REST endpoints for your tRPC procedures.
    • Perfect for incremental adoption.
    • OpenAPI version 3.0.3.

    Many thanks to

    • Alex, tRPC - https://github.com/KATT
    • Jozef - https://github.com/dodas
    Source code(tar.gz)
    Source code(zip)
Owner
James Berry
@trpc maintainer - now building something new πŸ‘·πŸš§
James Berry
Grupprojekt fΓΆr kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet fΓΆr kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide FΓΆr information om hur utv

Svante Jonsson IT-HΓΆgskolan 3 May 18, 2022
Hemsida fΓΆr personer i Sverige som kan och vill erbjuda boende till mΓ€nniskor pΓ₯ flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo fΓΆr kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
Proof of concept: support immutable trpc servers using lambdas to ensure client/server compatibility

auto-versioned-trpc-aws-lambda Proof of concept to support an automatically versioned AWS Lambda running tRPC to ensure a somewhat graceful and automa

Kenneth Skovhus 5 Aug 30, 2022
Query for CSS brower support data, combined from caniuse and MDN, including version support started and global support percentages.

css-browser-support Query for CSS browser support data, combined from caniuse and MDN, including version support started and global support percentage

Stephanie Eckles 65 Nov 2, 2022
Example auto-generated OpenAPI client library and an accompanying example Angular app.

To utilize this demo Head into petstore_frontend\petes_pets Run npm install Go to frontend_client_lib\out Run npm install Head back into petstore_fron

Alan Gross 1 Jan 21, 2022
OpenAPI (Swagger) module for Nest framework (node.js) :earth_americas:

A progressive Node.js framework for building efficient and scalable server-side applications. Description OpenAPI (Swagger) module for Nest. Installat

nestjs 1.3k Jan 6, 2023
REST API complete test suite using openapi.json

Openapi Test Suite Objective This package aims to solve the following two problems: Maintenance is a big problem to solve in any test suite. As the AP

PLG Works 21 Nov 3, 2022
Generate a zodios (typescript http client with zod validation) from an OpenAPI spec (json/yaml)

openapi-zod-client Generates a zodios (typescript http client with zod validation) from a (json/yaml) OpenAPI spec (or just use the generated schemas/

Alexandre Stahmer 104 Jan 4, 2023
An OpenAPI specification for the MagicBell API.

MagicBell's OpenAPI Specification This repository contains OpenAPI specifications for the MagicBell REST API. Changelog Files can be found in the /spe

MagicBell 5 Dec 15, 2022
Quickly bootstrap your next TypeScript REST API project. Node 16+, auto OpenAPI, Prettier+ESLint, Jest

REST API template with autogenerated OpenAPI Quickly bootstrap your next TypeScript REST API project with the most up to date template. Included a sam

null 6 Oct 1, 2022
End-to-end typesafe APIs with tRPC.io in SvelteKit applications

✨ tRPC-SvelteKit End-to-end typesafe APIs with tRPC.io in SvelteKit applications. No code generation, run-time bloat, or build pipeline. ❀️ ???? See b

Ionut-Cristian Florescu 307 Dec 29, 2022
Prisma 2+ generator to emit fully implemented tRPC routers

Prisma tRPC Generator Automatically generate fully implemented tRPC routers from your Prisma Schema. This includes routers, app router and of course a

Omar Dulaimi 370 Jan 3, 2023
tRPC-ified SWR hooks

trpc-swr tRPC-ified SWR hooks Installation npm install trpc-swr @trpc/client Usage First, create your fully typed hooks using your router type: // trp

Sachin Raja 129 Jan 8, 2023
Prisma +2 generator to emit a tRPC shield from your Prisma schema

Prisma tRPC Shield Generator Automatically generate a tRPC Shield from your Prisma Schema. Updates every time npx prisma generate runs. Table of Conte

Omar Dulaimi 27 Dec 24, 2022
tRPC test & precursor to a billion dollar social cat network

CatMash What is this? Have you ever wanted to rank 11,000 cat pictures by cuteness? Of course you have. That's what we're doing here. This is an app b

Christopher Ehrlich 6 Dec 18, 2022
Scaffold a full-stack SvelteKit application with tRPC and WindiCSS out of the box

create-sweet-app Interactive CLI to quickly set up an opinionated, full-stack, typesafe SvelteKit project. Inspired by the T3 Stack and create-t3-app

David HrabΔ› 10 Dec 16, 2022
NX monorepo showing the TMDB Watchlist mobile app with Expo, tRPC, Next, and Prisma

tmdb-watchlist-prisma This app uses TMDB to retrieve a list of Now Playing movies. You can add/remove movies to track which ones you've watched. There

Mat Warger 65 Dec 28, 2022
A trpc-ified useReducer hook. ⚑

trpc-reducer A trpc-ified react useReducer hook that lets you perform state logic in reducers just like React's useReducer hook When you dispatch an a

gabriel-frattini 14 Aug 27, 2022