Update API Doc

This commit is contained in:
Rudi committed 2026-10-13 19:26:56 +02:00
1 parent 5d6d8f15f3
commit 5a56245218
10 files changed
+1196 -229

No files matched your search

+66 -9
View File
@@ -1,3 +1,5 @@
// @/app/api/songs/[songId]/route.ts
import { NextResponse } from "next/server";
import { getSongById, updateSong, deleteSong } from "@/lib/db/song";
@@ -9,27 +11,44 @@ interface RouteParams {
/**
* @openapi
* /api/songs/{id}:
* /api/songs/{songId}:
* get:
* summary: Einzelnen Song abrufen
* tags:
* - Songs
* parameters:
* - in: path
* name: id
* name: songId
* required: true
* schema:
* type: integer
* description: Die ID des Songs
* example: 1
* responses:
* 200:
* description: Song erfolgreich gefunden
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/Song'
* 400:
* description: Ungültige Song-ID
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/Error'
* 404:
* description: Song nicht gefunden
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/Error'
* 500:
* description: Serverfehler
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/Error'
*/
export async function GET(_request: Request, { params }: RouteParams) {
try {
@@ -53,33 +72,54 @@ export async function GET(_request: Request, { params }: RouteParams) {
/**
* @openapi
* /api/songs/{id}:
* /api/songs/{songId}:
* patch:
* summary: Song aktualisieren
* tags:
* - Songs
* parameters:
* - in: path
* name: id
* name: songId
* required: true
* schema:
* type: integer
* description: Die ID des Songs
* example: 1
* requestBody:
* required: true
* content:
* application/json:
* schema:
* type: object
* properties:
* title:
* type: string
* example: "Großer Gott"
* responses:
* 200:
* description: Song erfolgreich aktualisiert
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/Song'
* 400:
* description: Ungültige Parameter oder Daten
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/Error'
* 404:
* description: Song nicht gefunden
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/Error'
* 500:
* description: Serverfehler
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/Error'
*/
export async function PATCH(request: Request, { params }: RouteParams) {
try {
@@ -95,7 +135,7 @@ export async function PATCH(request: Request, { params }: RouteParams) {
} catch (error) {
console.error("API Error:", error);
return NextResponse.json(
{ error: "Fehler beim Laden der Songinfos" },
{ error: "Fehler beim Aktualisieren des Songs" },
{ status: 500 }
);
}
@@ -104,27 +144,44 @@ export async function PATCH(request: Request, { params }: RouteParams) {
/**
* @openapi
* /api/songs/{id}:
* /api/songs/{songId}:
* delete:
* summary: Song löschen
* tags:
* - Songs
* parameters:
* - in: path
* name: id
* name: songId
* required: true
* schema:
* type: integer
* description: Die ID des Songs
* example: 1
* responses:
* 200:
* description: Song erfolgreich gelöscht
* description: Song erfolgreich gelöscht (gibt den gelöschten Song zurück)
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/Song'
* 400:
* description: Ungültige Song-ID
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/Error'
* 404:
* description: Song nicht gefunden
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/Error'
* 500:
* description: Serverfehler
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/Error'
*/
export async function DELETE(_request: Request, { params }: RouteParams) {
try {
@@ -139,7 +196,7 @@ export async function DELETE(_request: Request, { params }: RouteParams) {
} catch (error) {
console.error("API Error:", error);
return NextResponse.json(
{ error: "Fehler beim Laden der Songinfos" },
{ error: "Fehler beim Löschen des Songs" },
{ status: 500 }
);
}