kt-schema-apt
Compile-time JSON Schema generation for plain Java projects via a JSR 269 (javax.annotation.processing) annotation processor.
Analyzes @Schema-annotated Java types — or every type under a configured root package — at compile time, writing one JSON Schema resource per type. No Kotlin required in consuming code.
Platform Support: JVM only • Build-time only • Java 17+
Generated Output
@Schema
public record User(String name) {}
// Generated resource:
// META-INF/kt-schema/schemas/com/example/User.jsonUnlike kt-schema-ksp, this module has no Kotlin code to attach extension properties to, so it writes the serialized JsonSchema directly as a classpath resource instead of generating Kotlin source.
Configuration
Processor options, set via javac -A compiler arguments:
me.kpavlov.kt.schema.rootPackage— process every top-level type under this package (and sub-packages), in addition to@Schema-annotated types
See Java Annotation Processor Guide.
Features
Reuses the same
TypeGraphToJsonSchemaTransformeraskt-schema-ksp, so output ($id/$
defs/$ref/nullability) is identicalRecognizes description/ignore/name-override annotations from Jackson, LangChain4j, Koog, etc. via the shared
Introspectionsconfig, same as KSP and reflection