421 lines
21 KiB
PHP
421 lines
21 KiB
PHP
<?php
|
|
|
|
use Illuminate\Support\Facades\Route;
|
|
|
|
Route::get('/api/docs', function () {
|
|
$spec = [
|
|
'openapi' => '3.0.0',
|
|
'info' => [
|
|
'title' => 'Veranstaltungen API',
|
|
'description' => 'REST API für Event Management System mit Locations und Occurrences',
|
|
'version' => '1.0.0',
|
|
'contact' => [
|
|
'name' => 'API Support',
|
|
'email' => 'support@veranstaltungen.de',
|
|
],
|
|
],
|
|
'servers' => [
|
|
[
|
|
'url' => config('app.url') ?: 'http://localhost:8000',
|
|
'description' => 'Development Server',
|
|
],
|
|
],
|
|
'paths' => [
|
|
'/api/events' => [
|
|
'get' => [
|
|
'summary' => 'Alle Events auflisten',
|
|
'description' => 'Listet alle veröffentlichten Events mit optionalen Filtern auf',
|
|
'tags' => ['Events'],
|
|
'parameters' => [
|
|
[
|
|
'name' => 'from',
|
|
'in' => 'query',
|
|
'description' => 'Startdatum (Format: YYYY-MM-DD)',
|
|
'required' => false,
|
|
'schema' => ['type' => 'string', 'format' => 'date'],
|
|
],
|
|
[
|
|
'name' => 'to',
|
|
'in' => 'query',
|
|
'description' => 'Enddatum (Format: YYYY-MM-DD)',
|
|
'required' => false,
|
|
'schema' => ['type' => 'string', 'format' => 'date'],
|
|
],
|
|
[
|
|
'name' => 'category',
|
|
'in' => 'query',
|
|
'description' => 'Filter nach Kategorie',
|
|
'required' => false,
|
|
'schema' => ['type' => 'string'],
|
|
],
|
|
[
|
|
'name' => 'location',
|
|
'in' => 'query',
|
|
'description' => 'Filter nach Stadt',
|
|
'required' => false,
|
|
'schema' => ['type' => 'string'],
|
|
],
|
|
[
|
|
'name' => 'limit',
|
|
'in' => 'query',
|
|
'description' => 'Anzahl der Ergebnisse (1-100, default: 20)',
|
|
'required' => false,
|
|
'schema' => ['type' => 'integer'],
|
|
],
|
|
],
|
|
'responses' => [
|
|
'200' => [
|
|
'description' => 'Erfolgreiche Abfrage',
|
|
'content' => [
|
|
'application/json' => [
|
|
'schema' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'data' => [
|
|
'type' => 'array',
|
|
'items' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'id' => ['type' => 'integer'],
|
|
'title' => ['type' => 'string'],
|
|
'description' => ['type' => 'string'],
|
|
'category' => ['type' => 'string'],
|
|
'location' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'id' => ['type' => 'integer'],
|
|
'name' => ['type' => 'string'],
|
|
'city' => ['type' => 'string'],
|
|
'full_address' => ['type' => 'string'],
|
|
],
|
|
],
|
|
'published' => ['type' => 'boolean'],
|
|
],
|
|
],
|
|
],
|
|
'meta' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'current_page' => ['type' => 'integer'],
|
|
'from' => ['type' => 'integer'],
|
|
'per_page' => ['type' => 'integer'],
|
|
'total' => ['type' => 'integer'],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
'400' => ['description' => 'Ungültige Anfrage'],
|
|
'500' => ['description' => 'Serverfehler'],
|
|
],
|
|
],
|
|
],
|
|
'/api/events/{id}' => [
|
|
'get' => [
|
|
'summary' => 'Single Event abrufen',
|
|
'description' => 'Ruft die Details eines einzelnen Events ab',
|
|
'tags' => ['Events'],
|
|
'parameters' => [
|
|
[
|
|
'name' => 'id',
|
|
'in' => 'path',
|
|
'description' => 'Event ID',
|
|
'required' => true,
|
|
'schema' => ['type' => 'integer'],
|
|
],
|
|
],
|
|
'responses' => [
|
|
'200' => [
|
|
'description' => 'Event gefunden',
|
|
'content' => [
|
|
'application/json' => [
|
|
'schema' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'id' => ['type' => 'integer'],
|
|
'title' => ['type' => 'string'],
|
|
'description' => ['type' => 'string'],
|
|
'category' => ['type' => 'string'],
|
|
'location' => ['type' => 'object'],
|
|
'occurrences' => ['type' => 'array'],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
'404' => ['description' => 'Event nicht gefunden'],
|
|
],
|
|
],
|
|
],
|
|
'/api/events/categories/list' => [
|
|
'get' => [
|
|
'summary' => 'Alle Kategorien auflisten',
|
|
'description' => 'Gibt eine Liste aller verfügbaren Kategorien zurück',
|
|
'tags' => ['Categories'],
|
|
'responses' => [
|
|
'200' => [
|
|
'description' => 'Liste der Kategorien',
|
|
'content' => [
|
|
'application/json' => [
|
|
'schema' => [
|
|
'type' => 'array',
|
|
'items' => ['type' => 'string'],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
'/api/events/locations/list' => [
|
|
'get' => [
|
|
'summary' => 'Alle Locations auflisten',
|
|
'description' => 'Gibt eine Liste aller verfügbaren Locations mit vollständiger Adresse zurück',
|
|
'tags' => ['Locations'],
|
|
'responses' => [
|
|
'200' => [
|
|
'description' => 'Liste der Locations',
|
|
'content' => [
|
|
'application/json' => [
|
|
'schema' => [
|
|
'type' => 'array',
|
|
'items' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'id' => ['type' => 'integer'],
|
|
'name' => ['type' => 'string'],
|
|
'street' => ['type' => 'string'],
|
|
'house_number' => ['type' => 'string'],
|
|
'postal_code' => ['type' => 'string'],
|
|
'city' => ['type' => 'string'],
|
|
'state' => ['type' => 'string'],
|
|
'country' => ['type' => 'string'],
|
|
'full_address' => ['type' => 'string'],
|
|
'phone' => ['type' => 'string'],
|
|
'email' => ['type' => 'string'],
|
|
'website' => ['type' => 'string'],
|
|
'events_count' => ['type' => 'integer'],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
];
|
|
return view('swagger', ['spec' => json_encode($spec)]);
|
|
})->name('api.docs');
|
|
|
|
Route::get('/api/docs/json', function () {
|
|
return response()->json([
|
|
'openapi' => '3.0.0',
|
|
'info' => [
|
|
'title' => 'Veranstaltungen API',
|
|
'description' => 'REST API für Event Management System mit Locations und Occurrences',
|
|
'version' => '1.0.0',
|
|
'contact' => [
|
|
'name' => 'API Support',
|
|
'email' => 'support@veranstaltungen.de',
|
|
],
|
|
],
|
|
'servers' => [
|
|
[
|
|
'url' => config('app.url') ?: 'http://localhost:8000',
|
|
'description' => 'Development Server',
|
|
],
|
|
],
|
|
'paths' => [
|
|
'/api/events' => [
|
|
'get' => [
|
|
'summary' => 'Alle Events auflisten',
|
|
'description' => 'Listet alle veröffentlichten Events mit optionalen Filtern auf',
|
|
'tags' => ['Events'],
|
|
'parameters' => [
|
|
[
|
|
'name' => 'from',
|
|
'in' => 'query',
|
|
'description' => 'Startdatum (Format: YYYY-MM-DD)',
|
|
'required' => false,
|
|
'schema' => ['type' => 'string', 'format' => 'date'],
|
|
],
|
|
[
|
|
'name' => 'to',
|
|
'in' => 'query',
|
|
'description' => 'Enddatum (Format: YYYY-MM-DD)',
|
|
'required' => false,
|
|
'schema' => ['type' => 'string', 'format' => 'date'],
|
|
],
|
|
[
|
|
'name' => 'category',
|
|
'in' => 'query',
|
|
'description' => 'Filter nach Kategorie',
|
|
'required' => false,
|
|
'schema' => ['type' => 'string'],
|
|
],
|
|
[
|
|
'name' => 'location',
|
|
'in' => 'query',
|
|
'description' => 'Filter nach Stadt',
|
|
'required' => false,
|
|
'schema' => ['type' => 'string'],
|
|
],
|
|
[
|
|
'name' => 'limit',
|
|
'in' => 'query',
|
|
'description' => 'Anzahl der Ergebnisse (1-100, default: 20)',
|
|
'required' => false,
|
|
'schema' => ['type' => 'integer'],
|
|
],
|
|
],
|
|
'responses' => [
|
|
'200' => [
|
|
'description' => 'Erfolgreiche Abfrage',
|
|
'content' => [
|
|
'application/json' => [
|
|
'schema' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'data' => [
|
|
'type' => 'array',
|
|
'items' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'id' => ['type' => 'integer'],
|
|
'title' => ['type' => 'string'],
|
|
'description' => ['type' => 'string'],
|
|
'category' => ['type' => 'string'],
|
|
'location' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'id' => ['type' => 'integer'],
|
|
'name' => ['type' => 'string'],
|
|
'city' => ['type' => 'string'],
|
|
'full_address' => ['type' => 'string'],
|
|
],
|
|
],
|
|
'published' => ['type' => 'boolean'],
|
|
],
|
|
],
|
|
],
|
|
'meta' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'current_page' => ['type' => 'integer'],
|
|
'from' => ['type' => 'integer'],
|
|
'per_page' => ['type' => 'integer'],
|
|
'total' => ['type' => 'integer'],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
'400' => ['description' => 'Ungültige Anfrage'],
|
|
'500' => ['description' => 'Serverfehler'],
|
|
],
|
|
],
|
|
],
|
|
'/api/events/{id}' => [
|
|
'get' => [
|
|
'summary' => 'Single Event abrufen',
|
|
'description' => 'Ruft die Details eines einzelnen Events ab',
|
|
'tags' => ['Events'],
|
|
'parameters' => [
|
|
[
|
|
'name' => 'id',
|
|
'in' => 'path',
|
|
'description' => 'Event ID',
|
|
'required' => true,
|
|
'schema' => ['type' => 'integer'],
|
|
],
|
|
],
|
|
'responses' => [
|
|
'200' => [
|
|
'description' => 'Event gefunden',
|
|
'content' => [
|
|
'application/json' => [
|
|
'schema' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'id' => ['type' => 'integer'],
|
|
'title' => ['type' => 'string'],
|
|
'description' => ['type' => 'string'],
|
|
'category' => ['type' => 'string'],
|
|
'location' => ['type' => 'object'],
|
|
'occurrences' => ['type' => 'array'],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
'404' => ['description' => 'Event nicht gefunden'],
|
|
],
|
|
],
|
|
],
|
|
'/api/events/categories/list' => [
|
|
'get' => [
|
|
'summary' => 'Alle Kategorien auflisten',
|
|
'description' => 'Gibt eine Liste aller verfügbaren Kategorien zurück',
|
|
'tags' => ['Categories'],
|
|
'responses' => [
|
|
'200' => [
|
|
'description' => 'Liste der Kategorien',
|
|
'content' => [
|
|
'application/json' => [
|
|
'schema' => [
|
|
'type' => 'array',
|
|
'items' => ['type' => 'string'],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
'/api/events/locations/list' => [
|
|
'get' => [
|
|
'summary' => 'Alle Locations auflisten',
|
|
'description' => 'Gibt eine Liste aller verfügbaren Locations mit vollständiger Adresse zurück',
|
|
'tags' => ['Locations'],
|
|
'responses' => [
|
|
'200' => [
|
|
'description' => 'Liste der Locations',
|
|
'content' => [
|
|
'application/json' => [
|
|
'schema' => [
|
|
'type' => 'array',
|
|
'items' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'id' => ['type' => 'integer'],
|
|
'name' => ['type' => 'string'],
|
|
'street' => ['type' => 'string'],
|
|
'house_number' => ['type' => 'string'],
|
|
'postal_code' => ['type' => 'string'],
|
|
'city' => ['type' => 'string'],
|
|
'state' => ['type' => 'string'],
|
|
'country' => ['type' => 'string'],
|
|
'full_address' => ['type' => 'string'],
|
|
'phone' => ['type' => 'string'],
|
|
'email' => ['type' => 'string'],
|
|
'website' => ['type' => 'string'],
|
|
'events_count' => ['type' => 'integer'],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
], 200, ['Content-Type' => 'application/json']);
|
|
})->name('api.docs.json');
|