marshmallow-oneofschema icon indicating copy to clipboard operation
marshmallow-oneofschema copied to clipboard

Required Field `type` Issue

Open lmregus opened this issue 1 year ago • 2 comments

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 avatar Jan 10 '23 15:01 lmregus