From 9e2cb30dfb50f83baec05a7a0302a76c86ec37cd Mon Sep 17 00:00:00 2001 From: Guilliam Xavier Date: Mon, 24 May 2021 10:15:16 +0200 Subject: [PATCH] Revert "Merge remote-tracking branch 'BoShurik/schema'" This reverts commit 89c3045e2b437dd04d52394d0989ee4c07d7f16c, reversing changes made to 991985792d236a002dce6adfb50f2bf0625fbab0. --- res/composer-schema.json | 21 +------------------ src/Composer/Json/JsonFile.php | 2 +- .../Composer/Test/Json/ComposerSchemaTest.php | 20 ------------------ 3 files changed, 2 insertions(+), 41 deletions(-) diff --git a/res/composer-schema.json b/res/composer-schema.json index 836409b43..d6e149c9d 100644 --- a/res/composer-schema.json +++ b/res/composer-schema.json @@ -3,26 +3,7 @@ "title": "Package", "type": "object", "additionalProperties": false, - "oneOf": [ - { - "properties": { - "type": { - "not": { - "enum": ["project"] - } - } - }, - "required": ["name", "description"] - }, - { - "properties": { - "type": { - "enum": ["project"] - } - }, - "required": ["type"] - } - ], + "required": [ "name", "description" ], "properties": { "name": { "type": "string", diff --git a/src/Composer/Json/JsonFile.php b/src/Composer/Json/JsonFile.php index ff4dcc8c8..b15098d56 100644 --- a/src/Composer/Json/JsonFile.php +++ b/src/Composer/Json/JsonFile.php @@ -198,7 +198,7 @@ class JsonFile if ($schema === self::LAX_SCHEMA) { $schemaData->additionalProperties = true; - $schemaData->oneOf = null; + $schemaData->required = array(); } $validator = new Validator(); diff --git a/tests/Composer/Test/Json/ComposerSchemaTest.php b/tests/Composer/Test/Json/ComposerSchemaTest.php index 877ef0666..0eece664c 100644 --- a/tests/Composer/Test/Json/ComposerSchemaTest.php +++ b/tests/Composer/Test/Json/ComposerSchemaTest.php @@ -41,38 +41,18 @@ class ComposerSchemaTest extends TestCase { $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' => '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" }'; $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' => '', 'message' => 'Failed to match exactly one schema', 'constraint' => 'oneOf'), ), $this->check($json)); $json = '{ "description": "generic description" }'; $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' => '', 'message' => 'Failed to match exactly one schema', 'constraint' => 'oneOf'), ), $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()