diff --git a/build.gradle.kts b/build.gradle.kts index 5f5b7781..e0976735 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -154,6 +154,8 @@ tasks.register("fatJar", type = Jar::class) { val compileJsonSchemas by tasks.registering(JavaCompile::class) { dependsOn(tasks.compileJava) + val schemaBaseUri = "http://localhost:8080/schemas/" + source = sourceSets.main.get().java include("org/asamk/signal/json/**/*.java") @@ -172,7 +174,7 @@ val compileJsonSchemas by tasks.registering(JavaCompile::class) { "-Amicronaut.processing.group=org.asamk", "-Amicronaut.processing.module=signal-cli", "-Amicronaut.processing.annotations=org.asamk.signal.json.*", - "-Amicronaut.jsonschema.baseUri=https://example.com/schemas", + "-Amicronaut.jsonschema.baseUri=$schemaBaseUri", ) ) @@ -186,7 +188,8 @@ val compileJsonSchemas by tasks.registering(JavaCompile::class) { fileTree(destinationDirectory.get().dir("META-INF/schemas").asFile) { include("*.schema.json") }.forEach { schemaFile -> - val prettyJson = JsonOutput.prettyPrint(schemaFile.readText()) + val normalized = schemaFile.readText().replace("\"$schemaBaseUri/", "\"") + val prettyJson = JsonOutput.prettyPrint(normalized) schemaFile.writeText("$prettyJson\n") } } diff --git a/src/main/resources/META-INF/schemas/sync-data-message.schema.json b/src/main/resources/META-INF/schemas/sync-data-message.schema.json index f61c33a5..265f5453 100644 --- a/src/main/resources/META-INF/schemas/sync-data-message.schema.json +++ b/src/main/resources/META-INF/schemas/sync-data-message.schema.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://example.com/schemas/sync-data-message.schema.json", + "$id": "sync-data-message.schema.json", "title": "SyncDataMessage", "type": "object", "properties": { @@ -14,28 +14,28 @@ "type": "string" }, "editMessage": { - "$ref": "https://example.com/schemas/edit-message.schema.json" + "$ref": "edit-message.schema.json" }, "adminDelete": { - "$ref": "https://example.com/schemas/admin-delete.schema.json" + "$ref": "admin-delete.schema.json" }, "attachments": { "type": "array", "items": { - "$ref": "https://example.com/schemas/attachment.schema.json" + "$ref": "attachment.schema.json" } }, "contacts": { "type": "array", "items": { - "$ref": "https://example.com/schemas/shared-contact.schema.json" + "$ref": "shared-contact.schema.json" } }, "expiresInSeconds": { "type": "integer" }, "groupInfo": { - "$ref": "https://example.com/schemas/group-info.schema.json" + "$ref": "group-info.schema.json" }, "isExpirationUpdate": { "type": "boolean" @@ -43,59 +43,59 @@ "mentions": { "type": "array", "items": { - "$ref": "https://example.com/schemas/mention.schema.json" + "$ref": "mention.schema.json" } }, "message": { "type": "string" }, "payment": { - "$ref": "https://example.com/schemas/payment.schema.json" + "$ref": "payment.schema.json" }, "pinMessage": { - "$ref": "https://example.com/schemas/pin-message.schema.json" + "$ref": "pin-message.schema.json" }, "pollCreate": { - "$ref": "https://example.com/schemas/poll-create.schema.json" + "$ref": "poll-create.schema.json" }, "pollTerminate": { - "$ref": "https://example.com/schemas/poll-terminate.schema.json" + "$ref": "poll-terminate.schema.json" }, "pollVote": { - "$ref": "https://example.com/schemas/poll-vote.schema.json" + "$ref": "poll-vote.schema.json" }, "previews": { "type": "array", "items": { - "$ref": "https://example.com/schemas/preview.schema.json" + "$ref": "preview.schema.json" } }, "quote": { - "$ref": "https://example.com/schemas/quote.schema.json" + "$ref": "quote.schema.json" }, "reaction": { - "$ref": "https://example.com/schemas/reaction.schema.json" + "$ref": "reaction.schema.json" }, "remoteDelete": { - "$ref": "https://example.com/schemas/remote-delete.schema.json" + "$ref": "remote-delete.schema.json" }, "sticker": { - "$ref": "https://example.com/schemas/sticker.schema.json" + "$ref": "sticker.schema.json" }, "storyContext": { - "$ref": "https://example.com/schemas/story-context.schema.json" + "$ref": "story-context.schema.json" }, "textStyles": { "type": "array", "items": { - "$ref": "https://example.com/schemas/text-style.schema.json" + "$ref": "text-style.schema.json" } }, "timestamp": { "type": "integer" }, "unpinMessage": { - "$ref": "https://example.com/schemas/unpin-message.schema.json" + "$ref": "unpin-message.schema.json" }, "viewOnce": { "type": "boolean" diff --git a/src/main/resources/META-INF/schemas/sync-message.schema.json b/src/main/resources/META-INF/schemas/sync-message.schema.json index 5dc499f7..3e4a7fa6 100644 --- a/src/main/resources/META-INF/schemas/sync-message.schema.json +++ b/src/main/resources/META-INF/schemas/sync-message.schema.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://example.com/schemas/sync-message.schema.json", + "$id": "sync-message.schema.json", "title": "SyncMessage", "type": "object", "properties": { @@ -19,14 +19,14 @@ "readMessages": { "type": "array", "items": { - "$ref": "https://example.com/schemas/sync-read-message.schema.json" + "$ref": "sync-read-message.schema.json" } }, "sentMessage": { - "$ref": "https://example.com/schemas/sync-data-message.schema.json" + "$ref": "sync-data-message.schema.json" }, "sentStoryMessage": { - "$ref": "https://example.com/schemas/sync-story-message.schema.json" + "$ref": "sync-story-message.schema.json" }, "type": { "type": "string", diff --git a/src/main/resources/META-INF/schemas/sync-story-message.schema.json b/src/main/resources/META-INF/schemas/sync-story-message.schema.json index 6dcfec8f..25643d52 100644 --- a/src/main/resources/META-INF/schemas/sync-story-message.schema.json +++ b/src/main/resources/META-INF/schemas/sync-story-message.schema.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://example.com/schemas/sync-story-message.schema.json", + "$id": "sync-story-message.schema.json", "title": "SyncStoryMessage", "type": "object", "properties": { @@ -14,7 +14,7 @@ "type": "boolean" }, "fileAttachment": { - "$ref": "https://example.com/schemas/attachment.schema.json" + "$ref": "attachment.schema.json" }, "groupId": { "type": "string" @@ -54,7 +54,7 @@ } }, "preview": { - "$ref": "https://example.com/schemas/preview.schema.json" + "$ref": "preview.schema.json" }, "style": { "type": "string"