Lines Matching full:schema

15 """Schema processing for discovery based APIs
17 Schemas holds an APIs discovery schemas. It can return those schema as
19 conform to the schema.
21 For example, given the schema:
23 schema = \"\"\"{
45 s = Schemas(schema)
57 The constructor takes a discovery document in which to look up named schema.
79 out the named schema.
88 """Get pretty printed object prototype from the schema name.
91 name: string, Name of schema in the discovery document.
92 seen: list of string, Names of schema already seen. Used to handle
97 comments that conforms to the given schema.
104 return "# Object with schema name: %s" % name
117 """Get pretty printed object prototype from the schema name.
120 name: string, Name of schema in the discovery document.
124 comments that conforms to the given schema.
130 def _prettyPrintSchema(self, schema, seen=None, dent=0): argument
131 """Get pretty printed object prototype of schema.
134 schema: object, Parsed JSON schema.
135 seen: list of string, Names of schema already seen. Used to handle
140 comments that conforms to the given schema.
145 return _SchemaToStruct(schema, seen, dent=dent).to_str(self._prettyPrintByName)
147 def prettyPrintSchema(self, schema): argument
148 """Get pretty printed object prototype of schema.
151 schema: object, Parsed JSON schema.
155 comments that conforms to the given schema.
158 return self._prettyPrintSchema(schema, dent=1)[:-2]
161 """Get deserialized JSON schema from the schema name.
164 name: string, Schema name.
171 """Convert schema to a prototype object."""
174 def __init__(self, schema, seen, dent=0): argument
178 schema: object, Parsed JSON schema.
179 seen: list, List of names of schema already seen while parsing. Used to
189 # The parsed JSON schema.
190 self.schema = schema
195 # Method that when called returns a prototype object for the schema with
199 # List of names of schema already seen while parsing.
242 def _to_str_impl(self, schema): argument
243 """Prototype object based on the schema, in Python code with comments.
246 schema: object, Parsed JSON schema file.
249 Prototype object based on the schema, in Python code with comments.
251 stype = schema.get("type")
253 self.emitEnd("{", schema.get("description", ""))
255 if "properties" in schema:
256 for pname, pschema in six.iteritems(schema.get("properties", {})):
259 elif "additionalProperties" in schema:
261 self._to_str_impl(schema["additionalProperties"])
264 elif "$ref" in schema:
265 schemaName = schema["$ref"]
266 description = schema.get("description", "")
273 value = schema.get("default", "True or False")
274 self.emitEnd("%s," % str(value), schema.get("description", ""))
276 value = schema.get("default", "A String")
277 self.emitEnd('"%s",' % str(value), schema.get("description", ""))
279 value = schema.get("default", "42")
280 self.emitEnd("%s," % str(value), schema.get("description", ""))
282 value = schema.get("default", "3.14")
283 self.emitEnd("%s," % str(value), schema.get("description", ""))
285 self.emitEnd("None,", schema.get("description", ""))
287 self.emitEnd('"",', schema.get("description", ""))
289 self.emitEnd("[", schema.get("description"))
292 self._to_str_impl(schema["items"])
303 """Prototype object based on the schema, in Python code with comments.
307 prototype for a schema with the given name. Seen is a list of schema
308 names already seen as we recursively descend the schema definition.
311 Prototype object based on the schema, in Python code with comments.
315 return self._to_str_impl(self.schema)