@composio/json-schema-to-zod 0.1.1
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 +34 -0
- package/dist/index.cjs +695 -0
- package/dist/index.d.cts +72 -0
- package/dist/index.d.ts +72 -0
- package/dist/index.js +658 -0
- package/package.json +37 -0
package/README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Json-Schema-to-Zod
|
|
2
|
+
|
|
3
|
+
A package to convert JSON schema (draft 4+) objects into Zod schemas in the form of Zod objects at runtime.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install @composio/json-schema-to-zod
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
### Simple example
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { jsonSchemaToZod } from 'json-schema-to-zod';
|
|
15
|
+
|
|
16
|
+
const jsonSchema = {
|
|
17
|
+
type: 'object',
|
|
18
|
+
properties: {
|
|
19
|
+
hello: {
|
|
20
|
+
type: 'string',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const zodSchema = jsonSchemaToZod(myObject);
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Overriding a parser
|
|
29
|
+
|
|
30
|
+
You can pass a function to the `overrideParser` option, which represents a function that receives the current schema node and the reference object, and should return a zod object when it wants to replace a default output. If the default output should be used for the node just return undefined.
|
|
31
|
+
|
|
32
|
+
## Acknowledgements
|
|
33
|
+
|
|
34
|
+
This is a fork of [`json-schema-to-zod`](https://github.com/StefanTerdell/json-schema-to-zod).
|