Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 19 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ Both queries & mutations can accept a set of their inputs via URL path parameter

#### Query

Query inputs are always accepted as a `string`, if you wish to support other primitives such as `number`, `boolean`, `Date` etc. please use [`z.preprocess()`](https://github.com/colinhacks/zod#preprocess).
Query (& path parameter) inputs are always accepted as a `string`, if you wish to support other primitives such as `number`, `boolean`, `Date` etc. please use [`z.preprocess()`](https://github.com/colinhacks/zod#preprocess).

```typescript
// Router
Expand Down Expand Up @@ -168,6 +168,10 @@ const res = await fetch('http://localhost:3000/say-hello/James' /* 👈 */, {
const body = await res.json(); /* { ok: true, data: { greeting: 'Hello James!' } } */
```

### Custom headers

Any custom headers can be specified in the `meta.openapi.headers` array, these headers will not be validated on request. Please consider using [Authorization](#authorization) for first-class OpenAPI auth/security support.

## HTTP Responses

Inspired by [Slack Web API](https://api.slack.com/web).
Expand All @@ -181,16 +185,17 @@ Please see [error status codes here](src/adapters/node-http/errors.ts).
```jsonc
{
"ok": true,
"data": "This is good" /* tRPC procedure output */
"data": "This is good" /* Output from tRPC procedure */
}
```

```jsonc
{
"ok": false,
"error": {
"message": "This is bad" /* Message from TRPCError */,
"code": "BAD_REQUEST" /* Code from TRPCError */
"message": "This is bad", /* Message from TRPCError */,
"code": "BAD_REQUEST", /* Code from TRPCError */
"issues": [...] /* (optional) ZodIssues[] from TRPCError */
}
}
```
Expand Down Expand Up @@ -305,15 +310,16 @@ Please see [full typings here](src/generator/index.ts).

Please see [full typings here](src/types.ts).

| 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` |
| `tags` | `string[]` | A list of tags used for logical grouping of endpoints in the OpenAPI document. | `false` | `undefined` |
| 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` |
| `tags` | `string[]` | A list of tags used for logical grouping of endpoints in the OpenAPI document. | `false` | `undefined` |
| `headers` | `ParameterObject[]` | An array of custom headers to add for this endpoint in the OpenAPI document. | `false` | `undefined` |

#### CreateOpenApiNodeHttpHandlerOptions

Expand Down