Beispiel #1
0
class StoreResponse:
    success = doc.Boolean(
        "Boolean reflecting if the right query parameters were available in the request and if they are valid."
    )
    updated = doc.Boolean(
        "Boolean reflecting whether the webID uri and lblod uri pair is stored in the database."
    )
    message = doc.String("String that clarifies the response.")
Beispiel #2
0
 class HTTP_Check:
     hostname = doc.String("URL or hostname of the website to check")
     redirects = doc.Boolean(
         "Enables/disables the following of redirects (301/302)")
     check_string = doc.Boolean(
         "Enables/disables searching for a specified text string on the page"
     )
     keywords = doc.String(
         "The string to search for if check_string is enabled")
Beispiel #3
0
class ChannelPostRequest:
    url = doc.String()
    name = doc.String(description='A short readable name', required=True)
    match_regex = doc.String(
        description='Regex that the video title will have to match')
    directory = doc.String(required=True)
    mkdir = doc.Boolean()
    generate_posters = doc.Boolean()
    calculate_duration = doc.Boolean()
    download_frequency = doc.Integer()
Beispiel #4
0
class ChannelPutRequest:
    url = doc.String()
    name = doc.String()
    match_regex = doc.String()
    link = doc.String()
    directory = doc.String()
    generate_posters = doc.Boolean()
    calculate_duration = doc.Boolean()
    mkdir = doc.Boolean()
    download_frequency = doc.Integer()
Beispiel #5
0
class Model:
    name = doc.String(required=True)
    count = doc.Integer(required=True)
    fish = doc.Tuple()
    on = doc.Boolean()
    obj = doc.Dictionary()
    many = doc.Float()
Beispiel #6
0
 class endpoint(organization_team):
     endpoint_uid = doc.String(name='uid',
                               description='The endpoint\'s uid')
     tests = doc.List(doc.String(),
                      description='The tests that the endpoint supports')
     endpoint_name = doc.String()
     enable = doc.Boolean()  #default=False)
Beispiel #7
0
def swagger(app: Sanic):
    auth_bp, auth_me_bp, auth_verify_bp, auth_refresh_bp, auth_logout = app.jwt.bp.routes

    doc.summary('Авторизация')(auth_bp.handler)
    json_consumes(
        {
            'login': doc.String('Логин'),
            'password': doc.String('Пароль')
        },
        required=True)(auth_bp.handler)
    doc.response(200,
                 {'access_token': doc.String('Access Token')})(auth_bp.handler)

    doc.summary('Получение текущего пользователя')(auth_me_bp.handler)
    doc.security(True)(auth_me_bp.handler)
    doc.response(200, {'me': swagger_models.User})(auth_me_bp.handler)

    doc.summary('Проверка авторизации')(auth_verify_bp.handler)
    doc.response(200, {'valid': doc.Boolean()})(auth_verify_bp.handler)

    doc.summary('Обновление Access Token')(auth_refresh_bp.handler)
    doc.security(True)(auth_refresh_bp.handler)
    form_data_consumes({'refresh_token': doc.String('Refresh Token')},
                       required=True)(auth_refresh_bp.handler)
    doc.response(200, {'access_token': doc.String('Access Token')})(
        auth_refresh_bp.handler)

    doc.summary('Выход')(auth_logout.handler)
    doc.security(True)(auth_logout.handler)
    doc.response(200, {'response': doc.String('success')})(auth_logout.handler)
Beispiel #8
0
 class consumes:
     username = doc.String("Username")
     nick = doc.String("User's name")
     department = doc.String("User's department")
     back_mail = doc.String("User's backup mail")
     note = doc.String("Additional note")
     bed = doc.String("User's bed")
     is_panda = doc.Boolean("Is user panda")
Beispiel #9
0
 class _organization:
     label = doc.String(description='The organization name')
     owner = doc.String(
         description='The organization owner\'s name')
     owner_email = doc.String(
         description='The organization owner\'s email')
     personal = doc.Boolean(
         description='The organization is of person'
     )  #, default=False)
     value = doc.String(description='The organization ID')
Beispiel #10
0
 class _endpoint_item:
     endpoint_uid = doc.String()
     name = doc.String()
     status = doc.String()
     enable = doc.Boolean()
     last_run = doc.Integer(
         description="Timestamp in milliseconds, 0 if not run yet")
     tests = doc.List(doc.String())
     test_refs = doc.List(doc.String())
     endpoint_uid = doc.String()
Beispiel #11
0
class BiliChannelsModel:
    id = doc.String("An User/Channel/Space BiliBili ID.",
                    choices=["123456789"])
    room_id = doc.String("BiliBili Live Room ID the streamer will use.",
                         choices=["12345678"])
    name = doc.String("BiliBili Channel/Space/User name.")
    description = doc.String("The Channel Signature/Description.")
    thumbnail = doc.String("The Channel profile picture.")
    subscriberCount = doc.Integer("The channels subscription/followers count.")
    viewCount = doc.Integer("The channels views count.")
    videoCount = doc.Integer("The channels published/uploaded videos count.")
    live = doc.Boolean("Is the channel currently live or not.",
                       choices=[True, False])
Beispiel #12
0
 class task(organization_team):
     test_suite = doc.String(required=True,
                             description='The test suite name')
     path = doc.String(required=True,
                       description='The test suite\'s path name')
     endpoint_list = doc.List(
         doc.String(description='The endpoints to run the test'))
     priority = doc.Integer(
         description=
         'The priority of the task(larger number means higher importance)')
     parallelization = doc.Boolean()  #default=False)
     variables = doc.List(doc.String())
     test_cases = doc.List(doc.String())
     upload_dir = doc.String(
         description='The directory id of the upload files')
Beispiel #13
0
class ExampleModel:
    """
    Example domain object documentation that is used in swagger definition
    """
    field_a = doc.Float(description="field a description")
    field_b = doc.Integer(description="field b description")
    field_c = doc.Date(description="field c description")
    field_d = doc.Boolean(description="field d description")
    field_e = doc.String(description="field e description")

    def _validation_schema(self):
        return {
            'field_a': {'type': 'float', 'required': True, 'empty': False},
            'field_b': {'type': 'int', 'required': True, 'empty': False},
            'field_c': {'type': 'str', 'required': True, 'empty': False},
            'field_d': {'type': 'bool', 'required': True, 'empty': False},
            'field_e': {'type': 'str', 'required': True, 'empty': False},
        }
Beispiel #14
0
class ZooniverseClassificationReport:
    event = doc.Integer("Event Number", required=True)
    beam = doc.Integer("beam number", required=True)
    ml_prediction = doc.Float("zooniverse ML prediction", required=True)
    retired = doc.Boolean("retired")
    t0_astro = doc.Float("t0_astro")
    t1_blank = doc.Float("t1_blank")
    t1_overlapping = doc.Float("t1_overlapping")
    t1_repeating = doc.Float("t1_repeating")
    t0_rfi = doc.Float("t0_rfi")
    t0_cant_answer = doc.Float("t0_cant-answer")
    t1_something_weird = doc.Float("t0_something-weird")
    t0_total = doc.Float("t0_total")
    t1_total = doc.Float("t1_total")
    t0_astro_fraction = doc.Float("t0_astro_fraction")
    t0_rfi_fraction = doc.Float("t0_rfi_fraction")
    t0_cant_answer_fraction = doc.Float("t0_cant-answer_fraction")
    t1_blank_fraction = doc.Float("t1_blank_fraction")
    t1_overlapping_fraction = doc.Float("t1_overlapping_fraction")
    t1_repeating_fraction = doc.Float("t1_repeating_fraction")
    t1_something_weird_fraction = doc.Float("t1_something-weird_fraction")
Beispiel #15
0
def test_boolean_field(app):

    field = doc.Boolean()
    assert field.serialize() == {"type": "boolean"}

    @app.get("/")
    @doc.consumes(field, location="body", required=True)
    def test(request):
        return text("test")

    _, response = app.test_client.get("/swagger/swagger.json")
    assert response.status == 200
    assert response.content_type == "application/json"

    swagger_json = response.json
    path = swagger_json["paths"]["/"]["get"]
    assert path["parameters"][0] == {
        "required": True,
        "in": "body",
        "name": None,
        "type": "boolean",
    }
Beispiel #16
0
    "schema, expected_schema",
    [
        (doc.Field, {}),
        (doc.Field(), {}),
        (int, {"type": "integer", "format": "int64"}),
        (doc.Integer, {"type": "integer", "format": "int64"}),
        (doc.Integer(), {"type": "integer", "format": "int64"}),
        (float, {"type": "number", "format": "double"}),
        (doc.Float, {"type": "number", "format": "double"}),
        (doc.Float(), {"type": "number", "format": "double"}),
        (str, {"type": "string"}),
        (doc.String, {"type": "string"}),
        (doc.String(), {"type": "string"}),
        (bool, {"type": "boolean"}),
        (doc.Boolean, {"type": "boolean"}),
        (doc.Boolean(), {"type": "boolean"}),
        (date, {"type": "string", "format": "date"}),
        (doc.Date, {"type": "string", "format": "date"}),
        (doc.Date(), {"type": "string", "format": "date"}),
        (datetime, {"type": "string", "format": "date-time"}),
        (doc.DateTime, {"type": "string", "format": "date-time"}),
        (doc.DateTime(), {"type": "string", "format": "date-time"}),
        (TestSchema, {"$ref": "#/definitions/TestSchema"}),
        (dict, {"type": "object", "properties": {}}),
        ({"foo": "bar"}, {"type": "object", "properties": {"foo": {}}}),
        (list, {"type": "array", "items": []}),
        (["foo", "bar"], {"type": "array", "items": {"description": ["foo", "bar"]}}),
    ],
)
def test_serialize_schema(schema, expected_schema):
    serialized_schema = doc.serialize_schema(schema)
Beispiel #17
0
class UpdateResponseModel:
    update = doc.Boolean('Update status')
    id = doc.String('ID of firmware file')
    txhash = doc.String('Transaction hash of key')
Beispiel #18
0
class SettingsRequest:
    media_directory = doc.String()
    wrol_mode = doc.Boolean()
Beispiel #19
0
from utils.models import TwitchChannelModel, TwitchLiveModel

twitchbp = Blueprint("Twitch", "/twitch", strict_slashes=True)


@twitchbp.get("/live")
@doc.summary("Live Twitch streams")
@doc.description(
    "Fetch a list of live streams from available Twitch VTubers"
    ", updated every 1 minutes via cronjob."
)
@doc.produces(
    {
        "live": doc.List(TwitchLiveModel),
        "cached": doc.Boolean(
            "Is the results cached or not?", True, "cached", choices=[True]
        ),
    },
    description="A list of upcoming streams",
    content_type="application/json",
)
async def twitch_live(request):
    logger.info(f"Requested {request.path} data")
    twitch_res = await fetch_data("twitchdata", fetch_twitch)
    return json(
        {"live": twitch_res["live"], "cached": True},
        dumps=udumps,
        headers={"Cache-Control": "public, max-age=60, immutable"},
    )

Beispiel #20
0
        b = get_param(request, 'b')
        if a is None or b is None:
            return error_response('Invalid request')
        words_a = inference_engine_lda.tokenize(a)
        words_b = inference_engine_lda.tokenize(b)
        result = inference_engine_lda.cal_doc_distance(words_a, words_b)
        return response(data=result)
    except Exception as err:
        logger.error(err, exc_info=True)
        return error_response(str(err))


@app.route('/similarity/keywords', methods=["POST"])
@doc.summary("关键词计算")
@doc.description("使用LDA/TWE模型计算候选关键词与文档的相关性")
@doc.consumes(doc.Boolean(name='use_twe', description="是否使用TWE模型, 默认不使用"),
              required=False)
@doc.consumes(doc.String(name='text', description="文本"), required=True)
@doc.consumes(doc.String(name='keywords', description="关键词列表, 空格分割"),
              required=True)
@doc.response(200, None, description="""返回一个list对象,每个元素为关键词以及其与文档相关性。""")
async def api_similarity_keywords(request):
    try:
        keywords = get_param(request, 'keywords')
        text = get_param(request, 'text')
        use_twe = get_param(request, 'use_twe')
        if keywords is None or len(keywords) == 0 or text is None:
            return error_response('Invalid request')
        text = ' '.join(inference_engine_lda.tokenize(text))
        if use_twe:
            result = inference_engine_lda.cal_keywords_twe_similarity(
Beispiel #21
0
 class consumes:
     title = doc.String("lock title for public")
     description = doc.String("description only for admin")
     lock_until = doc.Date("YYYY-MM-DD")
     no_update = doc.Boolean("Should do switch_update(dev only)")
Beispiel #22
0
class EventObject:
    name = doc.String()
    is_set = doc.Boolean()
Beispiel #23
0
class RegexResponse:
    regex = doc.String()
    valid = doc.Boolean()
Beispiel #24
0
class CandidateResponse:
    success = doc.Boolean("Success of the request.")
    result = doc.List(CandidateResponseEntry, "List of all the candidates.")
Beispiel #25
0
class CandidateResponse:
    success = doc.Boolean("Success of the request.")
    result = doc.List(CandidateResponseEntry,
                      "List of all the list on which the person is present.")
Beispiel #26
0
class ListResponse:
    success = doc.Boolean("Success of the request.")
    result = doc.List(ListResponseEntry, "List of all the cities.")
Beispiel #27
0
class FavoriteRequest:
    video_id = doc.Integer()
    favorite = doc.Boolean()
Beispiel #28
0
 (str, {
     "type": "string"
 }),
 (doc.String, {
     "type": "string"
 }),
 (doc.String(), {
     "type": "string"
 }),
 (bool, {
     "type": "boolean"
 }),
 (doc.Boolean, {
     "type": "boolean"
 }),
 (doc.Boolean(), {
     "type": "boolean"
 }),
 (date, {
     "type": "string",
     "format": "date"
 }),
 (doc.Date, {
     "type": "string",
     "format": "date"
 }),
 (doc.Date(), {
     "type": "string",
     "format": "date"
 }),
 (datetime, {
Beispiel #29
0
class WROLModeRequest:
    enabled = doc.Boolean(required=True)
    try:
        subprocess.run(['git', 'commit', '-m', str(int(revision) + 1)], cwd=repo_root, check=True, stdout=subprocess.DEVNULL if not debug else None)
    except subprocess.CalledProcessError:
        return json(response_message(GIT_ERROR, "git commit error"))

    try:
        subprocess.run(['git', 'push', 'origin', language], cwd=repo_root, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL if not debug else None)
    except subprocess.CalledProcessError:
        return json(response_message(GIT_ERROR, "git push error"))

    return json(response_message(SUCCESS))

@bp.get('/roots')
@doc.summary('Return document paths in the root directory')
@doc.consumes(doc.String(name='X-Token'), location='header')
@doc.consumes(doc.Boolean(name='proprietary'))
@doc.consumes(doc.String(name='language'))
@doc.produces(_doc_roots)
@token_required
@organization_team_required_by_args
async def handler(self, request):
    organization = request.ctx.organization
    team = request.ctx.team
    proprietary = js2python_bool(request.args.get('proprietary', False))
    language = request.args.get('language', 'en')

    paths = [{'value': 0, 'label': '/'}]
    if proprietary:
        doc_root = get_document_root(language, organization, team)
    else:
        doc_root = get_document_root(language, None, None)