marshmallow-code / marshmallow-code/apispec
`apispec` ignores `oneOf` from `marshmallow-oneofschema`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.2k
- Forks
- 202
- Avg merge
- 3h 38m
- Merged PRs (30d)
- 3
Description
I need `oneOf` in my schema:
```py
class AerthlingsShopOffer(OneOfSchema):
"""Polymorphic offer type discriminated by the 'type' field."""
type_field = "type"
type_schemas = {
"character": AerthlingsCharacterOffer,
"mutation_point": AerthlingsMpOffer,
}
```
Marshmallow doesn't seem to support this. Fortunately, there is an extension, [`marshmallow-oneofschema`](https://github.com/marshmallow-code/marshmallow-oneofschema). Unfortunately, when presented with the class above, `apispec` silently ignores it, producing
```py
"AerthlingsShopOffer": {
"type": "object",
"properties": {}
},
```
and omitting `AerthlingsCharacterOffer` and `AerthlingsMpOffer` entirely.
I have a fix for this, but I think it requires discussion, and I have not yet written a unit test for it. If you think this is worth doing, I can complete the work and submit a PR. If not, that is no problem for me; I can continue to use my forked `apispec` in my own project.
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
No source file or test path is named; start by locating the marshmallow-oneofschema handling in apispec and reading the relevant schema-generation tests. Reproduce the AerthlingsShopOffer example, then add regression coverage confirming that oneOf and both concrete offer schemas are emitted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, python
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100