Skip to content

Commit 6195da1

Browse files
committed
docs: Tidy up new paths
1 parent 895112a commit 6195da1

6 files changed

Lines changed: 32 additions & 28 deletions

File tree

.changeset/young-chefs-trade.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@ts-rest/open-api': patch
3+
---
4+
5+
Fix body zod parsing not working at all

apps/docs/docs/core/core.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ Breaking down the contract to sub-routers also allows you to split up the backen
88
const c = initContract();
99

1010
export const contract = c.router({
11-
createPost: c.mutation({
11+
createPost: {
1212
method: 'POST',
13-
path: () => '/posts',
13+
path: '/posts',
1414
responses: {
1515
201: c.response<Post>(),
1616
},
@@ -21,10 +21,10 @@ export const contract = c.router({
2121
description: z.string().optional(),
2222
}),
2323
summary: 'Create a post',
24-
}),
25-
getPosts: c.query({
24+
},
25+
getPosts: {
2626
method: 'GET',
27-
path: () => '/posts',
27+
path: '/posts',
2828
responses: {
2929
200: c.response<{ posts: Post[]; total: number }>(),
3030
},
@@ -34,7 +34,7 @@ export const contract = c.router({
3434
search: z.string().optional(),
3535
}),
3636
summary: 'Get all posts',
37-
}),
37+
},
3838
});
3939
```
4040

@@ -46,9 +46,9 @@ You can combine contracts to create a single contract, helpful if you want many
4646
const c = initContract();
4747

4848
export const postContract = c.router({
49-
getPosts: c.query({
49+
getPosts: {
5050
method: 'GET',
51-
path: () => '/posts',
51+
path: '/posts',
5252
responses: {
5353
200: c.response<{ posts: Post[]; total: number }>(),
5454
},
@@ -58,7 +58,7 @@ export const postContract = c.router({
5858
search: z.string().optional(),
5959
}),
6060
summary: 'Get all posts',
61-
}),
61+
},
6262
});
6363

6464
export const contract = c.router({

apps/docs/docs/core/errors.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ Since 2.0 ts-rest-api has a built-in error handling, all you need to do is defin
44

55
```typescript
66
export const routerBasic = c.router({
7-
updateUser: c.mutation({
7+
updateUser: {
88
method: 'PATCH',
9-
path: ({ id }: { id: string }) => `/basic/users/${id}`,
9+
path: `/basic/users/:id`,
1010
response: {
1111
200: c.response<User>(),
1212
400: c.response<{ message: string }>(),
1313
},
1414
body: c.body<{ name: string | null; email: string | null }>(),
1515
summary: 'Update a user',
16-
}),
16+
},
1717
});
1818
```
1919

apps/docs/docs/quickstart.mdx

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ const PostSchema = z.object({
3636
});
3737

3838
export const contract = c.router({
39-
createPost: c.mutation({
39+
createPost: {
4040
method: 'POST',
41-
path: () => '/posts',
41+
path: '/posts',
4242
responses: {
4343
201: PostSchema,
4444
},
@@ -47,16 +47,15 @@ export const contract = c.router({
4747
body: z.string(),
4848
}),
4949
summary: 'Create a post',
50-
}),
51-
getPost: c.query({
50+
},
51+
getPost: {
5252
method: 'GET',
53-
path: ({ id }: { id: string }) => `/posts/${id}`,
53+
path: `/posts/:id`,
5454
responses: {
5555
200: PostSchema.nullable(),
5656
},
57-
query: null,
5857
summary: 'Get a post by id',
59-
}),
58+
},
6059
});
6160
```
6261

@@ -72,24 +71,23 @@ import { initContract } from '@ts-rest/core';
7271
const c = initContract();
7372

7473
export const contract = c.router({
75-
createPost: c.mutation({
74+
createPost: {
7675
method: 'POST',
77-
path: () => '/posts',
76+
path: '/posts',
7877
responses: {
7978
201: c.response<Post>(),
8079
},
8180
body: c.body<{title: string}>()
8281
summary: 'Create a post',
83-
}),
84-
getPost: c.query({
82+
},
83+
getPost: {
8584
method: 'GET',
86-
path: ({ id }: { id: string }) => `/posts/${id}`,
85+
path: `/posts/:id`,
8786
responses: {
8887
200: c.response<Post | null>(),
8988
},
90-
query: null,
9189
summary: 'Get a post by id',
92-
}),
90+
},
9391
});
9492
```
9593

libs/example-contracts/src/lib/contract-blog.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const PostSchema = z.object({
1515
title: z.string(),
1616
description: z.string().nullable(),
1717
content: z.string().nullable(),
18-
published: z.boolean().nullable(),
18+
published: z.boolean(),
1919
tags: z.array(z.string()),
2020
});
2121

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"scripts": {
66
"version-packages": "changeset version",
77
"release": "yarn nx run-many --target=build && changeset publish",
8-
"nest": "yarn nx run example-nest:serve"
8+
"nest": "yarn nx run example-nest:serve",
9+
"affected:all": "yarn nx affected:lint && yarn nx affected:test && yarn nx affected:build"
910
},
1011
"private": true,
1112
"workspaces": [

0 commit comments

Comments
 (0)