feature/avro specific records#142
Merged
Merged
Conversation
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.
Closes #128
Related to #131, #134, #139
The previous generator setup could preserve native Avro
schemaFormatpayloads, but it did not have a complete generation path for using those payloads as type-safe JVM artifacts. Native Avro schemas were still separate from the regular AsyncAPI Schema Object path, and Spring Kafka client generation could not yet use generated Avro payload types in producer, consumer, listener, or handler APIs.This was limiting because Avro is not just another JSON-compatible schema projection. Native Avro contracts should be consumed as Avro schemas, written as
.avscartifacts, and optionally compiled into Apache Avro JavaSpecificRecordclasses. For Spring Kafka APIs, those generated Avro classes are the type-safe payload surface we want to reference.For the proposed solution, native Avro generation now writes
.avscschema artifacts from AvroschemaFormatpayloads. It can also generate Apache Avro JavaSpecificRecordsource files by using Avro’s compiler. These Java sources are treated as their own generated artifact kind, so they can be routed to a Java source output directory instead of being mixed into Kotlin source output or resource output.The generator configuration was extended across core, CLI, Maven, and Gradle so users can explicitly enable native Avro generation and choose whether
SpecificRecordsources should be generated. By default, native Avro generation creates SpecificRecord sources when the native Avro capability is enabled.Spring Kafka client generation now supports native Avro message payloads. When a message payload uses a native Avro schema, the generated Spring Kafka producer, consumer, listener, and handler APIs reference the Java type declared by the Avro schema namespace and name. For example, an Avro schema with
namespace: com.example.avroandname: UserCreatedis used ascom.example.avro.UserCreated.The bundler was also adjusted so multi-format schema references can be bundled without being cast into regular AsyncAPI Schema Object models. This keeps native Avro schema references intact and avoids coupling native schema formats to the JSON-compatible model path.
Several error paths were tightened as well. Invalid native Avro schemas now fail with a domain-specific generator error. Native Avro schemas that cannot produce a named JVM client type, such as primitive Avro schemas, are rejected with a clear message explaining that generated client APIs require a named Avro record, enum, or fixed schema.
Approval coverage was added for native Avro output. The approved files now cover both the generated
.avscartifact and the generated Apache AvroSpecificRecordJava source, giving us a stable baseline for the actual generated output.The README was updated to document the current native Avro behavior, including Maven, Gradle, and CLI configuration examples. It also clarifies the boundary between Avro Projection and native Avro generation, and explains that Spring Kafka can reference native Avro payload types while runtime serializer/deserializer wiring is still handled by the consuming application.
Tests were added and updated for native Avro generation, SpecificRecord generation, output routing, approval baselines, configuration frontend behavior, Spring Kafka native Avro payload typing, compatibility validation, and bundling of multi-format schema references.