Skip to content

Commit da65f31

Browse files
committed
Collapse the comparison examples to make the README less cluttered
1 parent e25b3ff commit da65f31

File tree

1 file changed

+28
-20
lines changed

1 file changed

+28
-20
lines changed

README.md

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ npm install json-schema-kit
2929

3030
## 🆚 Comparison
3131

32-
### Traditional JSON Schema
32+
<details>
33+
34+
<summary>Traditional JSON Schema</summary>
3335

3436
```json
3537
{
@@ -54,7 +56,11 @@ npm install json-schema-kit
5456
}
5557
```
5658

57-
### Using JSON Schema Kit
59+
</details>
60+
61+
<details>
62+
63+
<summary>Using JSON Schema Kit</summary>
5864

5965
```ts
6066
object({
@@ -69,6 +75,26 @@ object({
6975
})
7076
```
7177

78+
</details>
79+
80+
## 🤖 OpenAI Structured Outputs
81+
82+
JSON Schema Kit is perfectly suited for OpenAI's Structured Outputs.
83+
For example, here's how to use it with the Vercel AI SDK:
84+
85+
```ts
86+
const schema = object({
87+
summary: string(),
88+
sentiment: string({ enum: ['positive', 'neutral', 'negative'] }),
89+
})
90+
91+
await generateObject({
92+
model: openai(...),
93+
schema: jsonSchema(schema),
94+
prompt: 'Analyze this review: "Great product, works perfectly!"',
95+
})
96+
```
97+
7298
## 🔗 Using References
7399

74100
Use `$ref` to create reusable schema definitions and reference them throughout your schema:
@@ -101,24 +127,6 @@ const contact = anyOf([
101127
])
102128
```
103129

104-
## 🤖 OpenAI Structured Outputs
105-
106-
JSON Schema Kit is perfectly suited for OpenAI's Structured Outputs.
107-
For example, here's how to use it with the Vercel AI SDK:
108-
109-
```ts
110-
const schema = object({
111-
summary: string(),
112-
sentiment: string({ enum: ['positive', 'neutral', 'negative'] }),
113-
})
114-
115-
await generateObject({
116-
model: openai(...),
117-
schema: jsonSchema(schema),
118-
prompt: 'Analyze this review: "Great product, works perfectly!"',
119-
})
120-
```
121-
122130
## 🤔 "But what about Zod?"
123131

124132
Great question! Zod is a versatile and comprehensive library, spanning thousands of lines of code. However, it's not specifically built for generating JSON Schemas, which can lead to unexpected results during conversion. In contrast, JSON Schema Kit provides full control — all in under 100 lines of code.

0 commit comments

Comments
 (0)