refactor(api): standardize Swagger documentation
Some checks failed
container-scan / Container Scan (pull_request) Failing after 1m29s
docker-build / docker (pull_request) Has been cancelled

This commit is contained in:
Dominik 2025-06-17 22:11:22 +02:00
parent 476114ca87
commit ce834dfc99
Signed by: dominik
GPG key ID: 06A4003FC5049644
7 changed files with 287 additions and 302 deletions

View file

@ -39,13 +39,13 @@ export const patchParticipantSchema = z.object({
* success: * success:
* type: boolean * type: boolean
* participant: * participant:
* $ref: '#/components/schemas/Participant' * $ref: "#/components/schemas/Participant"
* 401: * 401:
* description: Not authenticated. * description: Not authenticated.
* content: * content:
* application/json: * application/json:
* schema: * schema:
* $ref: '#/components/schemas/ErrorResponse' * $ref: "#/components/schemas/ErrorResponse"
* example: * example:
* success: false * success: false
* message: Not authenticated * message: Not authenticated
@ -54,7 +54,7 @@ export const patchParticipantSchema = z.object({
* content: * content:
* application/json: * application/json:
* schema: * schema:
* $ref: '#/components/schemas/ErrorResponse' * $ref: "#/components/schemas/ErrorResponse"
* example: * example:
* success: false * success: false
* message: User not found * message: User not found
@ -63,7 +63,7 @@ export const patchParticipantSchema = z.object({
* content: * content:
* application/json: * application/json:
* schema: * schema:
* $ref: '#/components/schemas/ErrorResponse' * $ref: "#/components/schemas/ErrorResponse"
* example: * example:
* success: false * success: false
* message: User is not a participant or organizer of this event * message: User is not a participant or organizer of this event
@ -189,7 +189,7 @@ export const GET = auth(async (req, { params }) => {
* content: * content:
* application/json: * application/json:
* schema: * schema:
* $ref: '#/components/schemas/ErrorResponse' * $ref: "#/components/schemas/ErrorResponse"
* example: * example:
* success: false * success: false
* message: Not authenticated * message: Not authenticated
@ -198,7 +198,7 @@ export const GET = auth(async (req, { params }) => {
* content: * content:
* application/json: * application/json:
* schema: * schema:
* $ref: '#/components/schemas/ErrorResponse' * $ref: "#/components/schemas/ErrorResponse"
* example: * example:
* success: false * success: false
* message: User not found * message: User not found
@ -207,7 +207,7 @@ export const GET = auth(async (req, { params }) => {
* content: * content:
* application/json: * application/json:
* schema: * schema:
* $ref: '#/components/schemas/ErrorResponse' * $ref: "#/components/schemas/ErrorResponse"
* example: * example:
* success: false * success: false
* message: Only organizer can remove participants * message: Only organizer can remove participants
@ -328,22 +328,19 @@ export const DELETE = auth(async (req, { params }) => {
* success: * success:
* type: boolean * type: boolean
* participant: * participant:
* $ref: '#/components/schemas/Participant' * $ref: "#/components/schemas/Participant"
* 400: * 400:
* description: Bad request due to invalid input data. * description: Invalid request data.
* content: * content:
* application/json: * application/json:
* schema: * schema:
* $ref: '#/components/schemas/ErrorResponse' * $ref: "#/components/schemas/ZodErrorResponse"
* example:
* success: false
* message: 'Invalid input data'
* 401: * 401:
* description: Not authenticated. * description: Not authenticated.
* content: * content:
* application/json: * application/json:
* schema: * schema:
* $ref: '#/components/schemas/ErrorResponse' * $ref: "#/components/schemas/ErrorResponse"
* example: * example:
* success: false * success: false
* message: Not authenticated * message: Not authenticated
@ -352,7 +349,7 @@ export const DELETE = auth(async (req, { params }) => {
* content: * content:
* application/json: * application/json:
* schema: * schema:
* $ref: '#/components/schemas/ErrorResponse' * $ref: "#/components/schemas/ErrorResponse"
* example: * example:
* success: false * success: false
* message: User not found * message: User not found
@ -361,7 +358,7 @@ export const DELETE = auth(async (req, { params }) => {
* content: * content:
* application/json: * application/json:
* schema: * schema:
* $ref: '#/components/schemas/ErrorResponse' * $ref: "#/components/schemas/ErrorResponse"
* example: * example:
* success: false * success: false
* message: Only participant can update their status * message: Only participant can update their status

View file

@ -36,13 +36,13 @@ export const postParticipantSchema = z.object({
* participants: * participants:
* type: array * type: array
* items: * items:
* $ref: '#/components/schemas/Participant' * $ref: "#/components/schemas/Participant"
* 401: * 401:
* description: Not authenticated. * description: Not authenticated.
* content: * content:
* application/json: * application/json:
* schema: * schema:
* $ref: '#/components/schemas/ErrorResponse' * $ref: "#/components/schemas/ErrorResponse"
* example: * example:
* success: false * success: false
* message: Not authenticated * message: Not authenticated
@ -51,7 +51,7 @@ export const postParticipantSchema = z.object({
* content: * content:
* application/json: * application/json:
* schema: * schema:
* $ref: '#/components/schemas/ErrorResponse' * $ref: "#/components/schemas/ErrorResponse"
* example: * example:
* success: false * success: false
* message: User not found * message: User not found
@ -60,7 +60,7 @@ export const postParticipantSchema = z.object({
* content: * content:
* application/json: * application/json:
* schema: * schema:
* $ref: '#/components/schemas/ErrorResponse' * $ref: "#/components/schemas/ErrorResponse"
* example: * example:
* success: false * success: false
* message: User is not a participant or organizer of this event * message: User is not a participant or organizer of this event
@ -173,22 +173,19 @@ export const GET = auth(async (req, { params }) => {
* success: * success:
* type: boolean * type: boolean
* participant: * participant:
* $ref: '#/components/schemas/Participant' * $ref: "#/components/schemas/Participant"
* 400: * 400:
* description: Bad request due to invalid input data. * description: Invalid request data.
* content: * content:
* application/json: * application/json:
* schema: * schema:
* $ref: '#/components/schemas/ErrorResponse' * $ref: "#/components/schemas/ZodErrorResponse"
* example:
* success: false
* message: 'Invalid input data'
* 401: * 401:
* description: Not authenticated. * description: Not authenticated.
* content: * content:
* application/json: * application/json:
* schema: * schema:
* $ref: '#/components/schemas/ErrorResponse' * $ref: "#/components/schemas/ErrorResponse"
* example: * example:
* success: false * success: false
* message: Not authenticated * message: Not authenticated
@ -197,7 +194,7 @@ export const GET = auth(async (req, { params }) => {
* content: * content:
* application/json: * application/json:
* schema: * schema:
* $ref: '#/components/schemas/ErrorResponse' * $ref: "#/components/schemas/ErrorResponse"
* example: * example:
* success: false * success: false
* message: User not found * message: User not found
@ -206,7 +203,7 @@ export const GET = auth(async (req, { params }) => {
* content: * content:
* application/json: * application/json:
* schema: * schema:
* $ref: '#/components/schemas/ErrorResponse' * $ref: "#/components/schemas/ErrorResponse"
* example: * example:
* success: false * success: false
* message: Only organizers can add participants * message: Only organizers can add participants
@ -215,7 +212,7 @@ export const GET = auth(async (req, { params }) => {
* content: * content:
* application/json: * application/json:
* schema: * schema:
* $ref: '#/components/schemas/ErrorResponse' * $ref: "#/components/schemas/ErrorResponse"
* example: * example:
* success: false * success: false
* message: User is already a participant of this event * message: User is already a participant of this event

View file

@ -38,13 +38,13 @@ export const patchEventSchema = z.object({
* success: * success:
* type: boolean * type: boolean
* event: * event:
* $ref: '#/components/schemas/Event' * $ref: "#/components/schemas/Event"
* 401: * 401:
* description: Not authenticated. * description: Not authenticated.
* content: * content:
* application/json: * application/json:
* schema: * schema:
* $ref: '#/components/schemas/ErrorResponse' * $ref: "#/components/schemas/ErrorResponse"
* example: * example:
* success: false * success: false
* message: Not authenticated * message: Not authenticated
@ -53,7 +53,7 @@ export const patchEventSchema = z.object({
* content: * content:
* application/json: * application/json:
* schema: * schema:
* $ref: '#/components/schemas/ErrorResponse' * $ref: "#/components/schemas/ErrorResponse"
*/ */
export const GET = auth(async (req, { params }) => { export const GET = auth(async (req, { params }) => {
if (!req.auth) if (!req.auth)
@ -165,7 +165,7 @@ export const GET = auth(async (req, { params }) => {
* content: * content:
* application/json: * application/json:
* schema: * schema:
* $ref: '#/components/schemas/ErrorResponse' * $ref: "#/components/schemas/ErrorResponse"
* example: * example:
* success: false * success: false
* message: Not authenticated * message: Not authenticated
@ -174,7 +174,7 @@ export const GET = auth(async (req, { params }) => {
* content: * content:
* application/json: * application/json:
* schema: * schema:
* $ref: '#/components/schemas/ErrorResponse' * $ref: "#/components/schemas/ErrorResponse"
* example: * example:
* success: false * success: false
* message: You are not the organizer of this event * message: You are not the organizer of this event
@ -183,7 +183,7 @@ export const GET = auth(async (req, { params }) => {
* content: * content:
* application/json: * application/json:
* schema: * schema:
* $ref: '#/components/schemas/ErrorResponse' * $ref: "#/components/schemas/ErrorResponse"
*/ */
export const DELETE = auth(async (req, { params }) => { export const DELETE = auth(async (req, { params }) => {
if (!req.auth) if (!req.auth)
@ -292,22 +292,19 @@ export const DELETE = auth(async (req, { params }) => {
* success: * success:
* type: boolean * type: boolean
* event: * event:
* $ref: '#/components/schemas/Event' * $ref: "#/components/schemas/Event"
* 400: * 400:
* description: Bad request due to invalid input data. * description: Invalid request data.
* content: * content:
* application/json: * application/json:
* schema: * schema:
* $ref: '#/components/schemas/ErrorResponse' * $ref: "#/components/schemas/ZodErrorResponse"
* example:
* success: false
* message: 'Invalid input data'
* 401: * 401:
* description: Not authenticated. * description: Not authenticated.
* content: * content:
* application/json: * application/json:
* schema: * schema:
* $ref: '#/components/schemas/ErrorResponse' * $ref: "#/components/schemas/ErrorResponse"
* example: * example:
* success: false * success: false
* message: Not authenticated * message: Not authenticated
@ -316,7 +313,7 @@ export const DELETE = auth(async (req, { params }) => {
* content: * content:
* application/json: * application/json:
* schema: * schema:
* $ref: '#/components/schemas/ErrorResponse' * $ref: "#/components/schemas/ErrorResponse"
* example: * example:
* success: false * success: false
* message: You are not the organizer of this event * message: You are not the organizer of this event
@ -325,7 +322,7 @@ export const DELETE = auth(async (req, { params }) => {
* content: * content:
* application/json: * application/json:
* schema: * schema:
* $ref: '#/components/schemas/ErrorResponse' * $ref: "#/components/schemas/ErrorResponse"
* example: * example:
* success: false * success: false
* message: User or event not found * message: User or event not found

View file

@ -36,13 +36,13 @@ export const postEventSchema = z
* events: * events:
* type: array * type: array
* items: * items:
* $ref: '#/components/schemas/Event' * $ref: "#/components/schemas/Event"
* 401: * 401:
* description: Not authenticated. * description: Not authenticated.
* content: * content:
* application/json: * application/json:
* schema: * schema:
* $ref: '#/components/schemas/ErrorResponse' * $ref: "#/components/schemas/ErrorResponse"
* example: * example:
* success: false * success: false
* message: Not authenticated * message: Not authenticated
@ -51,7 +51,7 @@ export const postEventSchema = z
* content: * content:
* application/json: * application/json:
* schema: * schema:
* $ref: '#/components/schemas/ErrorResponse' * $ref: "#/components/schemas/ErrorResponse"
* example: * example:
* success: false * success: false
* message: User not found * message: User not found
@ -165,22 +165,19 @@ export const GET = auth(async (req) => {
* success: * success:
* type: boolean * type: boolean
* event: * event:
* $ref: '#/components/schemas/Event' * $ref: "#/components/schemas/Event"
* 400: * 400:
* description: Bad request due to invalid input data. * description: Invalid request data.
* content: * content:
* application/json: * application/json:
* schema: * schema:
* $ref: '#/components/schemas/ErrorResponse' * $ref: "#/components/schemas/ZodErrorResponse"
* example:
* success: false
* message: 'Invalid input data'
* 401: * 401:
* description: Not authenticated. * description: Not authenticated.
* content: * content:
* application/json: * application/json:
* schema: * schema:
* $ref: '#/components/schemas/ErrorResponse' * $ref: "#/components/schemas/ErrorResponse"
* example: * example:
* success: false * success: false
* message: Not authenticated * message: Not authenticated
@ -189,7 +186,7 @@ export const GET = auth(async (req) => {
* content: * content:
* application/json: * application/json:
* schema: * schema:
* $ref: '#/components/schemas/ErrorResponse' * $ref: "#/components/schemas/ErrorResponse"
* example: * example:
* success: false * success: false
* message: User not found * message: User not found

View file

@ -46,14 +46,14 @@ export const getSearchUserSchema = z.object({
* required: false * required: false
* schema: * schema:
* type: string * type: string
* enum: ['created_at', 'name', 'first_name', 'last_name', 'id'] * enum: ["created_at", "name", "first_name", "last_name", "id"]
* description: The field to sort by (default is 'created_at'). * description: The field to sort by (default is 'created_at').
* - in: query * - in: query
* name: sort_order * name: sort_order
* required: false * required: false
* schema: * schema:
* type: string * type: string
* enum: ['asc', 'desc'] * enum: ["asc", "desc"]
* description: The order to sort by, either 'asc' or 'desc' (default is 'desc'). * description: The order to sort by, either 'asc' or 'desc' (default is 'desc').
* responses: * responses:
* 200: * 200:
@ -68,7 +68,7 @@ export const getSearchUserSchema = z.object({
* users: * users:
* type: array * type: array
* items: * items:
* $ref: '#/components/schemas/PublicUser' * $ref: "#/components/schemas/PublicUser"
* count: * count:
* type: integer * type: integer
* description: The number of users returned. * description: The number of users returned.
@ -77,25 +77,25 @@ export const getSearchUserSchema = z.object({
* content: * content:
* application/json: * application/json:
* schema: * schema:
* $ref: '#/components/schemas/ZodErrorResponse' * $ref: "#/components/schemas/ZodErrorResponse"
* 401: * 401:
* description: User is not authenticated. * description: User is not authenticated.
* content: * content:
* application/json: * application/json:
* schema: * schema:
* $ref: '#/components/schemas/ErrorResponse' * $ref: "#/components/schemas/ErrorResponse"
* example: * example:
* success: false * success: false
* message: 'Not authenticated' * message: "Not authenticated"
* 404: * 404:
* description: User not found. * description: User not found.
* content: * content:
* application/json: * application/json:
* schema: * schema:
* $ref: '#/components/schemas/ErrorResponse' * $ref: "#/components/schemas/ErrorResponse"
* example: * example:
* success: false * success: false
* message: 'User not found' * message: "User not found"
*/ */
export const GET = auth(async function GET(req) { export const GET = auth(async function GET(req) {
if (!req.auth) if (!req.auth)

View file

@ -23,31 +23,31 @@ import { prisma } from '@/prisma';
* content: * content:
* application/json: * application/json:
* schema: * schema:
* type: 'object' * type: "object"
* properties: * properties:
* success: * success:
* type: 'boolean' * type: "boolean"
* default: true * default: true
* user: * user:
* $ref: '#/components/schemas/PublicUser' * $ref: "#/components/schemas/PublicUser"
* 401: * 401:
* description: User is not authenticated. * description: User is not authenticated.
* content: * content:
* application/json: * application/json:
* schema: * schema:
* $ref: '#/components/schemas/ErrorResponse' * $ref: "#/components/schemas/ErrorResponse"
* example: * example:
* success: false * success: false
* message: 'Not authenticated' * message: "Not authenticated"
* 404: * 404:
* description: User not found. * description: User not found.
* content: * content:
* application/json: * application/json:
* schema: * schema:
* $ref: '#/components/schemas/ErrorResponse' * $ref: "#/components/schemas/ErrorResponse"
* example: * example:
* success: false * success: false
* message: 'User not found' * message: "User not found"
*/ */
export const GET = auth(async function GET(req, { params }) { export const GET = auth(async function GET(req, { params }) {
if (!req.auth) if (!req.auth)

View file

@ -38,25 +38,25 @@ export const patchUserMeSchema = z.object({
* type: boolean * type: boolean
* default: true * default: true
* user: * user:
* $ref: '#/components/schemas/User' * $ref: "#/components/schemas/User"
* 401: * 401:
* description: User is not authenticated. * description: User is not authenticated.
* content: * content:
* application/json: * application/json:
* schema: * schema:
* $ref: '#/components/schemas/ErrorResponse' * $ref: "#/components/schemas/ErrorResponse"
* example: * example:
* success: false * success: false
* message: 'Not authenticated' * message: "Not authenticated"
* 404: * 404:
* description: User not found. * description: User not found.
* content: * content:
* application/json: * application/json:
* schema: * schema:
* $ref: '#/components/schemas/ErrorResponse' * $ref: "#/components/schemas/ErrorResponse"
* example: * example:
* success: false * success: false
* message: 'User not found' * message: "User not found"
*/ */
export const GET = auth(async function GET(req) { export const GET = auth(async function GET(req) {
if (!req.auth) if (!req.auth)
@ -148,34 +148,31 @@ export const GET = auth(async function GET(req) {
* type: boolean * type: boolean
* default: true * default: true
* user: * user:
* $ref: '#/components/schemas/User' * $ref: "#/components/schemas/User"
* 401: * 401:
* description: User is not authenticated. * description: User is not authenticated.
* content: * content:
* application/json: * application/json:
* schema: * schema:
* $ref: '#/components/schemas/ErrorResponse' * $ref: "#/components/schemas/ErrorResponse"
* example: * example:
* success: false * success: false
* message: 'Not authenticated' * message: "Not authenticated"
* 404: * 404:
* description: User not found. * description: User not found.
* content: * content:
* application/json: * application/json:
* schema: * schema:
* $ref: '#/components/schemas/ErrorResponse' * $ref: "#/components/schemas/ErrorResponse"
* example: * example:
* success: false * success: false
* message: 'User not found' * message: "User not found"
* 400: * 400:
* description: Bad request due to invalid input data. * description: Invalid request data.
* content: * content:
* application/json: * application/json:
* schema: * schema:
* $ref: '#/components/schemas/ErrorResponse' * $ref: "#/components/schemas/ZodErrorResponse"
* example:
* success: false
* message: 'Invalid input data'
*/ */
export const PATCH = auth(async function PATCH(req) { export const PATCH = auth(async function PATCH(req) {
if (!req.auth) if (!req.auth)