marshmallow-code / marshmallow-code/marshmallow-oneofschema
Required Field `type` Issue
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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