Utility¶
decode_query_string¶
- schema_markdown.decode_query_string(query_string, encoding='utf-8')¶
Decode an object from a query string. Each member key of the query string is expressed in fully-qualified form. List keys are the index into the list, must be in order. For example:
>>> schema_markdown.decode_query_string('a=5&b=3.14&c.d=foo&c.e.0=1&c.e.1=2&c.e.2=3&f.0.g=true&f.1.g=false') {'a': '5', 'b': '3.14', 'c': {'d': 'foo', 'e': ['1', '2', '3']}, 'f': [{'g': 'true'}, {'g': 'false'}]}
- Parameters:
- Returns:
The decoded object
- Raises:
ValueError – Query string is invalid
encode_query_string¶
- schema_markdown.encode_query_string(obj, encoding='utf-8')¶
Encode an object as a query string. Dictionaries, lists, and tuples are recursed. Each member key is expressed in fully-qualified form. List keys are the index into the list, and are in order. For example:
>>> schema_markdown.encode_query_string({'a': 5, 'b': 3.14, 'c': {'d': 'foo', 'e': [1, 2, 3]}, 'f': [{'g': True}, {'g': False}]}) 'a=5&b=3.14&c.d=foo&c.e.0=1&c.e.1=2&c.e.2=3&f.0.g=true&f.1.g=false'
get_enum_values¶
- schema_markdown.get_enum_values(types, enum)¶
Iterate the enum’s values (inherited values first)
- Parameters:
types (dict) – The type model
enum (dict) – The enum model
- Returns:
An iterator of enum value models
get_referenced_types¶
- schema_markdown.get_referenced_types(types, type_name, referenced_types=None)¶
Get a type’s referenced type model
- Parameters:
types (dict) – The type model
type_name (str) – The type name
referenced_types (dict) – An optional map of referenced user type name to user type
- Returns:
The referenced type model
get_struct_members¶
- schema_markdown.get_struct_members(types, struct)¶
Iterate the struct’s members (inherited members first)
- Parameters:
types (dict) – The type model
struct (dict) – The struct model
- Returns:
An iterator of struct member models
validate_type_model¶
- schema_markdown.validate_type_model(types)¶
Validate a user type model
- Parameters:
types (dict) – The type model
- Returns:
The validated type model
- Raises:
ValidationError – A validation error occurred