Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove justinrainbow/json-schema again #3417

Merged
merged 1 commit into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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