Skip to content

feat: migrate networkmock config to OpenAPI 3.x - #104

Open
MaxMichel2 wants to merge 6 commits into
mainfrom
feat/networkmock-openapi-format
Open

feat: migrate networkmock config to OpenAPI 3.x#104
MaxMichel2 wants to merge 6 commits into
mainfrom
feat/networkmock-openapi-format

Conversation

@MaxMichel2

Copy link
Copy Markdown
Collaborator

Summary

First PR of the milestone 0.2.0 OpenAPI migration (epic #72). Replaces the bespoke mocks.json format with OpenAPI 3.x (JSON, YAML best-effort via kaml), removes the environment axis entirely, and adopts OpenAPI vocabulary across the public API of all three networkmock modules.

Closes #73, #74, #75, #76, #78, #94

This is the "core break" PR — see #72 for the full milestone plan. Deliberately not included here, tracked for follow-up PRs:

What changed

  • Core engine (devview-networkmock-core): new internal openapi/ package (OpenApiDocument, OpenApiParser, YamlSupport) is the only format-aware code in the library — no OpenAPI-shaped type leaks past MockConfigRepository. $ref/externalValue resolve one level deep, locally or into another file. Response variant discovery now reads declared responses.<code>.content.*.examples instead of probing status-code/suffix combinations. x-devview.delayMs replaces defaultDelayMs/delayMs (document-level default, operation-level override).
  • Rename to OpenAPI vocabulary: ApiGroupConfigApiSpec, EndpointConfigOperation, EndpointKeyOperationKey (drops environmentId), EndpointDescriptorOperationDescriptor, EndpointMockStateOperationMockState, GroupEnvironmentUiModelApiSpecUiModel, EndpointUiModelOperationUiModel. MockResponse and MockMatch are deliberately not renamed — they model DevView's own runtime mocking behavior (a served response, a request-to-operation match), not something OpenAPI describes. EnvironmentConfig, EndpointOverride, and effectiveEndpoints are deleted outright (pre-1.0, no deprecation path).
  • State shape: OperationMockState.Mock is now keyed by (statusCode, exampleName) instead of a response file name. DataStore entries under the pre-0.2.0 key shape are wiped once on first launch after upgrading (gated by a schema version marker) — chose wipe over a best-effort translation since the key shape and the payload shape changed at once (see fix: prune orphaned DataStore keys after the key-shape change #78); this is disabled-by-default developer-tooling state, not user data.
  • UI / Ktor (devview-networkmock, devview-networkmock-ktor): adapted to the renamed core API. Tabs are now one per spec instead of one per group+environment. NetworkMock's constructor takes specPaths: List<String> instead of a single configPath, with no default.
  • Sample app: mocks.json replaced by two specs (jsonplaceholder.json, sample-api.json). The old prod-environment override that rewrote getUserProfile's path between staging/prod is now a proper second operation, getUserProfileV2, in the same spec with two servers — the OpenAPI-native replacement for what the environment axis was actually being used for.
  • Docs: root README/CLAUDE.md/CHANGELOG, getting-started guides, all docs/modules/networkmock*.md pages, and the add-destination skill's example.

Test plan

  • testAndroidHostTest green in devview-networkmock-core, devview-networkmock, devview-networkmock-ktor
  • detektFull and konsist:test green across the repo
  • metalavaGenerateSignature regenerated for all three networkmock modules (devview-networkmock-ktor's public surface was unaffected)
  • devview-networkmock-core cross-compiles for iosArm64 and iosSimulatorArm64 — verifies kaml (YAML support) works on iOS, not just JVM
  • sample:androidApp:assembleDebug succeeds end-to-end against the new spec files
  • Manual check in the running sample app: two spec tabs (JSONPlaceholder, Sample API), getUserProfile/getUserProfileV2 both listed, mock toggling works, delays apply

Co-Authored-By: Claude Sonnet 5 noreply@anthropic.com

MaxMichel2 and others added 6 commits August 24, 2026 17:57
…lude

Adds the graphify skill/agent tooling and a generated knowledge graph
(graphify-out/) for codebase navigation, plus a PreToolUse hook that
nudges toward graphify query over raw grep. Also removes the stale
BootstrapKmp exclude pattern from the Detekt default config, a
leftover template artifact with no matching class in this codebase.
The post-commit graphify hook auto-rebuilt the graph after the prior
commit, picking up a graphify version bump (v0.9.33 -> v0.9.49-s2) that
forced a full re-extraction (2522->2584 nodes, 212->222 communities).
That rebuild path is AST-only (no LLM), so it fell back to naming
communities after their hub node instead of the curated plain-language
names. Re-labels all 222 communities and regenerates GRAPH_REPORT.md,
graph.html, and the labels/.sig sidecar accordingly.
Replaces the bespoke mocks.json format with one OpenAPI 3.x document
(JSON, YAML best-effort via kaml) per API group, across all three
networkmock modules plus the sample app. No intermediate state in this
diff compiles independently - the core model change, its consumers,
and the sample's registration call all have to move together.

## Core engine (devview-networkmock-core)

The environment axis is gone entirely - a group's request-matching
hosts now come from the spec's servers[] list, so an app talking to
two hosts for the same API is just two operations with different
paths in one document, not two environments.

Renamed to OpenAPI vocabulary: ApiGroupConfig -> ApiSpec, EndpointConfig
-> Operation, EndpointKey -> OperationKey (drops environmentId),
EndpointDescriptor -> OperationDescriptor, EndpointMockState ->
OperationMockState. MockResponse and MockMatch are deliberately not
renamed - they model DevView's own runtime mocking behavior, not
something OpenAPI describes. EnvironmentConfig, EndpointOverride, and
effectiveEndpoints are deleted outright (pre-1.0, no deprecation path).

Response variant discovery now reads the spec's declared
responses.<code>.content.*.examples instead of probing status-code and
filename-suffix combinations against the filesystem.
OperationMockState.Mock is now keyed by (statusCode, exampleName)
instead of a response file name. Response delay simulation moves to
the x-devview OpenAPI Specification Extension, at the document root
(spec-wide default) and/or per operation (overrides the default).

DataStore entries under the pre-0.2.0 key shape are wiped once on
first launch after upgrading, gated by a schema version marker - the
key shape and the Mock payload shape both changed at once, so a
best-effort translation wasn't attempted.

The new core/openapi package is the only format-aware code in the
module and is entirely internal - no OpenAPI-shaped type is visible
outside MockConfigRepository's implementation, which keeps a second,
lower-ceremony config format cheap to add later.

## UI and Ktor plugin (devview-networkmock, devview-networkmock-ktor)

Adapted to the renamed core API: GroupEnvironmentUiModel -> ApiSpecUiModel,
EndpointUiModel -> OperationUiModel. Tabs are now one per spec instead
of one per group+environment combination. NetworkMock's constructor
takes specPaths: List<String> instead of a single configPath, with no
default - integrators list every spec file explicitly.

## Sample app

mocks.json is replaced by two specs (jsonplaceholder.json, sample-api.json).
The old prod-environment override that rewrote getUserProfile's path
between staging and prod is now a proper second operation,
getUserProfileV2, sharing the same spec with two servers - the
OpenAPI-native replacement for what the environment axis was really
being used for.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Updates every doc page and CLAUDE.md that described the old mocks.json
format, the environment axis, or the single configPath entry point:
root README/CLAUDE.md/CHANGELOG, the getting-started guides, all
docs/modules/networkmock*.md pages, and the add-destination skill's
EndpointKey example.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Re-extracts the knowledge graph following the mocks.json -> OpenAPI
3.x migration (new openapi/ package, renamed model/UI types across
three modules). AST-only rebuild via the post-commit hook, no LLM
relabeling - community names may drift from their curated labels until
the next `graphify label` pass.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Section.containerColor and Section.contentColor were already public
API as of f050eed but api.txt was never regenerated after that commit.
Caught while running metalava across the full project during the
networkmock migration; no source change here, just catching the
signature file up to what was already committed.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: OpenAPI 3.x spec loader (JSON + YAML)

1 participant