From a43a3b434ed477799bba7b35591304fd251af474 Mon Sep 17 00:00:00 2001 From: "joaodasilva@chromium.org" Date: Thu, 28 Nov 2013 18:01:28 +0000 Subject: Resolve "$ref" attributes in JSON schemas. This allows managed extensions to declare policies that have a recursive type (e.g. a hierarchy of bookmarks with folders) or to reuse the same policy type for multiple policies. BUG=108992 Review URL: https://codereview.chromium.org/88573002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@237814 0039d316-1c4b-4281-b951-d872f2087c98 --- components/json_schema/json_schema_validator.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'components/json_schema') diff --git a/components/json_schema/json_schema_validator.cc b/components/json_schema/json_schema_validator.cc index 3cc9e2b..32cb93c 100644 --- a/components/json_schema/json_schema_validator.cc +++ b/components/json_schema/json_schema_validator.cc @@ -89,7 +89,7 @@ bool IsValidSchema(const base::DictionaryValue* dict, std::string* error) { { schema::kTitle, base::Value::TYPE_STRING }, }; - bool has_type = false; + bool has_type_or_ref = false; const base::ListValue* list_value = NULL; const base::DictionaryValue* dictionary_value = NULL; std::string string_value; @@ -119,7 +119,7 @@ bool IsValidSchema(const base::DictionaryValue* dict, std::string* error) { *error = "Invalid value for type attribute"; return false; } - has_type = true; + has_type_or_ref = true; continue; } @@ -242,10 +242,13 @@ bool IsValidSchema(const base::DictionaryValue* dict, std::string* error) { } } } + + if (it.key() == schema::kRef) + has_type_or_ref = true; } - if (!has_type) { - *error = "Schema must have a type attribute"; + if (!has_type_or_ref) { + *error = "Schema must have a type or a $ref attribute"; return false; } -- cgit v1.1