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.
78 out the named schema.
87 """Get pretty printed object prototype from the schema name.
90 name: string, Name of schema in the discovery document.
91 seen: list of string, Names of schema already seen. Used to handle
96 comments that conforms to the given schema.
103 return "# Object with schema name: %s" % name
116 """Get pretty printed object prototype from the schema name.
119 name: string, Name of schema in the discovery document.
123 comments that conforms to the given schema.
129 def _prettyPrintSchema(self, schema, seen=None, dent=0): argument
130 """Get pretty printed object prototype of schema.
133 schema: object, Parsed JSON schema.
134 seen: list of string, Names of schema already seen. Used to handle
139 comments that conforms to the given schema.
144 return _SchemaToStruct(schema, seen, dent=dent).to_str(self._prettyPrintByName)
146 def prettyPrintSchema(self, schema): argument
147 """Get pretty printed object prototype of schema.
150 schema: object, Parsed JSON schema.
154 comments that conforms to the given schema.
157 return self._prettyPrintSchema(schema, dent=0)[:-2]
160 """Get deserialized JSON schema from the schema name.
163 name: string, Schema name.
170 """Convert schema to a prototype object."""
173 def __init__(self, schema, seen, dent=0): argument
177 schema: object, Parsed JSON schema.
178 seen: list, List of names of schema already seen while parsing. Used to
188 # The parsed JSON schema.
189 self.schema = schema
194 # Method that when called returns a prototype object for the schema with
198 # List of names of schema already seen while parsing.
241 def _to_str_impl(self, schema): argument
242 """Prototype object based on the schema, in Python code with comments.
245 schema: object, Parsed JSON schema file.
248 Prototype object based on the schema, in Python code with comments.
250 stype = schema.get("type")
252 self.emitEnd("{", schema.get("description", ""))
254 if "properties" in schema:
255 properties = schema.get("properties", {})
260 elif "additionalProperties" in schema:
262 self._to_str_impl(schema["additionalProperties"])
265 elif "$ref" in schema:
266 schemaName = schema["$ref"]
267 description = schema.get("description", "")
274 value = schema.get("default", "True or False")
275 self.emitEnd("%s," % str(value), schema.get("description", ""))
277 value = schema.get("default", "A String")
278 self.emitEnd('"%s",' % str(value), schema.get("description", ""))
280 value = schema.get("default", "42")
281 self.emitEnd("%s," % str(value), schema.get("description", ""))
283 value = schema.get("default", "3.14")
284 self.emitEnd("%s," % str(value), schema.get("description", ""))
286 self.emitEnd("None,", schema.get("description", ""))
288 self.emitEnd('"",', schema.get("description", ""))
290 self.emitEnd("[", schema.get("description"))
293 self._to_str_impl(schema["items"])
304 """Prototype object based on the schema, in Python code with comments.
308 prototype for a schema with the given name. Seen is a list of schema
309 names already seen as we recursively descend the schema definition.
312 Prototype object based on the schema, in Python code with comments.
316 return self._to_str_impl(self.schema)