Beispiel #1
0
def test_parse_params():
    assert parse_params(demo_func, [], {}) == []
    params = parse_params(demo_class.demo_method, [], {})
    assert len(params) == 1
    assert params[0] == {
        'name': 'DemoModel',
        'in': 'query',
        'required': True,
        'schema': {
            '$ref': '#/components/schemas/DemoModel',
        }
    }
Beispiel #2
0
def test_parse_params():
    models = {"DemoModel": DemoModel.schema()}
    assert parse_params(demo_func, [], models) == []
    params = parse_params(demo_class.demo_method, [], models)
    assert len(params) == 3
    assert params[0] == {
        "name": "uid",
        "in": "query",
        "required": True,
        "schema": {
            "title": "Uid",
            "type": "integer",
        },
    }
Beispiel #3
0
def test_parse_params():
    models = {'DemoModel': DemoModel.schema()}
    assert parse_params(demo_func, [], models) == []
    params = parse_params(demo_class.demo_method, [], models)
    assert len(params) == 3
    assert params[0] == {
        'name': 'uid',
        'in': 'query',
        'required': True,
        'schema': {
            'title': 'Uid',
            'type': 'integer',
        }
    }
Beispiel #4
0
def test_parse_params():
    models = {
        get_model_path_key("tests.common.DemoModel"):
        DemoModel.schema(ref_template="#/components/schemas/{model}")
    }
    assert parse_params(demo_func, [], models) == []
    params = parse_params(demo_class.demo_method, [], models)
    assert len(params) == 3
    assert params[0] == {
        "name": "uid",
        "in": "query",
        "required": True,
        "description": "",
        "schema": {
            "title": "Uid",
            "type": "integer"
        },
    }
    assert params[2]["description"] == "user name"
Beispiel #5
0
def test_parse_params_with_route_param_keywords():
    models = {
        get_model_path_key("tests.common.DemoQuery"):
        DemoQuery.schema(ref_template="#/components/schemas/{model}")
    }
    params = parse_params(demo_func_with_query, [], models)
    assert params == [
        {
            "name": "names1",
            "in": "query",
            "required": True,
            "description": "",
            "schema": {
                "title": "Names1",
                "type": "array",
                "items": {
                    "type": "string"
                }
            },
        },
        {
            "name": "names2",
            "in": "query",
            "required": True,
            "description": "",
            "schema": {
                "title": "Names2",
                "type": "array",
                "items": {
                    "type": "string"
                },
                "non_keyword": "dummy",
            },
            "style": "matrix",
            "explode": True,
        },
    ]