Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5684)

Unified Diff: chrome/renderer/resources/extensions/json_schema.js

Issue 39113003: Docserver: Display enum value descriptions in API docs. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/renderer/resources/extensions/json_schema.js
diff --git a/chrome/renderer/resources/extensions/json_schema.js b/chrome/renderer/resources/extensions/json_schema.js
index 4b8996a4cd22e55f7ace3147dbafe922d8d7d576..6d0631b8bbd118ffd045955c15cd4f805ffb9bf8 100644
--- a/chrome/renderer/resources/extensions/json_schema.js
+++ b/chrome/renderer/resources/extensions/json_schema.js
@@ -53,6 +53,13 @@ function isOptionalValue(value) {
return typeof(value) === 'undefined' || value === null;
}
+function enumToString(enumValue) {
+ if (enumValue.name === undefined)
+ return enumValue;
+
+ return enumValue.name;
+}
+
/**
* Validates an instance against a schema and accumulates errors. Usage:
*
@@ -317,11 +324,12 @@ JSONSchemaValidator.prototype.validateChoices =
*/
JSONSchemaValidator.prototype.validateEnum = function(instance, schema, path) {
for (var i = 0; i < schema.enum.length; i++) {
- if (instance === schema.enum[i])
+ if (instance === enumToString(schema.enum[i]))
return true;
}
- this.addError(path, "invalidEnum", [schema.enum.join(", ")]);
+ this.addError(path, "invalidEnum",
+ [schema.enum.map(enumToString).join(", ")]);
return false;
};
« no previous file with comments | « chrome/common/extensions/docs/templates/private/type.html ('k') | components/json_schema/json_schema_validator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698