Skip to content

Commit 4ac9951

Browse files
committed
Add support for WebHooks
1 parent 75cb852 commit 4ac9951

File tree

8 files changed

+2591
-7
lines changed

8 files changed

+2591
-7
lines changed

bin/php-openapi

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,15 @@ switch ($command) {
136136

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

141145
if ($validator->isValid() && empty($errors)) {
142146
if(!$silentMode) {
143-
print_formatted("The supplied API Description \B\Gvalidates\C against the OpenAPI v3.0 schema.\n", STDERR);
147+
print_formatted("The supplied API Description \B\Gvalidates\C against the OpenAPI v" . $openApiVersion . " schema.\n", STDERR);
144148
}
145149
exit(0);
146150
}
@@ -163,7 +167,7 @@ switch ($command) {
163167
}
164168
}
165169
if (!$validator->isValid()) {
166-
print_formatted("\BOpenAPI v3.0 schema violations:\C\n", STDERR);
170+
print_formatted("\BOpenAPI v" . $openApiVersion . " schema violations:\C\n", STDERR);
167171
$errors = $validator->getErrors();
168172
foreach ($errors as $error) {
169173
// hide some errors triggered by other errors further down the path

0 commit comments

Comments
 (0)