static::
assertIsString($schema);
$this->
assertValidSchema($schema);
} private function assertValidSchema(string
$schema): void
{ $client =
new Client();
$validatorURL = EnvironmentHelper::
getVariable('SWAGGER_VALIDATOR_URL', 'https://validator.swagger.io/validator/debug'
);
static::
assertIsString($validatorURL);
$response =
$client->
post($validatorURL,
[ 'json' =>
json_decode($schema, true, 512, \JSON_THROW_ON_ERROR
),
'headers' =>
[ 'Accept' => 'application/json',
],
]);
$content =
json_decode((string) $response->
getBody(), true, flags: \JSON_THROW_ON_ERROR
);
// The CI validator returns an empty response if the schema is valid
// The public Web validator returns an object with an empty schemaValidationMessages array
$messages =
$content['schemaValidationMessages'
] ??
[];