예제 #1
0
class InitiateAuthRequest(typesystem.Schema):
    AuthFlow = typesystem.Choice(choices=list(AuthFlowType))
    AuthParameters = typesystem.Object()
    ClientMetadata = typesystem.Object(allow_null=True)
    ClientId = typesystem.String()
    AnalyticsMetadata = typesystem.Reference(AnalyticsMetadataType,
                                             allow_null=True)
    UserContextData = typesystem.Reference(UserContextDataType,
                                           allow_null=True)
예제 #2
0
class Shelf(typesystem.Schema):
    id = typesystem.Integer(allow_null=True)
    organization = typesystem.Reference(Organization, allow_null=True)
    size = typesystem.Integer(allow_null=True)

    async def get_object(self) -> warehouse_models.Shelf:
        return await warehouse_models.Shelf.objects.get(id=self.id)
예제 #3
0
class InitiateAuthResponse(typesystem.Schema):
    ChallengeName = typesystem.Choice(choices=list(ChallengeNameType),
                                      allow_null=True)
    Session = typesystem.String(max_length=2048, allow_null=True)
    ChallengeParameters = typesystem.Object(allow_null=True)
    AuthenticationResult = typesystem.Reference(AuthenticationResultType,
                                                allow_null=True)
예제 #4
0
class Organization(typesystem.Schema):
    id = typesystem.Integer(allow_null=True)
    name = typesystem.String(max_length=50, allow_blank=True)
    user = typesystem.Reference(users_serializers.UserRef, allow_null=True)

    async def get_object(self) -> warehouse_models.Organization:
        return await warehouse_models.Organization.objects.get(id=self.id)
예제 #5
0
class AuthenticationResultType(typesystem.Schema):
    AccessToken = typesystem.String(pattern=r"[A-Za-z0-9_=.-]+")
    ExpiresIn = typesystem.Integer()
    TokenType = typesystem.String()
    RefreshToken = typesystem.String(pattern=r"[A-Za-z0-9_=.-]+")
    IdToken = typesystem.String(pattern=r"[A-Za-z0-9_=.-]+")
    NewDeviceMetadata = typesystem.Reference(NewDeviceMetadataType,
                                             allow_null=True)
예제 #6
0
파일: schemas.py 프로젝트: w4tsn/ceryx
class Route(BaseSchema):
    DEFAULT_SETTINGS = dict(Settings.validate({}))

    source = typesystem.String()
    target = typesystem.String()
    settings = typesystem.Reference(Settings, default=DEFAULT_SETTINGS)

    @classmethod
    def validate(cls, data):
        if "target" in data.keys():
            data["target"] = ensure_protocol(data["target"])
        return super().validate(data)
예제 #7
0
class Config(typesystem.Schema):
    port = typesystem.Integer()
    logLevel = typesystem.Choice(
        title="LogLevel",
        choices=[(x, x)
                 for x in ["debug", "info", "warn", "error", "critical"]],
    )
    # not supported
    # secondary = typesystem.Reference(
    #     to="Config", allow_null=True, definitions=definitions
    # )
    xxxAPI = typesystem.Reference(to=XXXAPI,
                                  allow_null=True,
                                  definitions=definitions)
예제 #8
0
async def upload(request):
    username = request.path_params["username"]
    table_id = request.path_params["table_id"]
    can_edit = check_can_edit(request, username)
    datasource = await load_datasource_or_404(username, table_id)

    form = await request.form()
    data = await form["upload-file"].read()
    encoding = chardet.detect(data)["encoding"]
    lines = data.decode(encoding).splitlines()
    rows = normalize_table([row for row in csv.reader(lines)])
    column_identities = determine_column_identities(rows)
    column_types, schema = determine_column_types(rows)
    unvalidated_data = [dict(zip(column_identities, row)) for row in rows[1:]]
    validated_data = [
        dict(instance)
        for instance in typesystem.Array(items=typesystem.Reference(
            to=schema)).validate(unvalidated_data, strict=False)
    ]

    column_insert_values = [{
        "created_at": datetime.datetime.now(),
        "name": name,
        "identity": column_identities[idx],
        "datatype": column_types[idx],
        "table": datasource.table["pk"],
        "position": idx + 1,
    } for idx, name in enumerate(rows[0])]

    query = tables.column.insert()
    await database.execute_many(query, column_insert_values)

    row_insert_values = [{
        "created_at": datetime.datetime.now(),
        "uuid": str(uuid.uuid4()),
        "table": datasource.table["pk"],
        "data": validated_data[idx],
        "search_text": " ".join(row),
    } for idx, row in enumerate(rows[1:])]

    query = tables.row.insert()
    await database.execute_many(query, row_insert_values)

    url = request.url_for("table", username=username, table_id=table_id)
    return RedirectResponse(url=url, status_code=303)
예제 #9
0
파일: sync.py 프로젝트: tiepdotme/lfk.im
class Place(typesystem.Schema):
    active = typesystem.Boolean()
    address = typesystem.String(allow_null=True)
    cuisine = typesystem.String(allow_null=True)
    cuisine_slugs = typesystem.Array(allow_null=True,
                                     items=typesystem.String(allow_null=True))
    cuisines = typesystem.Array(allow_null=True,
                                items=typesystem.String(allow_null=True))
    curbside = typesystem.Boolean(default=False)
    curbside_instructions = typesystem.String(allow_null=True)
    delivery = typesystem.Boolean(default=False)
    delivery_service_websites = typesystem.String(allow_null=True)
    dinein = typesystem.Boolean(default=False)
    facebook_url = typesystem.String(allow_null=True)
    featured = typesystem.Boolean(default=False)
    food_urls = typesystem.Array(allow_null=True,
                                 items=typesystem.Reference(allow_null=True,
                                                            to=Url))
    giftcard = typesystem.Boolean(default=False)
    giftcard_notes = typesystem.String(allow_null=True)
    giftcard_url = typesystem.String(allow_null=True)
    hours = typesystem.String(allow_null=True)
    instagram_url = typesystem.String(allow_null=True)
    locality = typesystem.String(
        allow_null=True)  # set default to a variable like "Lawrence"
    name = typesystem.String()
    neighborhood = typesystem.String(allow_null=True)
    neighborhood_slug = typesystem.String(allow_null=True)
    notes = typesystem.String(allow_blank=True)
    perma_closed = typesystem.Boolean(allow_null=True)
    place_type = typesystem.String(allow_null=True)
    region = typesystem.String(allow_null=True)
    restaurant_phone = typesystem.String(allow_null=True)
    sitemap = typesystem.Boolean()
    slug = typesystem.String()
    takeout = typesystem.Boolean(default=False)
    twitch_url = typesystem.String(allow_null=True)
    twitter_url = typesystem.String(allow_null=True)
    website = typesystem.String(allow_null=True)
예제 #10
0
 class Album(typesystem.Schema):
     title = typesystem.String(max_length=100)
     release_year = typesystem.Integer()
     artists = typesystem.Array(items=typesystem.Reference(Artist))
예제 #11
0
 class ExampleE(typesystem.Schema, definitions=definitions):
     field_on_e = typesystem.Integer()
     example_f = typesystem.Array(items=[typesystem.Reference("ExampleF")])
예제 #12
0
from apistar.schemas.jsonschema import JSON_SCHEMA

SCHEMA_REF = typesystem.Object(
    properties={"$ref": typesystem.String(pattern="^#/definitiions/")})
RESPONSE_REF = typesystem.Object(
    properties={"$ref": typesystem.String(pattern="^#/responses/")})

definitions = typesystem.SchemaDefinitions()

SWAGGER = typesystem.Object(
    title="Swagger",
    properties={
        "swagger":
        typesystem.String(),
        "info":
        typesystem.Reference("Info", definitions=definitions),
        "paths":
        typesystem.Reference("Paths", definitions=definitions),
        "host":
        typesystem.String(),
        "basePath":
        typesystem.String(pattern="^/"),
        "schemes":
        typesystem.Array(items=typesystem.Choice(
            choices=["http", "https", "ws", "wss"])),
        "consumes":
        typesystem.Array(items=typesystem.String()),
        "produces":
        typesystem.Array(items=typesystem.String()),
        "definitions":
        typesystem.Object(additional_properties=typesystem.Any()),
예제 #13
0
import typesystem

definitions = typesystem.SchemaDefinitions()

JSON_SCHEMA = (
    typesystem.Object(
        properties={
            "$ref":
            typesystem.String(),
            "type":
            typesystem.String() | typesystem.Array(items=typesystem.String()),
            "enum":
            typesystem.Array(unique_items=True, min_items=1),
            "definitions":
            typesystem.Object(additional_properties=typesystem.Reference(
                "JSONSchema", definitions=definitions)),
            # String
            "minLength":
            typesystem.Integer(minimum=0),
            "maxLength":
            typesystem.Integer(minimum=0),
            "pattern":
            typesystem.String(format="regex"),
            "format":
            typesystem.String(),
            # Numeric
            "minimum":
            typesystem.Number(),
            "maximum":
            typesystem.Number(),
            "exclusiveMinimum":
예제 #14
0
class Match(typesystem.Schema):
    left = typesystem.Reference(to=Player, allow_null=False)
    right = typesystem.Reference(to=Player, allow_null=False)
예제 #15
0
    properties={"$ref": typesystem.String(pattern="^#/components/schemas/")}
)
REQUESTBODY_REF = typesystem.Object(
    properties={"$ref": typesystem.String(pattern="^#/components/requestBodies/")}
)
RESPONSE_REF = typesystem.Object(
    properties={"$ref": typesystem.String(pattern="^#/components/responses/")}
)

definitions = typesystem.SchemaDefinitions()

OPEN_API = typesystem.Object(
    title="OpenAPI",
    properties={
        "openapi": typesystem.String(),
        "info": typesystem.Reference("Info", definitions=definitions),
        "servers": typesystem.Array(
            items=typesystem.Reference("Server", definitions=definitions)
        ),
        "paths": typesystem.Reference("Paths", definitions=definitions),
        "components": typesystem.Reference("Components", definitions=definitions),
        "security": typesystem.Array(
            items=typesystem.Reference("SecurityRequirement", definitions=definitions)
        ),
        "tags": typesystem.Array(
            items=typesystem.Reference("Tag", definitions=definitions)
        ),
        "externalDocs": typesystem.Reference(
            "ExternalDocumentation", definitions=definitions
        ),
    },
예제 #16
0
 class ExampleG(typesystem.Schema, definitions=definitions):
     field_on_g = typesystem.Integer()
     example_h = typesystem.Object(
         properties={"h": typesystem.Reference("ExampleH")}
     )
예제 #17
0
 class Album(typesystem.Schema):
     title = typesystem.String(max_length=100)
     release_date = typesystem.Date()
     artist = typesystem.Reference(Artist)
예제 #18
0
class Box(typesystem.Schema):
    id = typesystem.Integer(allow_null=True)
    shelf = typesystem.Reference(Shelf, allow_null=True)

    async def get_object(self) -> warehouse_models.Box:
        return await warehouse_models.Box.objects.get(id=self.id)
예제 #19
0
 class ExampleA(typesystem.Schema, definitions=definitions):
     field_on_a = typesystem.Integer()
     example_b = typesystem.Reference("ExampleB")
예제 #20
0
class ShelfCreate(Shelf):
    organization = typesystem.Reference(Organization)
예제 #21
0
 class ExampleC(typesystem.Schema, definitions=definitions):
     field_on_c = typesystem.Integer()
     example_d = typesystem.Array(items=typesystem.Reference("ExampleD"))
예제 #22
0
class OrganizationCreate(Organization):
    user = typesystem.Reference(users_serializers.UserRef)
예제 #23
0
class JSONRPCErrorResponse(typesystem.Schema):
    jsonrpc = typesystem.String(pattern="2.0", trim_whitespace=False)
    id = typesystem.String(trim_whitespace=False)
    error = typesystem.Reference(to=ErrorSchema)
예제 #24
0
 class BarSchema(typesystem.Schema):
     foo = typesystem.Reference(to=FooSchema)
예제 #25
0
 class Album(typesystem.Schema):
     title = typesystem.String(max_length=100)
     release_year = typesystem.Integer()
     artist = typesystem.Reference(Artist, allow_null=True)
예제 #26
0
 class BarSchema(typesystem.Schema):
     id = typesystem.Integer(allow_null=True)
     foo = typesystem.Reference(to=FooSchema)
예제 #27
0
 class Album(typesystem.Schema, definitions=definitions):
     title = typesystem.String(max_length=100)
     release_date = typesystem.Date()
     artist = typesystem.Reference("Artist")
예제 #28
0
 class BarsSchema(typesystem.Schema):
     bars = typesystem.Array(typesystem.Reference(to=BarSchema))
예제 #29
0
class BoxCreate(Box):
    shelf = typesystem.Reference(Shelf, allow_null=True)
예제 #30
0
class Person(typesystem.Schema, definitions=definitions):
    name = typesystem.String()
    age = typesystem.Integer()
    father = typesystem.Reference(to="Person", allow_null=True)