15

I have used Swagger to generate a document for rest API, but I am building Kafka listener and wanted to generate a document for it. Do we have any possibility using Swagger or something similar?

Thanks, Manish

krmanish007
  • 6,749
  • 16
  • 58
  • 100
  • Exactly what are you trying to document? A REST API is something that you might want to publish for external users to use. A Kafka listener does not hava a public API, it's just an internal implementation that receives records from Kafka. – Gary Russell Feb 22 '18 at 16:05
  • 2
    Interesting question. Messaging (via JMS with ActiveMQ) is the main way of communication between our services. We document all our listeners manually which is a great pain. I would love to have a "Swagger for messaging". – Thomas Uhrig Feb 22 '18 at 16:25
  • Hi @GaryRussell, our core domain layer is sending a different specialized message to the different topic, and this becomes a contract for another service, of what they are going to receive it. – krmanish007 Feb 22 '18 at 21:32
  • 1
    I am not sure it's entirely relevant to your requirements, but you might find [Spring Cloud Contract](https://cloud.spring.io/spring-cloud-contract/) interesting. – Gary Russell Feb 22 '18 at 21:58
  • thanks @GaryRussell I will have a look into it. – krmanish007 Feb 22 '18 at 22:26

2 Answers2

1

I have faced the same need, and decided to create something myself. I call it swagger4kafka, and it works very similar to swagger, but it documents @KafkaListener annotated methods instead of RestController methods.

Its source is hosted in github: swagger4kafka repository In the readme section you can find how to use it.

I would not say it is production ready yet, but I think it can be quite useful for internal use.

Stav Shamir
  • 888
  • 7
  • 20
1

Stav Shamir has actually created an improved open source solution called Springwolf.

It does auto-detect the KafkaListener annotations and creates AsyncAPI compliant documentation for the asynchronous world (i.e. Kafka) - just like Swagger does for synchronous REST APIs.

Timon Back
  • 11
  • 2