def serialize_resource(resource, ctx):
    """
    Serialize resource by schema.

    :param resource: Resource instance
    :param ctx: Request context
    :return: Serialized resource
    """
    schema_cls, _ = ctx.registry[resource]
    return schema_cls(ctx).serialize_resource(resource)
