Skip to content

Feature/external native schema files#146

Merged
bascunansalvador merged 24 commits into
feature/protobuf-runtime-generationfrom
feature/external-native-schema-files
Jun 18, 2026
Merged

Feature/external native schema files#146
bascunansalvador merged 24 commits into
feature/protobuf-runtime-generationfrom
feature/external-native-schema-files

Conversation

@bascunansalvador

Copy link
Copy Markdown
Collaborator

The previous implementation required native Avro and native Protobuf schemas to be written inline inside the AsyncAPI document. That worked for small examples, but it was not ideal for real projects where .avsc and .proto files are usually maintained as standalone schema assets.

This was also inconsistent with how teams normally work with native schema formats. Avro and Protobuf schemas often have their own tooling, validation, build steps, and ownership, so forcing the schema text into the AsyncAPI YAML made the contract harder to maintain.

For the proposed solution, native Avro and native Protobuf schemas can now be referenced from the AsyncAPI document through schema.$ref.

For example, native Avro schemas can now be written like this:

components:
  schemas:
    UserCreated:
      schemaFormat: application/vnd.apache.avro+json;version=1.9.0
      schema:
        $ref: schemas/UserCreated.avsc

Native Protobuf schemas can be written in the same style:

components:
  schemas:
    UserCreated:
      schemaFormat: application/vnd.google.protobuf;version=3
      schema:
        $ref: schemas/user-created.proto

The external schema path is resolved relative to the AsyncAPI file that owns the reference. This reuses the existing external-reference path handling so native schema assets follow the same project-local reference behavior as other external files.

The parser now reads external native schema assets as plain text instead of routing them through the YAML or JSON document reader. This is important because .avsc and .proto files are native schema assets, not AsyncAPI documents.

A domain-specific parse error was also added for missing or unreadable native schema files. This means users get a clear generator error when a referenced .avsc or .proto file cannot be read, instead of a low-level file or parsing failure.

The generator output contract was extended so external Avro files generate .avsc output and Java SpecificRecord sources, and external Protobuf files generate .proto output.

Spring Kafka generation was also covered end to end. Java and Kotlin Spring Kafka clients now resolve payload types from external native Avro and Protobuf schema files in both full and simple client modes.

The README was updated to document both inline native schema usage and external native schema file references.

The test coverage includes parser tests for external native Avro and Protobuf schema assets, a missing-file parser diagnostic test, generator output contract tests for external .avsc and .proto assets, and Spring Kafka runtime generation tests for Java and Kotlin full/simple clients.

bascunansalvador and others added 24 commits June 13, 2026 21:27
Introduce shared message header analysis so generated Spring Kafka producers and consumers can use typed header DTOs when AsyncAPI message headers are defined.

The Spring Kafka model preparation now carries header type metadata through the analyzer, payload model, Java/Kotlin factories, and templates. Generated producer and consumer APIs now include typed header parameters for messages with headers, while no-header messages keep the existing simpler signatures.

Producer templates now map non-null typed header values into Kafka record headers, and consumer templates expose the generated header type in handler signatures.

Add tests covering header analysis, Java Spring Kafka generation, and
Kotlin Spring Kafka generation so typed header imports, method
signatures, and producer header mapping remain stable.
…eration

Feature/protobuf java payload generation
@bascunansalvador bascunansalvador merged commit c27a850 into feature/protobuf-runtime-generation Jun 18, 2026
1 check passed
@bascunansalvador bascunansalvador deleted the feature/external-native-schema-files branch June 18, 2026 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant