94 lines
2.2 KiB
TypeScript
94 lines
2.2 KiB
TypeScript
import { OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
|
|
import { EventResponseSchema, updateEventSchema } from '../validation';
|
|
import {
|
|
invalidRequestDataResponse,
|
|
notAuthenticatedResponse,
|
|
serverReturnedDataValidationErrorResponse,
|
|
userNotFoundResponse,
|
|
} from '@/lib/defaultApiResponses';
|
|
import {
|
|
EventIdParamSchema,
|
|
SuccessResponseSchema,
|
|
} from '@/app/api/validation';
|
|
import zod from 'zod/v4';
|
|
|
|
export default function registerSwaggerPaths(registry: OpenAPIRegistry) {
|
|
registry.registerPath({
|
|
method: 'get',
|
|
path: '/event/{eventID}',
|
|
request: {
|
|
params: zod.object({
|
|
eventID: EventIdParamSchema,
|
|
}),
|
|
},
|
|
responses: {
|
|
200: {
|
|
description: 'Event retrieved successfully',
|
|
content: {
|
|
'application/json': {
|
|
schema: EventResponseSchema,
|
|
},
|
|
},
|
|
},
|
|
...userNotFoundResponse,
|
|
...serverReturnedDataValidationErrorResponse,
|
|
},
|
|
tags: ['Event'],
|
|
});
|
|
|
|
registry.registerPath({
|
|
method: 'delete',
|
|
path: '/event/{eventID}',
|
|
request: {
|
|
params: zod.object({
|
|
eventID: EventIdParamSchema,
|
|
}),
|
|
},
|
|
responses: {
|
|
200: {
|
|
description: 'Event deleted successfully',
|
|
content: {
|
|
'application/json': {
|
|
schema: SuccessResponseSchema,
|
|
},
|
|
},
|
|
},
|
|
...notAuthenticatedResponse,
|
|
...userNotFoundResponse,
|
|
...serverReturnedDataValidationErrorResponse,
|
|
},
|
|
tags: ['Event'],
|
|
});
|
|
|
|
registry.registerPath({
|
|
method: 'patch',
|
|
path: '/event/{eventID}',
|
|
request: {
|
|
params: zod.object({
|
|
eventID: EventIdParamSchema,
|
|
}),
|
|
body: {
|
|
content: {
|
|
'application/json': {
|
|
schema: updateEventSchema,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
responses: {
|
|
200: {
|
|
description: 'Event updated successfully',
|
|
content: {
|
|
'application/json': {
|
|
schema: EventResponseSchema,
|
|
},
|
|
},
|
|
},
|
|
...invalidRequestDataResponse,
|
|
...notAuthenticatedResponse,
|
|
...userNotFoundResponse,
|
|
...serverReturnedDataValidationErrorResponse,
|
|
},
|
|
tags: ['Event'],
|
|
});
|
|
}
|