@orpc/valibot 0.0.0-next.e563486 → 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -10
- package/package.json +5 -5
package/README.md
CHANGED
@@ -8,8 +8,8 @@
|
|
8
8
|
<a href="https://codecov.io/gh/unnoq/orpc">
|
9
9
|
<img alt="codecov" src="https://codecov.io/gh/unnoq/orpc/branch/main/graph/badge.svg">
|
10
10
|
</a>
|
11
|
-
<a href="https://www.npmjs.com/package/@orpc/
|
12
|
-
<img alt="weekly downloads" src="https://img.shields.io/npm/dw/%40orpc%
|
11
|
+
<a href="https://www.npmjs.com/package/@orpc/zod">
|
12
|
+
<img alt="weekly downloads" src="https://img.shields.io/npm/dw/%40orpc%2Fzod?logo=npm" />
|
13
13
|
</a>
|
14
14
|
<a href="https://github.com/unnoq/orpc/blob/main/LICENSE">
|
15
15
|
<img alt="MIT License" src="https://img.shields.io/github/license/unnoq/orpc?logo=open-source-initiative" />
|
@@ -60,23 +60,38 @@ You can find the full documentation [here](https://orpc.unnoq.com).
|
|
60
60
|
- [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
|
61
61
|
- [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
|
62
62
|
- [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
|
63
|
-
- [@orpc/valibot](https://www.npmjs.com/package/@orpc/valibot): OpenAPI spec generation from [Valibot](https://valibot.dev/).
|
64
|
-
- [@orpc/arktype](https://www.npmjs.com/package/@orpc/arktype): OpenAPI spec generation from [ArkType](https://arktype.io/).
|
65
63
|
|
66
|
-
## `@orpc/
|
64
|
+
## `@orpc/zod`
|
67
65
|
|
68
|
-
|
66
|
+
More schemas that [Zod](https://zod.dev/) doesn't support yet, and provides `ZodToJsonSchemaConverter` for generating OpenAPI specs.
|
67
|
+
|
68
|
+
### More Schemas
|
69
|
+
|
70
|
+
- `oz.url`: Zod schema for [URL](https://developer.mozilla.org/en-US/docs/Web/API/URL) instance.
|
71
|
+
- `oz.blob`: Zod schema for [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob) instance.
|
72
|
+
- `oz.file`: Zod schema for [File](https://developer.mozilla.org/en-US/docs/Web/API/File) instance.
|
73
|
+
- `oz.regexp`: Zod schema for [RegExp](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) instance.
|
74
|
+
|
75
|
+
```ts
|
76
|
+
import { oz } from '@orpc/zod'
|
77
|
+
import { z } from 'zod'
|
78
|
+
|
79
|
+
const Example = z.object({
|
80
|
+
url: oz.url(),
|
81
|
+
blob: oz.blob(),
|
82
|
+
file: oz.file().type('image/png'),
|
83
|
+
regexp: oz.regexp(),
|
84
|
+
})
|
85
|
+
```
|
69
86
|
|
70
87
|
### Generate OpenAPI Spec
|
71
88
|
|
72
89
|
```ts
|
73
90
|
import { OpenAPIGenerator } from '@orpc/openapi'
|
74
|
-
import {
|
91
|
+
import { ZodToJsonSchemaConverter } from '@orpc/zod'
|
75
92
|
|
76
93
|
const openAPIGenerator = new OpenAPIGenerator({
|
77
|
-
schemaConverters: [
|
78
|
-
new ValibotToJsonSchemaConverter()
|
79
|
-
],
|
94
|
+
schemaConverters: [new ZodToJsonSchemaConverter()],
|
80
95
|
})
|
81
96
|
|
82
97
|
const specFromContract = await openAPIGenerator.generate(contract, {
|
@@ -94,6 +109,26 @@ const specFromRouter = await openAPIGenerator.generate(router, {
|
|
94
109
|
})
|
95
110
|
```
|
96
111
|
|
112
|
+
### Extending the Specification
|
113
|
+
|
114
|
+
```ts
|
115
|
+
import { oz } from '@orpc/zod'
|
116
|
+
import { z } from 'zod'
|
117
|
+
|
118
|
+
const InputSchema = oz.openapi(
|
119
|
+
z.object({
|
120
|
+
name: z.string(),
|
121
|
+
}),
|
122
|
+
{
|
123
|
+
examples: [
|
124
|
+
{ name: 'Earth' },
|
125
|
+
{ name: 'Mars' },
|
126
|
+
],
|
127
|
+
// additional options...
|
128
|
+
}
|
129
|
+
)
|
130
|
+
```
|
131
|
+
|
97
132
|
## License
|
98
133
|
|
99
134
|
Distributed under the MIT License. See [LICENSE](https://github.com/unnoq/orpc/blob/main/LICENSE) for more information.
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@orpc/valibot",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.0.0
|
4
|
+
"version": "0.0.0",
|
5
5
|
"license": "MIT",
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
7
7
|
"repository": {
|
@@ -25,13 +25,13 @@
|
|
25
25
|
],
|
26
26
|
"peerDependencies": {
|
27
27
|
"valibot": "*",
|
28
|
-
"@orpc/contract": "0.
|
29
|
-
"@orpc/server": "0.
|
28
|
+
"@orpc/contract": "0.48.0",
|
29
|
+
"@orpc/server": "0.48.0"
|
30
30
|
},
|
31
31
|
"dependencies": {
|
32
32
|
"@valibot/to-json-schema": "1.0.0-rc.0",
|
33
|
-
"@orpc/openapi": "0.
|
34
|
-
"@orpc/shared": "0.
|
33
|
+
"@orpc/openapi": "0.48.0",
|
34
|
+
"@orpc/shared": "0.48.0"
|
35
35
|
},
|
36
36
|
"scripts": {
|
37
37
|
"build": "unbuild",
|