Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about validation_middleware #64

Closed
korcky opened this issue Sep 30, 2019 · 4 comments
Closed

Question about validation_middleware #64

korcky opened this issue Sep 30, 2019 · 4 comments

Comments

@korcky
Copy link

korcky commented Sep 30, 2019

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?

@maximdanilchenko
Copy link
Owner

@korcky, you talk about usage of @request_schema with location="match_info", am I right?

@korcky
Copy link
Author

korcky commented Sep 30, 2019

@maximdanilchenko, yep, you're correct

@maximdanilchenko
Copy link
Owner

maximdanilchenko commented Oct 1, 2019

Yes. You are right. It is an issue and it is my fault. It was designed like it in the very beginning of the project. And it was incorrect to change the behavior after some time. I will remove this else block in 2.0 version or we can add a new middleware without it. What do you think?

@korcky
Copy link
Author

korcky commented Oct 1, 2019

I'm not quite affected by this issue for now) So, I think it would better to fix in 2.0 version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants