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

Unified Diff: tools/json_schema_compiler/model.py

Issue 10022005: Let json schema compiler handle using arrays as types (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Small style changes Created 8 years, 8 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: tools/json_schema_compiler/model.py
diff --git a/tools/json_schema_compiler/model.py b/tools/json_schema_compiler/model.py
index 07ead3ddaf4522c9ac21a51d3f095e5098781062..53b3aee124c0d60736afabd9dd0bde3656c76759 100644
--- a/tools/json_schema_compiler/model.py
+++ b/tools/json_schema_compiler/model.py
@@ -70,13 +70,22 @@ class Type(object):
- |from_json| indicates that instances of the Type can originate from the
JSON (as described by the schema), such as top-level types and function
parameters
+ - |type_| the PropertyType of this Type
+ - |item_type| if this is an array, the type of items in the array
"""
def __init__(self, parent, name, json):
- if not (
- 'properties' in json or
- 'additionalProperties' in json or
- 'functions' in json):
- raise ParseException(name + " has no properties or functions")
+ if json.get('type') == 'array':
+ self.type_ = PropertyType.ARRAY
+ self.item_type = Property(self, name + "Element", json['items'],
+ from_json=True,
+ from_client=True)
+ else:
+ if not (
+ 'properties' in json or
+ 'additionalProperties' in json or
+ 'functions' in json):
+ raise ParseException(name + " has no properties or functions")
+ self.type_ = PropertyType.OBJECT
self.name = name
self.description = json.get('description')
self.from_json = True

Powered by Google App Engine
This is Rietveld 408576698