Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mismatch between Channel Message and Schema object name #100

Closed
jn-monster opened this issue Oct 5, 2022 · 2 comments
Closed

Mismatch between Channel Message and Schema object name #100

jn-monster opened this issue Oct 5, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@jn-monster
Copy link

jn-monster commented Oct 5, 2022

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"
          }
        }
      }
    }
  }
}
@jn-monster jn-monster added the bug Something isn't working label Oct 5, 2022
@jn-monster jn-monster changed the title Inconsistency between Channel Message and Schema object name Mismatch between Channel Message and Schema object name Oct 6, 2022
@stavshamir
Copy link
Member

Thanks for reporting this, will look into it in the next few days

@stavshamir
Copy link
Member

stavshamir commented Oct 15, 2022

Fixed, will be available in next release (or see snapshot - current ui will not work with this version however)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants