feat: synthesise response bodies from OpenAPI schemas
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 48/100
Research direction
Start with devview-networkmock-core/src/commonMain/kotlin/com/worldline/devview/networkmock/core/repository/MockConfigRepository.kt and the parser package introduced by #1/#4 to trace response discovery. Define the schema-synthesis utility under devview-networkmock-core/src/commonMain/kotlin/com/worldline/devview/networkmock/core/openapi/ and cover the listed schema shapes with unit tests. Done means schema-only responses produce bodies, nested and nullable cases work, and the UI distinguishes synthesized responses or documents that decision.
Written by the indexing model from the issue text.
Description
Part of #72
Depends on #1. Not blocking for 0.2.0 — follow-up depth issue.
Summary
When an OpenAPI operation declares a response (responses.<code>) but no examples entry, synthesize a plausible response body from the response's JSON Schema instead of the operation having zero mockable variants.
Current state
Per #1/#4, this migration's 0.2.0 scope only surfaces responses that have an explicit example (examples.<name>.externalValue). Many real-world OpenAPI specs declare a content.<mediaType>.schema for a response without ever attaching an example — those specs are still perfectly valid, but under 0.2.0 they'd show that response code with zero selectable variants in the DevView UI, which is a worse experience than the old probing-based discovery gave for a hand-written mocks.json (where at least an integrator could always add a matching file).
What to build
A schema → example synthesizer: given a Schema Object (type, properties, items, format, enum, etc.), generate a representative JSON value — e.g. string → "string" or the first enum value if present, integer/number → 0, boolean → false, object → recursively synthesized properties, array → a single-element array of the synthesized item type. Use this as the response body when no example exists for that status code.
Consider whether to cache synthesized bodies (they're deterministic per schema, so no need to regenerate on every discovery pass) and whether synthesized responses should be visually distinguished in the UI from author-provided examples (recommended — a user picking a mock should know whether they're looking at real example data or a generic placeholder).
Explicitly out of scope
allOf/oneOf/anyOf/discriminator resolution — tracked separately in #12, since that's a meaningfully different (and larger) problem: which schema variant to pick, not how to render a known schema.- Schema validation of any kind — this library mocks, it doesn't validate.
Acceptance criteria
- An operation with a declared response schema but no example produces a synthesized JSON body.
- Synthesis handles at minimum: primitives (string/integer/number/boolean),
enum,objectwithproperties,arraywithitems, and nullable fields. - Synthesized responses are visually distinguishable from example-provided responses in the UI (or a documented decision explaining why not).
- Unit tests cover each schema shape above plus nested objects/arrays.
Files likely touched
devview-networkmock-core/src/commonMain/kotlin/com/worldline/devview/networkmock/core/repository/MockConfigRepository.kt(or wherever discovery lands post-#4)- New schema-synthesis utility, likely
devview-networkmock-core/src/commonMain/kotlin/com/worldline/devview/networkmock/core/openapi/(or wherever #1's parser package lands) devview-networkmock/UI components if the "synthesized vs. real" visual distinction is built
- 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
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Richie97/track-history#325 ·
-
bug CLI documentation reliability
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
KW-related Type:bug UI / UX
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
RevenueCat/purchases-android#4299 · 1 comment ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
AAswordman/Operit#1265 · 3 comments ·