You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 ⬆️ Update compose-multiplatform to v1.3.0-alpha05 #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, object with properties, array with items, 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.
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 noexamplesentry, 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 acontent.<mediaType>.schemafor 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-writtenmocks.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 firstenumvalue 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 ⬆️ Update compose-multiplatform to v1.3.0-alpha05 #12, since that's a meaningfully different (and larger) problem: which schema variant to pick, not how to render a known schema.Acceptance criteria
enum,objectwithproperties,arraywithitems, and nullable fields.Files likely touched
devview-networkmock-core/src/commonMain/kotlin/com/worldline/devview/networkmock/core/repository/MockConfigRepository.kt(or wherever discovery lands post-Feature/analytics #4)devview-networkmock-core/src/commonMain/kotlin/com/worldline/devview/networkmock/core/openapi/(or wherever ✨ Add initial DevView #1's parser package lands)devview-networkmock/UI components if the "synthesized vs. real" visual distinction is built