openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

[REQ][Kotlin] Fake mock library on OpenAPI examples

Open Marimu opened this issue 1 month ago • 0 comments

Many Kotlin/mobile developers need to work with APIs without depending on a running backend. Currently, offline development or mock flavors require either:

  • Maintaining large amounts of hand-written or recorded JSON mock data
  • Writing custom fake clients by hand

This is time-consuming, error-prone, and difficult to maintain when the API changes.


Describe the solution you'd like

I propose adding a new Kotlin client library type:

--library=fake

This would generate:

  1. Standard models (unchanged)
  2. Standard API interfaces (unchanged)
  3. Fake API implementations (FakeApi) for each API interface

Each fake API method would return data derived from the OpenAPI specification:

  • Example fields, if present
  • Default values, if present
  • Schema-derived fake data as fallback (strings, numbers, enums, nested objects, arrays)

This approach produces a fully on-device mock client, with no server, Docker, or Node process required.


Describe alternatives you've considered

  • WireMock / MockWebServer / Prism / Mockoon

    • Requires running an embedded server or Node process
    • Not practical for Android mock flavors
    • Harder to keep in sync with API changes
  • Manually creating fake clients per API

    • High maintenance burden
    • Error-prone and repetitive
    • Difficult to scale for large APIs

Additional context

Marimu avatar Nov 25 '25 20:11 Marimu