feat: synthesise response bodies from OpenAPI schemas
I maintainer di solito rispondono entro 17 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 48/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- Kotlin
- Stelle
- 11
- Fork
- 3
- Merge medio
- 10g 9h
- PR unite (30g)
- 18
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di worldline/devview
-
enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
worldline/devview#99 · 4 commenti ·
I maintainer di solito rispondono entro 17 giorni
-
enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 45/100
worldline/devview#97 · 4 commenti ·
I maintainer di solito rispondono entro 17 giorni
-
enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
worldline/devview#95 · 4 commenti ·
I maintainer di solito rispondono entro 17 giorni
-
enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
worldline/devview#85 · 3 commenti ·
I maintainer di solito rispondono entro 17 giorni
-
enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
worldline/devview#84 · 3 commenti ·
I maintainer di solito rispondono entro 17 giorni
Tutte le issue di worldline/devview
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 73/100
tortuvshin/open-apps#377 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
supabase-community/supabase-kt#1413 ·
I maintainer di solito rispondono entro 5 giorni
-
Type: Possible bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
spacecowboy/Feeder#1258 ·
I maintainer di solito rispondono entro 1 giorno
-
[Submission] 抖音火山版Apertasubmit-adaption submit-adaption-pre
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
BetterAndroid/android-notification-icon-project#744 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
utopia-rise/godot-jvm#1004 ·
I maintainer di solito rispondono entro 1 giorno