Skip to content

Question about validation_middleware #64

@korcky

Description

@korcky

Currently code of this method looks like:

async def validation_middleware(request: web.Request, handler) -> web.Response:
    ...
    for schema in schemas:
        data = await request.app["_apispec_parser"].parse(
            schema["schema"], request, locations=schema["locations"]
        )
        if data:
            try:
                result.update(data)
            except (ValueError, TypeError):
                result = data
                break
    else:
        result.update(request.match_info)
    request[request.app["_apispec_request_data_name"]] = result
    return await handler(request)

So, if schema successfully parsed a request arguments (basically transform each argument to their relative type), they will be put in result, but eventually (if data a dictionary) arguments in result will be replaced by their string representation.

The question is Why? Why replacing a right type arguments with their string representation?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions