marshmallow-code / marshmallow-code/marshmallow-oneofschema

Required Field `type` Issue

Open
#172 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
142
Forks
44
Avg merge
7h 7m
Merged PRs (30d)
3

Description

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?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the @bp.arguments(OneOfSchemaClass) entry point and inspect how OneOfSchema selects a schema when the incoming webhook lacks a type field. Reproduce the two payload shapes, then determine whether discriminator-free selection is supported; done means both documented payloads are accepted or the limitation is clearly documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.