added self for nameservers for openApi defaults.

This commit is contained in:
tracer 2024-04-30 19:33:07 +02:00
parent d31ee8bdec
commit 753e96ed85
5 changed files with 38 additions and 30 deletions

6
TODO
View File

@ -1,6 +1,8 @@
Cron on all 4 ns.
BUG, NS$: No nameserver marked as this server.
BUG, NS1: Only one nameserver is designated as our host OK, but all are …
panels:apiping on all 4 servers
API Endpint cleanup
API Endpint for version
CLI Version check
check keytype of panel/bindApi
more UNIT tests

View File

@ -2,7 +2,7 @@
"name": "24unix/bindapi",
"description": "manage Bind9 DNS server via REST API",
"version": "1.0.9",
"build_number": "370",
"build_number": "371",
"authors": [
{
"name": "Micha Espey",

View File

@ -1681,8 +1681,14 @@ class CLIController
$nameserverList = implode(separator: "', '", array: $nameservers);
$currentDBVersion = $this->settingsRepository->findByName(name: 'version');
$dbVersion = json_decode(json: $currentDBVersion);
if ($dbVersion = json_decode(json: $currentDBVersion)) {
$versionSting = $dbVersion->version->major . '.' . $dbVersion->version->minor . '.' . $dbVersion->version->patch;
} else {
if (!$this->quiet) {
echo COLOR_RED . 'Error: ' . COLOR_DEFAULT . 'Check version settings.' . PHP_EOL;
}
exit(1);
}
$fileContent = "<?php

View File

@ -10,8 +10,9 @@ use App\Repository\ApikeyRepository;
use App\Repository\DomainRepository;
use App\Repository\DynDNSRepository;
use App\Repository\PanelRepository;
use App\Service\ApiClient;
use Monolog\Logger;
use OpenApi\Attributes as OAT;
use OpenApi\Attributes as OA;
use OpenApi\Attributes\OpenApi;
use OpenApi\Generator;
use UnhandledMatchError;
@ -19,27 +20,27 @@ use function Symfony\Component\String\s;
// TODO attributes for swaggerUI
#[OAT\Info(version: VERSION, title: 'bindAPI')]
#[OAT\Server(
#[OA\Info(version: VERSION, title: 'bindAPI')]
#[OA\Server(
url: "{schema}://{hostname}/api",
description: "The bindAPI URL.",
variables: [
new OAT\ServerVariable(
new OA\ServerVariable(
serverVariable: 'schema',
default: 'https',
enum: ['http', 'https']
),
new OAT\ServerVariable(
new OA\ServerVariable(
serverVariable: 'hostname',
default: DEFAULT_NS,
enum: NAMESERVERS
)
]
)]
#[OAT\Tag(
#[OA\Tag(
name: "Server"
)]
#[OAT\SecurityScheme(
#[OA\SecurityScheme(
securityScheme: "Authorization",
type: "apiKey",
description: "Api Authentication",
@ -60,7 +61,7 @@ class RequestController
// server tag
private string $baseDir;
#[OAT\Get(
#[OA\Get(
path: '/ping',
operationId: 'ping',
description: 'Checks for connectivity and valid APIkey',
@ -69,11 +70,11 @@ class RequestController
],
tags: ['Server'],
responses: [
new OAT\Response(
new OA\Response(
response: 200,
description: 'OK'
),
new OAT\Response(
new OA\Response(
response: 401,
description: 'API key is missing or invalid.'
)
@ -90,7 +91,7 @@ class RequestController
}
}
#[OAT\Get(
#[OA\Get(
path: '/version',
operationId: 'version',
description: 'Check the API version of the nameserver.',
@ -99,11 +100,11 @@ class RequestController
],
tags: ['Server'],
responses: [
new OAT\Response(
new OA\Response(
response: 200,
description: 'x.y.z, aka major, minor, patch'
),
new OAT\Response(
new OA\Response(
response: 401,
description: 'API key is missing or invalid.'
)
@ -129,7 +130,7 @@ class RequestController
}
}
#[OAT\Get(
#[OA\Get(
path: '/domains',
operationId: 'getAllDomains',
description: 'Returns a list of all domains on this server.',
@ -139,15 +140,15 @@ class RequestController
],
tags: ['Domains'],
responses: [
new OAT\Response(
new OA\Response(
response: 200,
description: 'OK'
),
new OAT\Response(
new OA\Response(
response: 401,
description: 'API key is missing or invalid.'
),
new OAT\Response(
new OA\Response(
response: 404,
description: 'Domain not found.'
)]
@ -238,7 +239,7 @@ class RequestController
*/
#[
OAT\Get(
OA\Get(
path: '/domains/{name}',
operationId: 'getSingleDomain',
description: 'Returns information of a single domain specified by its domain name.',
@ -247,18 +248,18 @@ class RequestController
],
tags: ['Domains'],
parameters: [
new OAT\Parameter(name: 'name', in: 'path', required: true, schema: new OAT\Schema(type: 'string')),
new OA\Parameter(name: 'name', in: 'path', required: true, schema: new OA\Schema(type: 'string')),
],
responses: [
new OAT\Response(
new OA\Response(
response: 200,
description: 'OK'
),
new OAT\Response(
new OA\Response(
response: 401,
description: 'API key is missing or invalid.'
),
new OAT\Response(
new OA\Response(
response: 404,
description: 'Domain not found.'
)]
@ -653,6 +654,7 @@ class RequestController
// }
public function __construct(
private readonly ApiClient $apiClient,
private readonly ApikeyRepository $apikeyRepository,
private readonly DomainController $domainController,
private readonly DomainRepository $domainRepository,
@ -694,7 +696,7 @@ class RequestController
// domains
'domains' => $this->handleDomains(),
'dyndns' => $this->handleDynDNS(),
'apidoc' => $this->apiDoc(),
// 'apidoc' => $this->apiDoc(),
};
} catch (UnhandledMatchError) {
$this->status = '400 Bad Request';

View File

@ -20,10 +20,8 @@ use Monolog\Formatter\LineFormatter;
use Monolog\Handler\StreamHandler;
use Monolog\Level;
use Monolog\Logger;
use OpenApi\Attributes as OA;
use function DI\autowire;
#[OA\Info(version: '1.0.9', title: 'bindAPI')]
class BindAPI
{
private Logger $logger;