diff options
author | kinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-31 06:38:29 +0000 |
---|---|---|
committer | kinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-31 06:38:29 +0000 |
commit | e685143bd7d15b048b7ca9cb4ec0240827842266 (patch) | |
tree | 74f100269c45c656a554a794d4e63749b91fe026 /components | |
parent | 7a29680b81b983ac1da1b5fdbe3ad096bad7015a (diff) | |
download | chromium_src-e685143bd7d15b048b7ca9cb4ec0240827842266.zip chromium_src-e685143bd7d15b048b7ca9cb4ec0240827842266.tar.gz chromium_src-e685143bd7d15b048b7ca9cb4ec0240827842266.tar.bz2 |
Revert 231982 "Docserver: Display enum value descriptions in API..."
"JsonSchemaTest.TestEnum" started failing on Windows bot after this change.
> Docserver: Display enum value descriptions in API docs.
>
> This modifies the json schema to allow both primitive types and
> dictionaries with properties "name" and optional "description" for enum
> values.
>
> BUG=310454
>
> Review URL: https://codereview.chromium.org/39113003
TBR=sammc@chromium.org
Review URL: https://codereview.chromium.org/47403003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@232016 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components')
-rw-r--r-- | components/json_schema/json_schema_validator.cc | 25 | ||||
-rw-r--r-- | components/json_schema/json_schema_validator_unittest.cc | 10 | ||||
-rw-r--r-- | components/test/data/json_schema/enum_schema.json | 2 |
3 files changed, 3 insertions, 34 deletions
diff --git a/components/json_schema/json_schema_validator.cc b/components/json_schema/json_schema_validator.cc index 3cc9e2b..3816a76 100644 --- a/components/json_schema/json_schema_validator.cc +++ b/components/json_schema/json_schema_validator.cc @@ -53,18 +53,6 @@ bool CompareToString(const ExpectedType& entry, const std::string& key) { return entry.key < key; } -// If |value| is a dictionary, returns the "name" attribute of |value| or NULL -// if |value| does not contain a "name" attribute. Otherwise, returns |value|. -const base::Value* ExtractNameFromDictionary(const base::Value* value) { - const base::DictionaryValue* value_dict = NULL; - const base::Value* name_value = NULL; - if (value->GetAsDictionary(&value_dict)) { - value_dict->Get("name", &name_value); - return name_value; - } - return value; -} - bool IsValidSchema(const base::DictionaryValue* dict, std::string* error) { // This array must be sorted, so that std::lower_bound can perform a // binary search. @@ -207,13 +195,6 @@ bool IsValidSchema(const base::DictionaryValue* dict, std::string* error) { for (size_t i = 0; i < list_value->GetSize(); ++i) { const base::Value* value = NULL; list_value->Get(i, &value); - // Sometimes the enum declaration is a dictionary with the enum value - // under "name". - value = ExtractNameFromDictionary(value); - if (!value) { - *error = "Invalid value in enum attribute"; - return false; - } switch (value->GetType()) { case base::Value::TYPE_NULL: case base::Value::TYPE_BOOLEAN: @@ -498,12 +479,6 @@ void JSONSchemaValidator::ValidateEnum(const base::Value* instance, for (size_t i = 0; i < choices->GetSize(); ++i) { const base::Value* choice = NULL; CHECK(choices->Get(i, &choice)); - // Sometimes the enum declaration is a dictionary with the enum value under - // "name". - choice = ExtractNameFromDictionary(choice); - if (!choice) { - NOTREACHED(); - } switch (choice->GetType()) { case base::Value::TYPE_NULL: case base::Value::TYPE_BOOLEAN: diff --git a/components/json_schema/json_schema_validator_unittest.cc b/components/json_schema/json_schema_validator_unittest.cc index 6372032..4844ed1 100644 --- a/components/json_schema/json_schema_validator_unittest.cc +++ b/components/json_schema/json_schema_validator_unittest.cc @@ -77,16 +77,10 @@ TEST(JSONSchemaValidator, IsValidSchema) { EXPECT_FALSE(JSONSchemaValidator::IsValidSchema( "{" " \"type\": \"string\"," - " \"enum\": [ {} ]" // "enum" dict values must contain "name". + " \"enum\": [ {} ]," // "enum" must contain simple values. "}", &error)); EXPECT_FALSE(JSONSchemaValidator::IsValidSchema( "{" - " \"type\": \"string\"," - " \"enum\": [ { \"name\": {} } ]" // "enum" name must be a simple value. - "}", - &error)); - EXPECT_FALSE(JSONSchemaValidator::IsValidSchema( - "{" " \"type\": \"array\"," " \"items\": [ 123 ]," // "items" must contain a schema or schemas. "}", &error)); @@ -112,7 +106,7 @@ TEST(JSONSchemaValidator, IsValidSchema) { " }," " \"enum-property\": {" " \"type\": \"integer\"," - " \"enum\": [0, 1, {\"name\": 10}, 100]" + " \"enum\": [0, 1, 10, 100]" " }," " \"items-property\": {" " \"type\": \"array\"," diff --git a/components/test/data/json_schema/enum_schema.json b/components/test/data/json_schema/enum_schema.json index efb68de..ae0c12a 100644 --- a/components/test/data/json_schema/enum_schema.json +++ b/components/test/data/json_schema/enum_schema.json @@ -1,3 +1,3 @@ { - "enum": ["foo", 42, {"name": false, "description": "a false value"}] + "enum": ["foo", 42, false] } |