Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit 774fffa

Browse files
authored
Docs/custom header (#121)
* docs/custom-header * typo
1 parent ca90f0a commit 774fffa

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

README.md

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ Both queries & mutations can accept a set of their inputs via URL path parameter
126126

127127
#### Query
128128

129-
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).
129+
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).
130130

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

171+
### Custom headers
172+
173+
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.
174+
171175
## HTTP Responses
172176

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

188192
```jsonc
189193
{
190194
"ok": false,
191195
"error": {
192-
"message": "This is bad" /* Message from TRPCError */,
193-
"code": "BAD_REQUEST" /* Code from TRPCError */
196+
"message": "This is bad", /* Message from TRPCError */,
197+
"code": "BAD_REQUEST", /* Code from TRPCError */
198+
"issues": [...] /* (optional) ZodIssues[] from TRPCError */
194199
}
195200
}
196201
```
@@ -305,15 +310,16 @@ Please see [full typings here](src/generator/index.ts).
305310

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

308-
| Property | Type | Description | Required | Default |
309-
| ------------- | ------------ | ------------------------------------------------------------------------------------------------------------------ | -------- | ----------- |
310-
| `enabled` | `boolean` | Exposes this procedure to `trpc-openapi` adapters and on the OpenAPI document. | `true` | `false` |
311-
| `method` | `HttpMethod` | Method this endpoint is exposed on. Value can be `GET`/`DELETE` for queries OR `POST`/`PUT`/`PATCH` for mutations. | `true` | `undefined` |
312-
| `path` | `string` | Pathname this endpoint is exposed on. Value must start with `/`, specify path parameters using `{}`. | `true` | `undefined` |
313-
| `protect` | `boolean` | Requires this endpoint to use an `Authorization` header credential with `Bearer` scheme on OpenAPI document. | `false` | `false` |
314-
| `summary` | `string` | A short summary of the endpoint included in the OpenAPI document. | `false` | `undefined` |
315-
| `description` | `string` | A verbose description of the endpoint included in the OpenAPI document. | `false` | `undefined` |
316-
| `tags` | `string[]` | A list of tags used for logical grouping of endpoints in the OpenAPI document. | `false` | `undefined` |
313+
| Property | Type | Description | Required | Default |
314+
| ------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------ | -------- | ----------- |
315+
| `enabled` | `boolean` | Exposes this procedure to `trpc-openapi` adapters and on the OpenAPI document. | `true` | `false` |
316+
| `method` | `HttpMethod` | Method this endpoint is exposed on. Value can be `GET`/`DELETE` for queries OR `POST`/`PUT`/`PATCH` for mutations. | `true` | `undefined` |
317+
| `path` | `string` | Pathname this endpoint is exposed on. Value must start with `/`, specify path parameters using `{}`. | `true` | `undefined` |
318+
| `protect` | `boolean` | Requires this endpoint to use an `Authorization` header credential with `Bearer` scheme on OpenAPI document. | `false` | `false` |
319+
| `summary` | `string` | A short summary of the endpoint included in the OpenAPI document. | `false` | `undefined` |
320+
| `description` | `string` | A verbose description of the endpoint included in the OpenAPI document. | `false` | `undefined` |
321+
| `tags` | `string[]` | A list of tags used for logical grouping of endpoints in the OpenAPI document. | `false` | `undefined` |
322+
| `headers` | `ParameterObject[]` | An array of custom headers to add for this endpoint in the OpenAPI document. | `false` | `undefined` |
317323

318324
#### CreateOpenApiNodeHttpHandlerOptions
319325

0 commit comments

Comments
 (0)