class TestArrayType(TestTypes, unittest.TestCase): schema = (jsd.Array(min_items=0, item_type=jsd.String(required=True)) .json()) expected_schema = { 'type': ['array', 'null'], 'minItems': 0, 'items': {'type': 'string'}, } valid_input = ( [], ['a string'], ) invalid_input = ( [0], ['a string', 0], [None], )
class Stuff(jsd.Object): name = jsd.String(required=True) email = jsd.String() groups = jsd.Array(min_items=1, item_type=jsd.String(required=True))
class TestStringTypeRequired(TestTypes, unittest.TestCase): schema = jsd.String(required=True).json() expected_schema = {'type': 'string'} valid_input = ['a string'] invalid_input = [None]
class TestStringType(TestTypes, unittest.TestCase): schema = jsd.String().json() expected_schema = {'type': ['string', 'null']} valid_input = ['a string', None] invalid_input = [0, .1, [], {}]
class Example(jsd.Object): thing = jsd.OneOf(jsd.String(), jsd.Boolean(required=True))
class NestedStuff(jsd.Object): name = jsd.String(required=True) email = Email() groups = jsd.Array(item_type=jsd.String(), required=True)
class Email(jsd.Object): service = jsd.String() value = jsd.String()