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

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..3c6f3942e81d4e4aa242cbb42eb788a0b779b945 100644
--- a/chrome/renderer/resources/extensions/json_schema.js
+++ b/chrome/renderer/resources/extensions/json_schema.js
@@ -53,6 +53,10 @@ function isOptionalValue(value) {
return typeof(value) === 'undefined' || value === null;
}
+function enumToString(enumValue) {
+ return enumValue.name || enumValue;
+}
+
/**
* Validates an instance against a schema and accumulates errors. Usage:
*
@@ -317,11 +321,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;
};

Powered by Google App Engine
This is Rietveld 408576698