feat: allOf / oneOf / discriminator resolution
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
Research direction
Start with the OpenAPI schema model/parser from #1, likely under devview-networkmock-core/src/commonMain/kotlin/com/worldline/devview/networkmock/core/openapi/, and review how #10's schema synthesis will consume it. Define and document deterministic handling for allOf, oneOf, anyOf, and discriminator mappings, then add realistic fixture tests. Done means common compositions resolve correctly and malformed or conflicting cases fail with clear errors.
Written by the indexing model from the issue text.
Description
Part of #72
Depends on #1, #10. Not blocking for 0.2.0 — follow-up depth issue.
Summary
Resolve allOf/oneOf/anyOf composition and discriminator-based polymorphism in JSON Schemas encountered while parsing an OpenAPI spec, so that schema-driven features (#10's synthesis, any future validation-adjacent feature) work correctly against real-world specs that use these constructs — which is common, especially for polymorphic response shapes.
Current state
The core parser built in #1 is explicitly scoped to a subset of OpenAPI (see #1's "explicitly out of scope" list): allOf/oneOf/anyOf/discriminator resolution is called out there as deferred. This issue is where that deferred work actually gets scoped and built once there's a concrete need for it (most likely driven by #10's schema synthesis hitting a composed schema and not knowing what to do with it).
What to build
allOf: merge all member schemas' properties into one effective schema.oneOf/anyOfwithout adiscriminator: pick a strategy for which variant to use when synthesizing (#10) — likely "first declared variant" is a reasonable default, since there's no runtime data to disambiguate at spec-parse time.oneOfwith adiscriminator: resolvediscriminator.propertyNameanddiscriminator.mappingto determine which variant a given example or synthesized value actually represents.
This is meaningfully more complex than the rest of the parser (#1) — JSON Schema composition has real edge cases (conflicting property definitions across allOf members, circular refs, etc.). Scope the first pass narrowly (handle the common, well-formed cases; fail loudly rather than silently misinterpreting on anything unusual) rather than attempting full JSON Schema spec conformance.
Acceptance criteria
-
allOfmember schemas are merged correctly for the common case (non-conflicting properties). -
oneOf/anyOfwithout a discriminator falls back to a documented, deterministic strategy. -
oneOfwith a discriminator resolves to the correct variant given adiscriminator.propertyNamevalue. - Malformed or unusually-structured composition (e.g. conflicting
allOfmembers) fails with a clear error rather than silently producing a wrong result. - Tests cover all of the above against realistic fixture schemas.
Files likely touched
- Wherever #1's OpenAPI schema model/parser lands (likely
devview-networkmock-core/src/commonMain/kotlin/com/worldline/devview/networkmock/core/openapi/) - #10's schema-synthesis code, once it exists, will need to call into this
- Dominant language
- Kotlin
- Stars
- 10
- Forks
- 2
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 13
Contributor guide
No contributing guide indexed for this repository
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.
More from worldline/devview
-
enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 45/100
All issues in worldline/devview
Similar issues
-
autoteam community team/use
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
android: AlbumArtistDetailViewModel keeps groupKeys of albums that disappeared in expandedAlbums Opentask
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
aaif-goose/goose#12496 ·
-
Schema rejections are neither logged nor attributed, so the offending object cannot be identified Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
zotero/zotero-android#350 ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Richie97/track-history#325 ·