Skip to content

Commit 014e038

Browse files
committed
chore: polish validator option
1 parent 8e1e62d commit 014e038

18 files changed

Lines changed: 428 additions & 371 deletions

File tree

dev/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"@hey-api/openapi-python": "workspace:*",
1414
"@hey-api/openapi-ts": "workspace:*",
1515
"@opencode-ai/sdk": "1.2.27",
16+
"@orpc/contract": "1.13.4",
1617
"@pinia/colada": "0.19.1",
1718
"@tanstack/angular-query-experimental": "5.90.25",
1819
"@tanstack/preact-query": "5.93.0",

dev/typescript/presets.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ export const presets = {
3030
},
3131
},
3232
],
33+
rpc: () => [
34+
/** RPC-style SDK with Zod validation */
35+
{
36+
name: '@orpc/contract',
37+
},
38+
'zod',
39+
],
3340
sdk: () => [
3441
/** SDK with types */
3542
'@hey-api/typescript',

packages/openapi-ts-tests/@orpc/contract/v1/__snapshots__/3.0.x/custom-contract-name/@orpc/contract.gen.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ export const base = oc.$route({ inputStructure: 'detailed' });
1111
*/
1212
export const getUsersRpc = base.route({
1313
method: 'GET',
14-
path: '/users',
1514
operationId: 'getUsers',
15+
path: '/users',
1616
summary: 'Get all users',
1717
tags: ['users']
1818
}).input(zGetUsersData).output(zGetUsersResponse);
@@ -22,20 +22,20 @@ export const getUsersRpc = base.route({
2222
*/
2323
export const createUserRpc = base.route({
2424
method: 'POST',
25-
path: '/users',
2625
operationId: 'createUser',
26+
path: '/users',
27+
successStatus: 201,
2728
summary: 'Create a new user',
28-
tags: ['users'],
29-
successStatus: 201
29+
tags: ['users']
3030
}).input(zCreateUserData).output(zCreateUserResponse);
3131

3232
/**
3333
* Delete a user
3434
*/
3535
export const deleteUserRpc = base.route({
3636
method: 'DELETE',
37-
path: '/users/{userId}',
3837
operationId: 'deleteUser',
38+
path: '/users/{userId}',
3939
summary: 'Delete a user',
4040
tags: ['users']
4141
}).input(zDeleteUserData);
@@ -45,8 +45,8 @@ export const deleteUserRpc = base.route({
4545
*/
4646
export const getUserByIdRpc = base.route({
4747
method: 'GET',
48-
path: '/users/{userId}',
4948
operationId: 'getUserById',
49+
path: '/users/{userId}',
5050
summary: 'Get a user by ID',
5151
tags: ['users']
5252
}).input(zGetUserByIdData).output(zGetUserByIdResponse);
@@ -56,8 +56,8 @@ export const getUserByIdRpc = base.route({
5656
*/
5757
export const updateUserRpc = base.route({
5858
method: 'PUT',
59-
path: '/users/{userId}',
6059
operationId: 'updateUser',
60+
path: '/users/{userId}',
6161
summary: 'Update a user',
6262
tags: ['users']
6363
}).input(zUpdateUserData).output(zUpdateUserResponse);
@@ -67,8 +67,8 @@ export const updateUserRpc = base.route({
6767
*/
6868
export const getPostsRpc = base.route({
6969
method: 'GET',
70-
path: '/posts',
7170
operationId: 'getPosts',
71+
path: '/posts',
7272
summary: 'Get all posts',
7373
tags: ['posts']
7474
}).input(zGetPostsData).output(zGetPostsResponse);
@@ -78,20 +78,20 @@ export const getPostsRpc = base.route({
7878
*/
7979
export const createPostRpc = base.route({
8080
method: 'POST',
81-
path: '/posts',
8281
operationId: 'createPost',
82+
path: '/posts',
83+
successStatus: 201,
8384
summary: 'Create a new post',
84-
tags: ['posts'],
85-
successStatus: 201
85+
tags: ['posts']
8686
}).input(zCreatePostData).output(zCreatePostResponse);
8787

8888
/**
8989
* Get a post by ID
9090
*/
9191
export const getPostByIdRpc = base.route({
9292
method: 'GET',
93-
path: '/posts/{postId}',
9493
operationId: 'getPostById',
94+
path: '/posts/{postId}',
9595
summary: 'Get a post by ID',
9696
tags: ['posts']
9797
}).input(zGetPostByIdData).output(zGetPostByIdResponse);

packages/openapi-ts-tests/@orpc/contract/v1/__snapshots__/3.0.x/custom-router-name/@orpc/contract.gen.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ export const base = oc.$route({ inputStructure: 'detailed' });
1111
*/
1212
export const getUsersContract = base.route({
1313
method: 'GET',
14-
path: '/users',
1514
operationId: 'getUsers',
15+
path: '/users',
1616
summary: 'Get all users',
1717
tags: ['users']
1818
}).input(zGetUsersData).output(zGetUsersResponse);
@@ -22,20 +22,20 @@ export const getUsersContract = base.route({
2222
*/
2323
export const createUserContract = base.route({
2424
method: 'POST',
25-
path: '/users',
2625
operationId: 'createUser',
26+
path: '/users',
27+
successStatus: 201,
2728
summary: 'Create a new user',
28-
tags: ['users'],
29-
successStatus: 201
29+
tags: ['users']
3030
}).input(zCreateUserData).output(zCreateUserResponse);
3131

3232
/**
3333
* Delete a user
3434
*/
3535
export const deleteUserContract = base.route({
3636
method: 'DELETE',
37-
path: '/users/{userId}',
3837
operationId: 'deleteUser',
38+
path: '/users/{userId}',
3939
summary: 'Delete a user',
4040
tags: ['users']
4141
}).input(zDeleteUserData);
@@ -45,8 +45,8 @@ export const deleteUserContract = base.route({
4545
*/
4646
export const getUserByIdContract = base.route({
4747
method: 'GET',
48-
path: '/users/{userId}',
4948
operationId: 'getUserById',
49+
path: '/users/{userId}',
5050
summary: 'Get a user by ID',
5151
tags: ['users']
5252
}).input(zGetUserByIdData).output(zGetUserByIdResponse);
@@ -56,8 +56,8 @@ export const getUserByIdContract = base.route({
5656
*/
5757
export const updateUserContract = base.route({
5858
method: 'PUT',
59-
path: '/users/{userId}',
6059
operationId: 'updateUser',
60+
path: '/users/{userId}',
6161
summary: 'Update a user',
6262
tags: ['users']
6363
}).input(zUpdateUserData).output(zUpdateUserResponse);
@@ -67,8 +67,8 @@ export const updateUserContract = base.route({
6767
*/
6868
export const getPostsContract = base.route({
6969
method: 'GET',
70-
path: '/posts',
7170
operationId: 'getPosts',
71+
path: '/posts',
7272
summary: 'Get all posts',
7373
tags: ['posts']
7474
}).input(zGetPostsData).output(zGetPostsResponse);
@@ -78,20 +78,20 @@ export const getPostsContract = base.route({
7878
*/
7979
export const createPostContract = base.route({
8080
method: 'POST',
81-
path: '/posts',
8281
operationId: 'createPost',
82+
path: '/posts',
83+
successStatus: 201,
8384
summary: 'Create a new post',
84-
tags: ['posts'],
85-
successStatus: 201
85+
tags: ['posts']
8686
}).input(zCreatePostData).output(zCreatePostResponse);
8787

8888
/**
8989
* Get a post by ID
9090
*/
9191
export const getPostByIdContract = base.route({
9292
method: 'GET',
93-
path: '/posts/{postId}',
9493
operationId: 'getPostById',
94+
path: '/posts/{postId}',
9595
summary: 'Get a post by ID',
9696
tags: ['posts']
9797
}).input(zGetPostByIdData).output(zGetPostByIdResponse);

packages/openapi-ts-tests/@orpc/contract/v1/__snapshots__/3.0.x/default/@orpc/contract.gen.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ export const base = oc.$route({ inputStructure: 'detailed' });
1111
*/
1212
export const getUsersContract = base.route({
1313
method: 'GET',
14-
path: '/users',
1514
operationId: 'getUsers',
15+
path: '/users',
1616
summary: 'Get all users',
1717
tags: ['users']
1818
}).input(zGetUsersData).output(zGetUsersResponse);
@@ -22,20 +22,20 @@ export const getUsersContract = base.route({
2222
*/
2323
export const createUserContract = base.route({
2424
method: 'POST',
25-
path: '/users',
2625
operationId: 'createUser',
26+
path: '/users',
27+
successStatus: 201,
2728
summary: 'Create a new user',
28-
tags: ['users'],
29-
successStatus: 201
29+
tags: ['users']
3030
}).input(zCreateUserData).output(zCreateUserResponse);
3131

3232
/**
3333
* Delete a user
3434
*/
3535
export const deleteUserContract = base.route({
3636
method: 'DELETE',
37-
path: '/users/{userId}',
3837
operationId: 'deleteUser',
38+
path: '/users/{userId}',
3939
summary: 'Delete a user',
4040
tags: ['users']
4141
}).input(zDeleteUserData);
@@ -45,8 +45,8 @@ export const deleteUserContract = base.route({
4545
*/
4646
export const getUserByIdContract = base.route({
4747
method: 'GET',
48-
path: '/users/{userId}',
4948
operationId: 'getUserById',
49+
path: '/users/{userId}',
5050
summary: 'Get a user by ID',
5151
tags: ['users']
5252
}).input(zGetUserByIdData).output(zGetUserByIdResponse);
@@ -56,8 +56,8 @@ export const getUserByIdContract = base.route({
5656
*/
5757
export const updateUserContract = base.route({
5858
method: 'PUT',
59-
path: '/users/{userId}',
6059
operationId: 'updateUser',
60+
path: '/users/{userId}',
6161
summary: 'Update a user',
6262
tags: ['users']
6363
}).input(zUpdateUserData).output(zUpdateUserResponse);
@@ -67,8 +67,8 @@ export const updateUserContract = base.route({
6767
*/
6868
export const getPostsContract = base.route({
6969
method: 'GET',
70-
path: '/posts',
7170
operationId: 'getPosts',
71+
path: '/posts',
7272
summary: 'Get all posts',
7373
tags: ['posts']
7474
}).input(zGetPostsData).output(zGetPostsResponse);
@@ -78,20 +78,20 @@ export const getPostsContract = base.route({
7878
*/
7979
export const createPostContract = base.route({
8080
method: 'POST',
81-
path: '/posts',
8281
operationId: 'createPost',
82+
path: '/posts',
83+
successStatus: 201,
8384
summary: 'Create a new post',
84-
tags: ['posts'],
85-
successStatus: 201
85+
tags: ['posts']
8686
}).input(zCreatePostData).output(zCreatePostResponse);
8787

8888
/**
8989
* Get a post by ID
9090
*/
9191
export const getPostByIdContract = base.route({
9292
method: 'GET',
93-
path: '/posts/{postId}',
9493
operationId: 'getPostById',
94+
path: '/posts/{postId}',
9595
summary: 'Get a post by ID',
9696
tags: ['posts']
9797
}).input(zGetPostByIdData).output(zGetPostByIdResponse);

packages/openapi-ts-tests/@orpc/contract/v1/__snapshots__/3.1.x/custom-contract-name/@orpc/contract.gen.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ export const base = oc.$route({ inputStructure: 'detailed' });
1111
*/
1212
export const getUsersRpc = base.route({
1313
method: 'GET',
14-
path: '/users',
1514
operationId: 'getUsers',
15+
path: '/users',
1616
summary: 'Get all users',
1717
tags: ['users']
1818
}).input(zGetUsersData).output(zGetUsersResponse);
@@ -22,20 +22,20 @@ export const getUsersRpc = base.route({
2222
*/
2323
export const createUserRpc = base.route({
2424
method: 'POST',
25-
path: '/users',
2625
operationId: 'createUser',
26+
path: '/users',
27+
successStatus: 201,
2728
summary: 'Create a new user',
28-
tags: ['users'],
29-
successStatus: 201
29+
tags: ['users']
3030
}).input(zCreateUserData).output(zCreateUserResponse);
3131

3232
/**
3333
* Delete a user
3434
*/
3535
export const deleteUserRpc = base.route({
3636
method: 'DELETE',
37-
path: '/users/{userId}',
3837
operationId: 'deleteUser',
38+
path: '/users/{userId}',
3939
summary: 'Delete a user',
4040
tags: ['users']
4141
}).input(zDeleteUserData);
@@ -45,8 +45,8 @@ export const deleteUserRpc = base.route({
4545
*/
4646
export const getUserByIdRpc = base.route({
4747
method: 'GET',
48-
path: '/users/{userId}',
4948
operationId: 'getUserById',
49+
path: '/users/{userId}',
5050
summary: 'Get a user by ID',
5151
tags: ['users']
5252
}).input(zGetUserByIdData).output(zGetUserByIdResponse);
@@ -56,8 +56,8 @@ export const getUserByIdRpc = base.route({
5656
*/
5757
export const updateUserRpc = base.route({
5858
method: 'PUT',
59-
path: '/users/{userId}',
6059
operationId: 'updateUser',
60+
path: '/users/{userId}',
6161
summary: 'Update a user',
6262
tags: ['users']
6363
}).input(zUpdateUserData).output(zUpdateUserResponse);
@@ -67,8 +67,8 @@ export const updateUserRpc = base.route({
6767
*/
6868
export const getPostsRpc = base.route({
6969
method: 'GET',
70-
path: '/posts',
7170
operationId: 'getPosts',
71+
path: '/posts',
7272
summary: 'Get all posts',
7373
tags: ['posts']
7474
}).input(zGetPostsData).output(zGetPostsResponse);
@@ -78,20 +78,20 @@ export const getPostsRpc = base.route({
7878
*/
7979
export const createPostRpc = base.route({
8080
method: 'POST',
81-
path: '/posts',
8281
operationId: 'createPost',
82+
path: '/posts',
83+
successStatus: 201,
8384
summary: 'Create a new post',
84-
tags: ['posts'],
85-
successStatus: 201
85+
tags: ['posts']
8686
}).input(zCreatePostData).output(zCreatePostResponse);
8787

8888
/**
8989
* Get a post by ID
9090
*/
9191
export const getPostByIdRpc = base.route({
9292
method: 'GET',
93-
path: '/posts/{postId}',
9493
operationId: 'getPostById',
94+
path: '/posts/{postId}',
9595
summary: 'Get a post by ID',
9696
tags: ['posts']
9797
}).input(zGetPostByIdData).output(zGetPostByIdResponse);

0 commit comments

Comments
 (0)