1
0
Fork 0

Revert "Merge remote-tracking branch 'BoShurik/schema'"

This reverts commit 89c3045e2b, reversing
changes made to 991985792d.
pull/9912/head
Guilliam Xavier 2021-05-24 10:15:16 +02:00
parent 41c66b1a2d
commit 9e2cb30dfb
3 changed files with 2 additions and 41 deletions

View File

@ -3,26 +3,7 @@
"title": "Package", "title": "Package",
"type": "object", "type": "object",
"additionalProperties": false, "additionalProperties": false,
"oneOf": [ "required": [ "name", "description" ],
{
"properties": {
"type": {
"not": {
"enum": ["project"]
}
}
},
"required": ["name", "description"]
},
{
"properties": {
"type": {
"enum": ["project"]
}
},
"required": ["type"]
}
],
"properties": { "properties": {
"name": { "name": {
"type": "string", "type": "string",

View File

@ -198,7 +198,7 @@ class JsonFile
if ($schema === self::LAX_SCHEMA) { if ($schema === self::LAX_SCHEMA) {
$schemaData->additionalProperties = true; $schemaData->additionalProperties = true;
$schemaData->oneOf = null; $schemaData->required = array();
} }
$validator = new Validator(); $validator = new Validator();

View File

@ -41,38 +41,18 @@ class ComposerSchemaTest extends TestCase
{ {
$json = '{ }'; $json = '{ }';
$result = $this->check($json); $result = $this->check($json);
$this->assertContains(array('property' => 'type', 'message' => 'The property type is required', 'constraint' => 'required'), $result);
$this->assertContains(array('property' => 'name', 'message' => 'The property name is required', 'constraint' => 'required'), $result); $this->assertContains(array('property' => 'name', 'message' => 'The property name is required', 'constraint' => 'required'), $result);
$this->assertContains(array('property' => 'description', 'message' => 'The property description is required', 'constraint' => 'required'), $result); $this->assertContains(array('property' => 'description', 'message' => 'The property description is required', 'constraint' => 'required'), $result);
$this->assertContains(array('property' => '', 'message' => 'Failed to match exactly one schema', 'constraint' => 'oneOf'), $result);
$json = '{ "name": "vendor/package" }'; $json = '{ "name": "vendor/package" }';
$this->assertEquals(array( $this->assertEquals(array(
array('property' => 'type', 'message' => 'The property type is required', 'constraint' => 'required'),
array('property' => 'description', 'message' => 'The property description is required', 'constraint' => 'required'), array('property' => 'description', 'message' => 'The property description is required', 'constraint' => 'required'),
array('property' => '', 'message' => 'Failed to match exactly one schema', 'constraint' => 'oneOf'),
), $this->check($json)); ), $this->check($json));
$json = '{ "description": "generic description" }'; $json = '{ "description": "generic description" }';
$this->assertEquals(array( $this->assertEquals(array(
array('property' => 'type', 'message' => 'The property type is required', 'constraint' => 'required'),
array('property' => 'name', 'message' => 'The property name is required', 'constraint' => 'required'), array('property' => 'name', 'message' => 'The property name is required', 'constraint' => 'required'),
array('property' => '', 'message' => 'Failed to match exactly one schema', 'constraint' => 'oneOf'),
), $this->check($json)); ), $this->check($json));
$json = '{ "type": "library" }';
$this->assertEquals(array(
array('property' => 'type', 'message' => 'Does not have a value in the enumeration ["project"]', 'constraint' => 'enum', 'enum' => array('project')),
array('property' => 'name', 'message' => 'The property name is required', 'constraint' => 'required'),
array('property' => 'description', 'message' => 'The property description is required', 'constraint' => 'required'),
array('property' => '', 'message' => 'Failed to match exactly one schema', 'constraint' => 'oneOf'),
), $this->check($json));
$json = '{ "type": "project" }';
$this->assertTrue($this->check($json));
$json = '{ "name": "vendor/package", "description": "description" }';
$this->assertTrue($this->check($json));
} }
public function testOptionalAbandonedProperty() public function testOptionalAbandonedProperty()