Skip to content

Commit

Permalink
Merge pull request #3417 from nextcloud/enh/noid/remove-json-validator
Browse files Browse the repository at this point in the history
remove justinrainbow/json-schema again
  • Loading branch information
szaimen authored Sep 27, 2023
2 parents a1abd8e + dbdefe2 commit 1ff0328
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 96 deletions.
3 changes: 1 addition & 2 deletions php/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
"http-interop/http-factory-guzzle": "^1.2",
"slim/twig-view": "^3.3",
"slim/csrf": "^1.3",
"ext-apcu": "*",
"justinrainbow/json-schema": "^5.2"
"ext-apcu": "*"
},
"scripts": {
"psalm": "psalm --threads=1",
Expand Down
84 changes: 7 additions & 77 deletions php/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 1 addition & 17 deletions php/src/ContainerDefinitionFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use AIO\Data\ConfigurationManager;
use AIO\Data\DataConst;
use AIO\Docker\DockerActionManager;
use JsonSchema\Validator;

class ContainerDefinitionFetcher
{
Expand Down Expand Up @@ -41,27 +40,12 @@ public function GetContainerById(string $id): Container
throw new \Exception("The provided id " . $id . " was not found in the container definition.");
}

private function validateJson(object $data): void {
// Validate against json schema
$validator = new Validator;
$validator->validate($data, (object)[file_get_contents(__DIR__ . '/../containers-schema.json')]);
if (!$validator->isValid()) {
error_log("JSON does not validate. Violations:");
foreach ($validator->getErrors() as $error) {
error_log((string)printf("[%s] %s\n", $error['property'], $error['message']));
}
}
}

/**
* @return array
*/
private function GetDefinition(bool $latest): array
{
$rawData = file_get_contents(__DIR__ . '/../containers.json');
$objectData = json_decode($rawData, false);
$this->validateJson($objectData);
$data = json_decode($rawData, true);
$data = json_decode(file_get_contents(__DIR__ . '/../containers.json'), true);

$containers = [];
foreach ($data['aio_services_v1'] as $entry) {
Expand Down

0 comments on commit 1ff0328

Please sign in to comment.