Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,3 @@ docs/api
docs/sample
docs/changelog.md
docs/markdown.md
publishing-progress.md
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@ All notable changes to this project are documented in this file.

## Unreleased

### Changed
- Downgraded Kotlin from 2.4.10 to 2.3.21 for broader consumer compatibility.
- Removed `compose-stability-analyzer` plugin (KMP incompatible).

### Documentation
- Updated minimum Kotlin version requirement to 2.3.21 in installation guide.
- Added acknowledgment for chrisbanes/haze inspiration.
- Added GitHub issue templates for bugs and feature requests.

### Quality
- Added Metalava API tracking to all published modules.
- Improved CI infrastructure: split workflows to Linux/macOS, added snapshot deploy, replaced `release.sh` with platform-agnostic `release.py`.
- Enabled automatic Maven Central publishing.

## [0.1.0] - 2026-07-15

### Added
Expand Down
243 changes: 0 additions & 243 deletions TODO-endpoint-preview.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.worldline.devview.networkmock.core.model.MockMatch
import com.worldline.devview.networkmock.core.model.MockResponse
import com.worldline.devview.networkmock.core.model.effectiveEndpoints
import com.worldline.devview.networkmock.core.repository.MockConfigRepository.Companion.DEFAULT_STATUS_CODES
import kotlinx.serialization.SerializationException
import kotlinx.serialization.json.Json

/**
Expand Down Expand Up @@ -181,50 +182,59 @@ public class MockConfigRepository(
*
* @return A [Result] containing the [MockConfiguration] on success, or an error on failure
*/
public suspend fun loadConfiguration(): Result<MockConfiguration> = runCatching {
cachedConfig?.let {
println(
message = "[NetworkMock][Config] Using cached configuration with ${it.apiGroups.size} group(s)"
)
return@runCatching it
}

println(message = "[NetworkMock][Config] Loading configuration from: $configPath")
public suspend fun loadConfiguration(): Result<MockConfiguration> {
// ponytail: explicit try-catch instead of runCatching — K/N's inline expansion of runCatching
// does not reliably catch exceptions thrown by suspend calls in the generated state machine.
return try {
cachedConfig?.let {
println(
message = "[NetworkMock][Config] Using cached configuration with ${it.apiGroups.size} group(s)"
)
return Result.success(value = it)
}

val configBytes = resourceLoader(configPath)
val configJson = configBytes.decodeToString()
println(message = "[NetworkMock][Config] Loading configuration from: $configPath")

val config = json
.decodeFromString<MockConfiguration>(
string = configJson
)
cachedConfig = config
val configBytes = resourceLoader(configPath)
val configJson = configBytes.decodeToString()

println(message = "[NetworkMock][Config] Successfully loaded configuration:")
config.apiGroups.forEach { group ->
println(
message = "[NetworkMock][Config] Group: ${group.id} " +
"with ${group.endpoints.size} shared endpoint(s) " +
"and ${group.environments.size} environment(s)"
)
group.environments.forEach { env ->
println(
message = "[NetworkMock][Config] Environment: ${env.id} (${env.url})"
val config = json
.decodeFromString<MockConfiguration>(
string = configJson
)
}
group.endpoints.forEach { endpoint ->
cachedConfig = config

println(message = "[NetworkMock][Config] Successfully loaded configuration:")
config.apiGroups.forEach { group ->
println(
message = "[NetworkMock][Config] - ${endpoint.method} ${endpoint.path} (${endpoint.id})"
message = "[NetworkMock][Config] Group: ${group.id} " +
"with ${group.endpoints.size} shared endpoint(s) " +
"and ${group.environments.size} environment(s)"
)
group.environments.forEach { env ->
println(
message = "[NetworkMock][Config] Environment: ${env.id} (${env.url})"
)
}
group.endpoints.forEach { endpoint ->
println(
message = "[NetworkMock][Config] - ${endpoint.method} ${endpoint.path} (${endpoint.id})"
)
}
}
}

config
}.onFailure { error ->
println(
message = "[NetworkMock][Config] ERROR: Failed to load configuration - ${error.message}"
)
error.printStackTrace()
Result.success(value = config)
} catch (e: IllegalStateException) {
println(
message = "[NetworkMock][Config] ERROR: Failed to load configuration - ${e.message}"
)
Result.failure(exception = e)
} catch (e: SerializationException) {
println(
message = "[NetworkMock][Config] ERROR: Failed to load configuration - ${e.message}"
)
Result.failure(exception = e)
}
}

/**
Expand Down Expand Up @@ -549,15 +559,17 @@ public class MockConfigRepository(
private suspend fun loadMockResponseFromPath(
filePath: String,
fileName: String
): MockResponse? = runCatching {
): MockResponse? = try {
val responseBytes = resourceLoader(filePath)
val content = responseBytes.decodeToString()
MockResponse.Companion
.fromFile(
fileName = fileName,
content = content
)
}.getOrNull()
} catch (@Suppress("SwallowedException") e: IllegalStateException) {
null
}

/**
* Extracts the hostname from a URL string.
Expand Down
Loading