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

Required Field type Issue #172

Open
lmregus opened this issue Jan 10, 2023 · 2 comments
Open

Required Field type Issue #172

lmregus opened this issue Jan 10, 2023 · 2 comments

Comments

@lmregus
Copy link

lmregus commented Jan 10, 2023

Hello, I am building an integration with an external webhook, unfortunately the webhook returns 2 slightly different payloads depending if the payload has a collection of objects or not.

I am trying to use the OneOfSchema to allow my endpoint to support these 2 different schemas, but when I hit the endpoint it fails saying that it requires the type field, when I add the type field with the expected value it works fine, the problem with this is that I have no access to the real payload being created which means that I can not ask the third party service to add the type key with the expected value to the payload before sending it.

In code I have something like this:

@bp.route(
    f"/{RESOURCE}/endpoint"
)
class className(MethodView):
    @bp.arguments(OneOfSchemaClass)
    @bp.response(200)
    def post(self, data: dict):

Is this something that's not supported/achievable? Unless the type key is explicitly set in the incoming payload?

@lmregus
Copy link
Author

lmregus commented Jan 10, 2023

Solved it with @pre_load

@lmregus lmregus closed this as completed Jan 10, 2023
@lmregus
Copy link
Author

lmregus commented Jan 12, 2023

I will re-open, because @pre_load does not work, is there any solutions for this? Or is it not expected to be used the way I am using it?

@lmregus lmregus reopened this Jan 12, 2023
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

1 participant