feat(schema): add version schema

This commit is contained in:
Lars Hampe 2024-10-09 12:43:44 +02:00
parent e45d498f56
commit 14f39f47c7
7 changed files with 83 additions and 0 deletions

View File

@ -1,3 +1,4 @@
export * from './general'
export * from './user'
export * from './changelog'
export * from './version'

View File

@ -0,0 +1,24 @@
import { z } from '@hono/zod-openapi'
export const VersionOutput = z
.object({
id: z.string().uuid().openapi({
example: '9f00f912-f687-42ef-84d7-efde48ca11ef',
}),
changelogId: z.string().uuid().openapi({
example: '8f00f912-f687-42ef-84d7-efde48ca11ef',
}),
version: z.string().openapi({
example: '1.0.0',
}),
markdown: z.string().openapi({
example: '### Changelog\n\n- Added a new feature',
}),
releasedAt: z.date().optional().openapi({
example: '2024-01-01T00:00:00.000Z',
}),
status: z.enum(['draft', 'review', 'published']).default('draft').openapi({
example: 'draft',
}),
})
.openapi('Version')

View File

@ -0,0 +1,14 @@
import { z } from '@hono/zod-openapi'
export const VersionByIdParams = z.object({
id: z
.string()
.uuid()
.openapi({
param: {
name: 'id',
in: 'path',
},
example: 'a5ed5965-0506-44e6-aaec-0465ff9fe092',
}),
})

View File

@ -0,0 +1,15 @@
import { z } from '@hono/zod-openapi'
import { VersionOutput } from './base'
export const VersionCreateOutput = VersionOutput
export const VersionCreateInput = z
.object({
changelogId: z.string().uuid(),
version: z.string(),
releasedAt: z.date().or(z.string()).optional(),
status: z.enum(['draft', 'review', 'published']).default('draft'),
markdown: z.string(),
})
.openapi({
required: ['changelogId', 'version', 'markdown', 'releasedAt'],
})

View File

@ -0,0 +1,5 @@
export * from './base'
export * from './byId'
export * from './create'
export * from './list'
export * from './update'

View File

@ -0,0 +1,4 @@
import { z } from '@hono/zod-openapi'
import { VersionOutput } from './base'
export const VersionListOutput = z.array(VersionOutput)

View File

@ -0,0 +1,20 @@
import { z } from '@hono/zod-openapi'
import { VersionOutput } from './base'
export const VersionUpdateOutput = VersionOutput
export const VersionUpdateInput = z
.object({
markdown: z.string().optional(),
status: z
.enum(['draft', 'review', 'published'])
.default('draft')
.optional(),
})
.openapi({})
export const VersionUpdateParams = z
.object({
id: z.string().uuid(),
})
.openapi({
required: ['id'],
})