Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

feat: synthesise response bodies from OpenAPI schemas

Aperta
#82 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

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
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
kotlin, openapi
Ambito
api, tooling

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

enhancement

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, 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.

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

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di worldline/devview

Tutte le issue di worldline/devview

Issue simili

Altre issue su Kotlin

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.