feat: add Kotlin DSL sugar, URI templates, and a kotlinx.serialization bridge#74
Merged
Merged
Conversation
Adds Kotlin-idiomatic DSL/operator sugar for building and editing Url/Uri
values (buildUrl {}, Url.edit {}, path/query operators) and RFC 6570 URI
Template support (UriTemplate.parse/expand/match), under
org.dexpace.kuri.ktx and org.dexpace.kuri.template. Neither needs an
external dependency or an independent release cadence, so they ship as
part of the core kuri artifact rather than as separate modules.
A Public Suffix List prototype was evaluated alongside these but dropped —
it only had a placeholder rule set with no data generator behind it, so it
wasn't ready to ship.
Regenerates the JVM/Android/klib API dumps for the new ktx/template
symbols and adds test coverage for template edge cases (malformed
expressions, non-ASCII percent-encoding, uninvertible match() inputs).
Adds UrlSerializer/UriSerializer KSerializers so Url and Uri round-trip through any kotlinx.serialization format via their canonical string form, plus QueryParametersFormat for encoding and decoding QueryParameters to and from flat @serializable data classes. Named kuri-serde-kotlinx (package org.dexpace.kuri.serde) to leave room for other JSON-library backends later without the name implying it's the only serialization integration kuri has. Also fixes lint, detekt, and coverage gaps that surfaced once the module was actually wired into settings.gradle.kts and run through the gate for the first time.
OmarAlJarrah
force-pushed
the
refactor/fold-ktx-template-drop-psl
branch
from
July 15, 2026 11:00
82c0c2d to
14c5b49
Compare
The variable-name parser accepted names RFC 6570's grammar forbids
(varname = varchar *( ["."] varchar )): a leading, trailing, or doubled
dot, e.g. ".foo", "foo.", "a..b". validateName now walks the name as a
sequence of varchars with an optional single dot strictly between two
of them, matching the grammar exactly.
match() also mis-scoped its "trailing query expression" detection: it
treated any operator with named=true (which includes ";", not just "?"
and "&") as the query to invert. Since ";" renders as ";key=value" path
segments rather than a "?"-delimited query string, this let a lone
trailing ";" expression get dropped from the path pattern while the
query-side matcher short-circuited on an empty query, so matching the
empty string against a template like "{;a}" wrongly reported a match
with no bound variables instead of no match at all. Restricting the
check to the QUERY/CONTINUATION operators fixes this.
QueryEncoder didn't override shouldEncodeElementDefault, so kotlinx .serialization's inherited default (always encode, even when a property equals its declared default) applied. Encoding a value that left optional properties at their defaults spelled every one of them out (e.g. "q=only&page=1&sort=ASC" instead of just "q=only"), which is asymmetric with the decode side's documented "absent falls back to default" contract and produces needlessly verbose query strings. Overriding it to false mirrors Json's own default (encodeDefaults = false) and keeps encoded output minimal.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Url/Uri(buildUrl {},Url.edit {}, path/query operators) underorg.dexpace.kuri.ktx, and RFC 6570 URI Template support (UriTemplate.parse/expand/match) underorg.dexpace.kuri.template— both as part of the corekurimodule, since neither needs an external dependency or an independent release cadence to justify a separate artifact.kuri-serde-kotlinx, bridgingkuri'sUrl/Urito kotlinx.serialization:UrlSerializer/UriSerializerKSerializers, plusQueryParametersFormatfor encoding/decodingQueryParametersto/from flat@Serializabledata classes. Namedkuri-serde-kotlinx(not justkuri-serialization) to leave room for other JSON-library backends later.ktx/templatesymbols, and adds an initial JVM API dump forkuri-serde-kotlinx.match()inputs), and forkuri-serde-kotlinxpaths (scalar/list round-trips, nested-object rejection, missing-parameter and invalid-input decode failures).Test plan
:kuri:jvmTest,:kuri:ktlintCheck,:kuri:detekt:kuri:apiCheck(jvm, android, klib):kuri:koverVerify:kuri:jsNodeTest,:kuri:wasmJsNodeTest, native compile/test (macOS):kuri-serde-kotlinx:jvmTest,:kuri-serde-kotlinx:ktlintCheck,:kuri-serde-kotlinx:detekt:kuri-serde-kotlinx:apiCheck,:kuri-serde-kotlinx:koverVerify:kuri-serde-kotlinx:jsNodeTest,:kuri-serde-kotlinx:wasmJsNodeTest, native test (macOS)