All checks were successful
CI / PHP Lint (pull_request) Successful in 41s
CI / PHP Lint-1 (pull_request) Successful in 53s
CI / Unit Tests & Static Analysis (pull_request) Successful in 38s
CI / PHP Lint (push) Successful in 36s
CI / PHP Lint-1 (push) Successful in 42s
CI / Unit Tests & Static Analysis (push) Successful in 41s
Das Projekt nennt sich in composer.json und Readme MIT, der Lizenztext fehlte aber komplett - ohne ihn ist die Angabe wertlos. Dazu kamen die Bibliotheken unter assets/vendor/, die ihre Hinweise mitführen müssen (MIT und OFL verlangen den Copyright-Vermerk in jeder Kopie, CC BY 4.0 die Namensnennung). - LICENSE (MIT) im Wurzelverzeichnis - THIRD-PARTY-NOTICES.md mit Version, Copyright und Lizenz je Komponente - Vollständige Lizenztexte als LICENSE.txt bei Inter, Font Awesome, Chart.js und qrcodejs (TinyMCE brachte seine schon mit) - Readme: Abschnitt "Lizenz"; assets/vendor/README.md verweist auf die Lizenzdateien und erinnert daran, sie beim Update mit zu erneuern - Dockerfile mit OCI-Labels (u.a. image.licenses=MIT), .dockerignore nimmt die Hinweisdateien trotz *.md wieder auf - OpenAPI-Spezifikation nennt Lizenz und Kontakt TinyMCE 6.8.3 stand an drei Stellen als GPL-Variante, ist seit Version 6 aber MIT (siehe mitgelieferte license.txt). Korrigiert in der Vendor-Übersicht, im Sprachtext zum Editor und im Kommentar in admin/settings.php. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
79 lines
3.6 KiB
PHP
79 lines
3.6 KiB
PHP
<?php
|
|
/**
|
|
* OpenAPI 3.0 Spezifikation der REST-API (zum Import in Postman/Swagger).
|
|
* GET /api/openapi.php
|
|
*/
|
|
header('Content-Type: application/json; charset=utf-8');
|
|
|
|
$scheme = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
|
|
$host = $_SERVER['HTTP_HOST'] ?? 'localhost';
|
|
$base = $scheme . '://' . $host . rtrim(dirname($_SERVER['SCRIPT_NAME']), '/');
|
|
|
|
$spec = [
|
|
'openapi' => '3.0.3',
|
|
'info' => [
|
|
'title' => 'UniFi Voucher Tool API',
|
|
'version' => '1.0.0',
|
|
'description' => 'REST-API zum Erstellen und Abrufen von WLAN-Vouchers. Authentifizierung per API-Schlüssel (Authorization: Bearer … oder X-API-Key).',
|
|
'license' => ['name' => 'MIT', 'url' => 'https://git.loheide.cloud/friloo/Unifi-Voucher-Tool/src/branch/main/LICENSE'],
|
|
'contact' => ['name' => 'Loheide.eu', 'url' => 'https://loheide.eu'],
|
|
],
|
|
'servers' => [['url' => $base]],
|
|
'components' => [
|
|
'securitySchemes' => [
|
|
'bearerAuth' => ['type' => 'http', 'scheme' => 'bearer'],
|
|
'apiKeyAuth' => ['type' => 'apiKey', 'in' => 'header', 'name' => 'X-API-Key'],
|
|
],
|
|
],
|
|
'security' => [['bearerAuth' => []], ['apiKeyAuth' => []]],
|
|
'paths' => [
|
|
'/sites.php' => [
|
|
'get' => [
|
|
'summary' => 'Aktive Sites auflisten',
|
|
'description' => 'Erfordert Scope read.',
|
|
'responses' => ['200' => ['description' => 'Liste der Sites']],
|
|
],
|
|
],
|
|
'/vouchers.php' => [
|
|
'get' => [
|
|
'summary' => 'Voucher einer Site auflisten',
|
|
'description' => 'Erfordert Scope read.',
|
|
'parameters' => [[
|
|
'name' => 'site_id', 'in' => 'query', 'required' => true,
|
|
'schema' => ['type' => 'integer'],
|
|
]],
|
|
'responses' => ['200' => ['description' => 'Liste der Voucher']],
|
|
],
|
|
'post' => [
|
|
'summary' => 'Voucher erstellen',
|
|
'description' => 'Erfordert Scope write.',
|
|
'requestBody' => [
|
|
'required' => true,
|
|
'content' => ['application/json' => ['schema' => [
|
|
'type' => 'object',
|
|
'required' => ['site_id', 'name'],
|
|
'properties' => [
|
|
'site_id' => ['type' => 'integer'],
|
|
'name' => ['type' => 'string'],
|
|
'max_uses' => ['type' => 'integer', 'default' => 1],
|
|
'expire_minutes' => ['type' => 'integer', 'default' => 480],
|
|
'qos' => ['type' => 'object', 'properties' => [
|
|
'down' => ['type' => 'integer', 'description' => 'Download kbit/s'],
|
|
'up' => ['type' => 'integer', 'description' => 'Upload kbit/s'],
|
|
'quota_mb' => ['type' => 'integer', 'description' => 'Datenkontingent MB'],
|
|
]],
|
|
],
|
|
]]],
|
|
],
|
|
'responses' => [
|
|
'201' => ['description' => 'Voucher erstellt'],
|
|
'401' => ['description' => 'Nicht authentifiziert'],
|
|
'403' => ['description' => 'Fehlender Scope'],
|
|
'429' => ['description' => 'Rate-Limit überschritten'],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
];
|
|
|
|
echo json_encode($spec, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);
|