feat: add schema examples

This commit is contained in:
hgpark
2024-03-22 12:30:11 +09:00
parent 1348638cf8
commit dfb41bdc08

View File

@@ -44,7 +44,7 @@ export const plugin = new Elysia({
})
.post(
'/json/:id',
({ body, params: { id }, query: { name } }) => ({
({ body, params: { id }, query: { name, email, } }) => ({
...body,
id
}),
@@ -53,6 +53,22 @@ export const plugin = new Elysia({
params: t.Object({
id: t.Numeric()
}),
query: t.Object({
name: t.String(),
email: t.String({
description: 'sample email description',
format: 'email',
examples: ['test@test.com']
}),
birthday: t.String({
description: 'sample birthday description',
pattern: '\\d{4}-\\d{2}-\\d{2}',
minLength: 10,
maxLength: 10,
examples: ['2024-01-01']
}),
gender: t.Union([t.Literal('M'), t.Literal('F')])
}),
response: {
200: t.Object(
{