You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/blog/elysia-14.md
+16-15Lines changed: 16 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,11 +10,11 @@ head:
10
10
11
11
- - meta
12
12
- name: 'description'
13
-
content: Support for Standard Validator. Macro with schema, extension, and OpenAPI detail. Lifecycle type soundness. Improve type inference performance by 10%.
13
+
content: Support for Standard Schema. Macro with schema, extension, and OpenAPI detail. Lifecycle type soundness. Improves type inference performance by 10%.
14
14
15
15
- - meta
16
16
- property: 'og:description'
17
-
content: Support for Standard Validator. Macro with schema, extension, and OpenAPI detail. Lifecycle type soundness. Improve type inference performance by 10%.
17
+
content: Support for Standard Schema. Macro with schema, extension, and OpenAPI detail. Lifecycle type soundness. Improves type inference performance by 10%.
18
18
19
19
- - meta
20
20
- property: 'og:image'
@@ -111,12 +111,12 @@ This allows you to have beautiful OpenAPI documentation with your favorite valid
111
111

112
112
> Using Zod native OpenAPI schema support with **describe** to add description to the schema
113
113
114
-
But if your validator does not support JSON Schema, we provide our unique [OpenAPI type gen](/blog/openapi-type-gen.html) to generate OpenAPI schema directly from TypeScript type from your validator.
114
+
But if your validator does not support JSON Schema, we provide [OpenAPI type gen](/blog/openapi-type-gen.html) to generate OpenAPI schema directly from TypeScript type from your validator.
115
115
116
116
This means that Elysia supports OpenAPI generation for all validators that support Standard Schema, even if they don't directly support JSON Schema.
117
117
118
118

119
-
> Valibot doesn't directly support JSON Schema, but we OpenAPI type gen to handle it
119
+
> Valibot doesn't directly support JSON Schema, but we use OpenAPI type gen to handle it
120
120
121
121
Not only will it generate the correct input type, but OpenAPI type gen will also generate all possible output types, including error responses.
122
122
@@ -138,26 +138,27 @@ const app = new Elysia()
138
138
id: z.coerce.number()
139
139
})
140
140
})
141
-
.post(
142
-
'/user/:id',
143
-
({ body }) =>body,
141
+
.post(
142
+
'/user/:id',
143
+
({ body }) =>body,
144
144
// ^?
145
145
146
146
147
147
148
148
149
-
{
150
-
body: v.object({
151
-
name: v.literal('lilith')
152
-
})
153
-
})
149
+
{
150
+
body: v.object({
151
+
name: v.literal('lilith')
152
+
})
153
+
}
154
+
)
154
155
```
155
156
> This example uses both Zod and Valibot to validate the body, allowing you to use existing schemas in your codebase from different validators together.
156
157
157
158
This works by using each validator to parse a part of the input, then storing each result as a snapshot that merges together to form a single output, ensuring type integrity.
158
159
159
160

160
-
> Using TypeBox, Zod, Valibot, Joi, Yup, ArkType, Effect Schema, TypeMap, and Rescript Schema to validate different parts of the body
161
+
> Using TypeBox, Zod, Valibot, Joi, Yup, ArkType, Effect Schema, TypeMap, and ReScript Schema to validate different parts of the body
161
162
162
163
We tested 8 validators at the same time, validating each part of the input, and it just works flawlessly.
163
164
@@ -229,7 +230,7 @@ Not only does this improve the developer experience, but it also improves the re
229
230
230
231
> Type Soundness covers all lifecycle events and macros, allowing you to have complete documentation of your API. The only exception is an inline lifecycle event due to slowness.
231
232
232
-
We also managed to improve type inference performance by a factor of ~9-11% and decrease type instantiation by 11.5%, despite the massive increase in type complexity.
233
+
We also managed to improve type inference performance by ~9-11% and decrease type instantiation by 11.5%, despite the massive increase in type complexity.
0 commit comments