Skip to content

Commit fcd0248

Browse files
committed
Correct reference resolution when root schema ID is a relative uri
1 parent ca45f15 commit fcd0248

File tree

1 file changed

+5
-0
lines changed
  • src/commonMain/kotlin/io/github/optimumcode/json/schema/internal

1 file changed

+5
-0
lines changed

src/commonMain/kotlin/io/github/optimumcode/json/schema/internal/SchemaLoader.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,11 @@ private data class DefaultLoadingContext(
610610
id.isAbsolute -> register(id.buildRefId(), assertion, dynamic) // register JSON schema by absolute URI
611611
id.isRelative ->
612612
when {
613+
// For root schema we should not apply any transformations to ID
614+
schemaPath === JsonPointer.ROOT && !id.path.isNullOrBlank() ->
615+
// Empty URI is used to normalize the path
616+
// Instead of 'path/segment' it will result '/path/segment
617+
register(Uri.EMPTY.appendPathToParent(id.path!!).buildRefId(), assertion, dynamic)
613618
!id.path.isNullOrBlank() ->
614619
register(
615620
// register JSON schema by related path

0 commit comments

Comments
 (0)