From a5d6d4b2250a338860e2e4117c792d6f7f522cfa Mon Sep 17 00:00:00 2001 From: Maxime MICHEL Date: Tue, 22 Sep 2026 11:42:32 +0200 Subject: [PATCH] :lock: Make MockHttpClientCall internal MockHttpClientCall was public purely because Ktor's HttpClientCall(client) base constructor requires it to be instantiable from the plugin's install code - nothing about it is meant to be integrator-facing, and its rawContent override already depends on the @InternalAPI-annotated Ktor API, so staying public compounded that instability risk onto this library's own public API surface. createMockHttpClientCall (the only caller) is already private in the same file, so this is a clean visibility narrowing with no call-site changes needed elsewhere. api.txt regenerated; no test or sample code constructed MockHttpClientCall directly. Closes #89. Co-Authored-By: Claude Sonnet 5 --- CHANGELOG.md | 8 ++++++++ devview-networkmock-ktor/CLAUDE.md | 1 - devview-networkmock-ktor/api/api.txt | 5 ----- .../devview/networkmock/ktor/plugin/NetworkMockPlugin.kt | 4 ++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d2eba07..7d89652 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 per-operation mock selections are untouched. (`devview-networkmock-core`, `devview-networkmock`, #90) +### Changed +- **Breaking:** `MockHttpClientCall` is now `internal` instead of `public` — it was only public + because Ktor's `HttpClientCall(client)` base constructor required it to be instantiable from + the plugin's install code, not because integrators have a legitimate reason to construct it + themselves. Its `rawContent` override already depends on the `@InternalAPI`-annotated Ktor + API, so staying public compounded that instability onto this library's own tracked surface. + (`devview-networkmock-ktor`, #89) + ### Fixed - NetworkMock: replaced ~35 unconditional `println` calls in `MockConfigRepository` and `NetworkMockPlugin` with gated [Kermit](https://github.com/touchlab/Kermit) logging diff --git a/devview-networkmock-ktor/CLAUDE.md b/devview-networkmock-ktor/CLAUDE.md index 89baa5e..512d830 100644 --- a/devview-networkmock-ktor/CLAUDE.md +++ b/devview-networkmock-ktor/CLAUDE.md @@ -25,7 +25,6 @@ val client = HttpClient(OkHttp) { - `NetworkMockPlugin` — the `HttpClientPlugin` singleton (`NetworkMockPlugin.kt`) - `NetworkMockConfig` — DSL receiver; exposes `mockRepository` and `stateRepository` as nullable vars, plus `random: Random` (defaults to `Random.Default`) used for the `x-devview.failureRate` roll — override in tests to pin the outcome (`NetworkMockConfig.kt`) -- `MockHttpClientCall` — public subclass of `HttpClientCall` that wraps synthetic request/response data without touching the network (`NetworkMockPlugin.kt`) ## Interception Flow diff --git a/devview-networkmock-ktor/api/api.txt b/devview-networkmock-ktor/api/api.txt index 749649d..91a1a31 100644 --- a/devview-networkmock-ktor/api/api.txt +++ b/devview-networkmock-ktor/api/api.txt @@ -1,11 +1,6 @@ // Signature format: 4.0 package com.worldline.devview.networkmock.ktor.plugin { - public final class MockHttpClientCall extends io.ktor.client.call.HttpClientCall { - ctor public MockHttpClientCall(io.ktor.client.HttpClient client); - ctor public MockHttpClientCall(io.ktor.client.HttpClient client, io.ktor.client.request.HttpRequestData mockRequestData, io.ktor.client.request.HttpResponseData mockResponseData); - } - public final class NetworkMockConfig { ctor public NetworkMockConfig(); method @InaccessibleFromKotlin public com.worldline.devview.networkmock.core.repository.MockConfigRepository? getMockRepository(); diff --git a/devview-networkmock-ktor/src/commonMain/kotlin/com/worldline/devview/networkmock/ktor/plugin/NetworkMockPlugin.kt b/devview-networkmock-ktor/src/commonMain/kotlin/com/worldline/devview/networkmock/ktor/plugin/NetworkMockPlugin.kt index 408839d..3827c6f 100644 --- a/devview-networkmock-ktor/src/commonMain/kotlin/com/worldline/devview/networkmock/ktor/plugin/NetworkMockPlugin.kt +++ b/devview-networkmock-ktor/src/commonMain/kotlin/com/worldline/devview/networkmock/ktor/plugin/NetworkMockPlugin.kt @@ -428,8 +428,8 @@ private fun createMockHttpClientCall( * a synthetic response. Both [request] and [response] are set immediately in * the secondary constructor so the call is fully usable upon creation. */ -public class MockHttpClientCall(client: HttpClient) : HttpClientCall(client) { - public constructor( +internal class MockHttpClientCall(client: HttpClient) : HttpClientCall(client) { + constructor( client: HttpClient, mockRequestData: HttpRequestData, mockResponseData: HttpResponseData