예제 #1
0
class Supported(pyschema.Record):
    """We have doc"""
    _namespace = "com.spotify.pyschema.test"
    int_field = pyschema.Integer(nullable=False, size=4)
    float1 = pyschema.Float(nullable=False)
    required_string_field = pyschema.Text(nullable=False)
    long_field = pyschema.Integer(description="some number")
    optional_string_field = pyschema.Text(description="")
    undocumented_string_field = pyschema.Text()
    string_list = pyschema.List(pyschema.Text(nullable=False),
                                nullable=True,
                                default=None)
    string_map = pyschema.Map(pyschema.Text(nullable=False),
                              description="map of foo",
                              nullable=True,
                              default=None)
    bytes1 = pyschema.Bytes(description="bytes field 1")
    boolean1 = pyschema.Boolean(description="boolean field 1")
    another_string_field = pyschema.Text(description="What")
    boolean2 = pyschema.Boolean(description="boolean field 2")
    bytes2 = pyschema.Bytes(description="bytes field 2")
    weird_characters = pyschema.Integer(
        description=u"\';drop table schemas;--\u0100\u0101\x00\x00\n"
        u"http://uncyclopedia.wikia.com/wiki/AAAAAAAAA! "
        u"\\ \u043c\u043d\u043e\u0433\u0430\u0431\u0443"
        u"\u043a\u0430\u0444 <script>alert(\"eh\")</script>(:,%)\'")
    float2 = pyschema.Float(description="float field 2")
예제 #2
0
class ParseMaps(ParseThreeIncludingNullable):
    maxDiff = 2000
    schema_name = "MySchema"
    avsc = """
{
    "name": "MySchema",
    "type": "record",
    "fields": [{
        "default": {},
        "type": {
            "values": ["null", "long"],
            "type": "map"
        },
        "name": "m"
    }, {
        "default": {},
        "type": [{
            "values": ["null", "long"],
            "type": "map"
        }, "null"],
        "name": "n"
    }, {
        "default": null,
        "type": ["null",
        {
            "values": ["null", "long"],
            "type": "map"
        }],
        "name": "o"
    }]
}"""
    references = [("m", pyschema.Map(pyschema.Integer())),
                  ("n", pyschema.Map(pyschema.Integer(), nullable=True)),
                  ("o",
                   pyschema.Map(pyschema.Integer(),
                                nullable=True,
                                default=None))]