Skip to content

adding the option to specify datatypes and constraints for @AsyncOperation.Headers.Header in io.github.springwolf.core.asyncapi.annotations #1506

@kostja86

Description

@kostja86

Describe the feature request
I specify my AsyncAPI code first. When displaying my AsyncAPI spec with the web-ui (e.g. http://localhost:8080/springwolf/asyncapi-ui.html), the datatypes of the payload are correctly displayed. But for header fields, the displayed datatype is always string without any constraints, regardless what is defined in the actual code.

For example:

I have the following publisher:

import io.github.springwolf.bindings.kafka.annotations.KafkaAsyncOperationBinding;
import io.github.springwolf.core.asyncapi.annotations.AsyncOperation;
import io.github.springwolf.core.asyncapi.annotations.AsyncPublisher;

@Service
public class EventProducerService {

    @AsyncPublisher(operation = @AsyncOperation(
            channelName = "[...]",
            description = "[...]",
            servers = {"kafka-server"},
            payloadType = [...]Payload.class,
            headers = @AsyncOperation.Headers(
                    schemaName = "[...]Header",
                    values = {
                            @AsyncOperation.Headers.Header(name = "consultant-number", description = "Identifier for the consultant."),
                            @AsyncOperation.Headers.Header(name = "client-number", description = "Identifier for the client."))
                    }
            )
    ))
    @KafkaAsyncOperationBinding()
    public Mono<Void> publishEvent([...], final Integer consultantNumber, final Integer clientNumber) {

[...]

specifics replaced with [...]

The actual datatypes for the header fields consultant-number and client-number are of type Integer, but there is no way to specify that.

This is displayed as follows with the web-ui:

Image

Also, the generated JSON looks as follows:

  "components": {
    "schemas": {
      "[...]Header": {
        "title": "[...]Header",
        "type": "object",
        "properties": {
          "client-number": {
            "type": "string",
            "description": "Identifier for the client.",
            "enum": []
          },
          "consultant-number": {
            "type": "string",
            "description": "Identifier for the consultant.",
            "enum": []
          },

There seems to be no way to define the datatype as well as constraints with @AsyncOperation.Headers.Header or define the headers with a Java Class like the payload with payloadType = [...]Payload.class.

Dependencies and versions used

  • springwolf-kafka version 1.17.0
  • springwolf-ui version 1.17.0

Motivation
It should be possible to define specific datatypes and constraints for header fields to provide a correct specification of my AsyncAPI for consumers.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions