KotlinxSchemaPlugin
Gradle plugin for generating JSON schemas using KSP2.
This plugin invokes KSP2 programmatically without applying the Google KSP Gradle plugin. It configures KSP tasks for each Kotlin compilation and generates schema extension properties.
The processor generates extension properties on KClass that provide JSON schema strings:
KClass<T>.jsonSchemaString: String- JSON schema as a stringKClass<T>.jsonSchema: JsonObject- JSON schema as a JsonObject
Generated files are placed under build/generated/kotlinxSchema/.
Usage:
plugins {
kotlin("multiplatform") version "2.2.21"
id("org.jetbrains.kotlinx.schema.ksp") version "0.0.4"
}
kotlinxSchema {
enabled.set(true) // Default: true
rootPackage.set("com.example") // Optional: filter by package
withSchemaObject.set(true) // Default: false, enables jsonSchema JsonObject property
}Content copied to clipboard