Skip to content

[Bug]: RequestUnmarshalResult has wrong type for body #898

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

Closed
mtvx opened this issue Aug 20, 2024 · 0 comments · Fixed by #900
Closed

[Bug]: RequestUnmarshalResult has wrong type for body #898

mtvx opened this issue Aug 20, 2024 · 0 comments · Fixed by #900
Labels
area/unmarshalling Indicates an issue on unmarshalling area. kind/bug/confirmed kind/bug Indicates an issue

Comments

@mtvx
Copy link

mtvx commented Aug 20, 2024

Actual Behavior

unmarshal_request returns RequestUnmarshalResult which has body field defined as:

@dataclass
class RequestUnmarshalResult(BaseUnmarshalResult):
    body: str | None = None
    ...

But actually, at least with application/json or alike request body defined in the spec, this gets set to the validated/unmarshalled dict.

Maybe generics could be used there, but it would probably make things just complicated.

Anyway, the reality and the type hint are not matching.

Expected Behavior

It's nice to get that unmarshalled dict instead of str, but the type hint is wrong.

I guess the type hint should be changed to Any, because if the content type was e.g. text/plain then body would really get set to a str (or bytes, rather?).

Steps to Reproduce

Something like:

result = unmarshal_request(...)
print(type(result.body))

OpenAPI Core Version

0.19.3

OpenAPI Core Integration

custom

Affected Area(s)

No response

References

No response

Anything else we need to know?

No response

Would you like to implement a fix?

None

@mtvx mtvx added the kind/bug Indicates an issue label Aug 20, 2024
@p1c2u p1c2u added kind/bug/confirmed area/unmarshalling Indicates an issue on unmarshalling area. labels Aug 20, 2024
@p1c2u p1c2u closed this as completed in #900 Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/unmarshalling Indicates an issue on unmarshalling area. kind/bug/confirmed kind/bug Indicates an issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants