Describe the bug
See here where the EnvironmentResponse object maps the id field in the response to the uuid field on the object. This prohibits the EnvironmentResponse from being validated successfully against the Cloud Api OpenAPI spec.
I've been using thephpleague/openapi-psr7-validator to validate locally stored and altered objects initially retrieved from Cloud API objects. I want to use this library to homogenise my local data and data that comes via typhonius/acquia-php-sdk-v2 so my functions can use both without excessive conditions to handle the data based on its source. Instead, I can validate the data through the OpenApi Spec, then trust it.
To Reproduce
Here is an example:
use cebe\openapi\Reader;
use cebe\openapi\ReferenceContext;
use cebe\openapi\spec\Reference;
use cebe\openapi\SpecObjectInterface;
use League\OpenAPIValidation\Schema\SchemaValidator;
// ...
const SpecUrl = 'https://cloudapi-docs.acquia.com/acquia-spec.yaml';
protected SpecObjectInterface $spec;
public function validate(array|object $response, string $ref) {
$response = (array) $response;
// e.g. #/component/schema/Environment.
$response['$ref'] = $ref;
$reference = new Reference($response);
$context = new ReferenceContext($this->spec, self::SpecUrl);
$schema = $reference->resolve($context);
$validator = new SchemaValidator();
// Throw exception because id property is missing on Environment.
$validator->validate($response, $schema);
return true;
}
Describe the bug
See here where the
EnvironmentResponseobject maps theidfield in the response to theuuid fieldon the object. This prohibits theEnvironmentResponsefrom being validated successfully against the Cloud Api OpenAPI spec.I've been using thephpleague/openapi-psr7-validator to validate locally stored and altered objects initially retrieved from Cloud API objects. I want to use this library to homogenise my local data and data that comes via typhonius/acquia-php-sdk-v2 so my functions can use both without excessive conditions to handle the data based on its source. Instead, I can validate the data through the OpenApi Spec, then trust it.
To Reproduce
Here is an example: