Skip to content

Commit

Permalink
Add support for WebHooks
Browse files Browse the repository at this point in the history
  • Loading branch information
WyriHaximus committed Jun 7, 2021
1 parent 75cb852 commit 4ac9951
Show file tree
Hide file tree
Showing 8 changed files with 2,591 additions and 7 deletions.
10 changes: 7 additions & 3 deletions bin/php-openapi
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,15 @@ switch ($command) {

$validator = new JsonSchema\Validator;
$openApiData = $openApi->getSerializableData();
$validator->validate($openApiData, (object)['$ref' => 'file://' . dirname(__DIR__) . '/schemas/openapi-v3.0.json']);
$openApiVersion = '3.0';
if (substr($openApi->openapi, 0, 3) === '3.1') {
$openApiVersion = '3.1';
}
$validator->validate($openApiData, (object)['$ref' => 'file://' . dirname(__DIR__) . '/schemas/openapi-v' . $openApiVersion . '.json']);

if ($validator->isValid() && empty($errors)) {
if(!$silentMode) {
print_formatted("The supplied API Description \B\Gvalidates\C against the OpenAPI v3.0 schema.\n", STDERR);
print_formatted("The supplied API Description \B\Gvalidates\C against the OpenAPI v" . $openApiVersion . " schema.\n", STDERR);
}
exit(0);
}
Expand All @@ -163,7 +167,7 @@ switch ($command) {
}
}
if (!$validator->isValid()) {
print_formatted("\BOpenAPI v3.0 schema violations:\C\n", STDERR);
print_formatted("\BOpenAPI v" . $openApiVersion . " schema violations:\C\n", STDERR);
$errors = $validator->getErrors();
foreach ($errors as $error) {
// hide some errors triggered by other errors further down the path
Expand Down
Loading

0 comments on commit 4ac9951

Please sign in to comment.