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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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