Skip to content

Instantly share code, notes, and snippets.

@SOHELAHMED7
Created January 22, 2025 13:49
Show Gist options
  • Save SOHELAHMED7/8ad65f3a0d43850be70d6d2994672e04 to your computer and use it in GitHub Desktop.
Save SOHELAHMED7/8ad65f3a0d43850be70d6d2994672e04 to your computer and use it in GitHub Desktop.
{
"openapi": "3.0.3",
"info": {
"title": "Test",
"version": "0.1.0"
},
"paths": {
"/test": {
"get": {
"responses": {
"200": {
"description": "Test"
}
}
}
}
},
"components": {
"schemas": {
"answer": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"summary": "the summary"
}
}
}
}
}
}

Run this test:

composer testOnly ValidatorTest::test774RedundantErrorInValidationComponentsschemasanswerpropertiesiddollarrefThePropertyDollarrefIsRequired
<?php
namespace JsonSchema\Tests;
use JsonSchema\Validator;
use PHPUnit\Framework\TestCase;
class ValidatorTest extends TestCase
{
public function test774RedundantErrorInValidationComponentsschemasanswerpropertiesiddollarrefThePropertyDollarrefIsRequired()
{
$data = json_decode('"42"');
$schema = json_decode(file_get_contents(__DIR__ . '/774.json'));
$validator = new Validator();
// $validator->validate($data, (object)['$ref' => 'file://' . dirname(__DIR__) . '/tests/774.json']);
$validator->validate($data, $schema);
$this->assertTrue($validator->getErrors());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment