Mismatch between Channel Message and Schema object name
Bug description
When a producer (possibly consumer as well - not tested) payload class is annotated by Swagger @Schema annotation with name the name is used in the schema definitions but in the channel payload message a class simple name is used and therefore there is a mismatch between those 2 which leads to invalid AsyncAPI definition.
See the details in the AsyncAPI result bellow (ExamplePayloadDto vs ExampleProducerPayload)
Dependencies and versions used
springwolf-core version 0.7.0
swagger-annotations version 2.1.0
Code example Example Payload DTO:
import io.swagger.v3.oas.annotations.media.Schema;
@Schema(name = "ExampleProducerPayload")
public class ExamplePayloadDto {
private String someString;
public String getSomeString() {
return someString;
}
public void setSomeString(String someString) {
this.someString = someString;
}
}
AsyncApiDocket configuration:
@Bean
public AsyncApiDocket asyncApiDocket() {
Info info = Info.builder()
.version("1.0.0")
.title("Springwolf example project")
.build();
ProducerData exampleProducerData = ProducerData.builder()
.channelName("example-producer-topic")
.operationBinding(Map.of("pubsub", new KafkaOperationBinding()))
.payloadType(ExamplePayloadDto.class)
.build();
return AsyncApiDocket.builder()
.info(info)
.producer(exampleProducerData)
.build();
}
AsyncAPI result
{
"Springwolf example project": {
"asyncapi": "2.0.0",
"info": {
"title": "Springwolf example project",
"version": "1.0.0"
},
"servers": {},
"channels": {
"example-producer-topic": {
"subscribe": {
"bindings": {
"pubsub": {}
},
"message": {
"name": "com.example.springfoxexample.dto.ExamplePayloadDto",
"title": "ExamplePayloadDto",
"payload": {
"$ref": "#/components/schemas/ExamplePayloadDto"
}
}
}
}
},
"components": {
"schemas": {
"ExampleProducerPayload": {
"type": "object",
"properties": {
"someString": {
"type": "string"
}
},
"example": {
"someString": "string"
}
}
}
}
}
}
Thanks for reporting this, will look into it in the next few days
Fixed, will be available in next release (or see snapshot - current ui will not work with this version however)