Configuration
There are 2 ways to configure springwolf:
application.properties, which is simple and should suit most use-casesAsyncApiDocket, which allows adding producers and consumers via code (and avoiding annotations)
- application.properties
- AsyncApiDocket
springwolf.docket.base-package=io.github.stavshamir.springwolf.example
springwolf.docket.id=urn:io:github:stavshamir:springwolf:example
springwolf.docket.default-content-type=application/json
springwolf.docket.info.title=${spring.application.name}
springwolf.docket.info.version=1.0.0
springwolf.docket.info.description=Springwolf example project to demonstrate springwolfs abilities
springwolf.docket.info.terms-of-service=http://asyncapi.org/terms
springwolf.docket.info.contact.name=springwolf
springwolf.docket.info.contact.email=example@example.com
springwolf.docket.info.contact.url=https://github.com/springwolf/springwolf-core
springwolf.docket.info.license.name=Apache License 2.0
springwolf.docket.servers.kafka.protocol=kafka
springwolf.docket.servers.kafka.url=${spring.kafka.bootstrap-servers}
@Configuration
public class AsyncApiConfiguration {
private final String BOOTSTRAP_SERVERS;
public AsyncApiConfiguration(@Value("${kafka.bootstrap.servers}") String bootstrapServers) {
this.BOOTSTRAP_SERVERS = bootstrapServers;
}
@Bean
public AsyncApiDocket asyncApiDocket() {
Info info = Info.builder()
.title("Springwolf example project - Kafka")
.version("1.0.0")
.contact(Contact.builder()
.name("springwolf")
.url("https://github.com/springwolf/springwolf-core")
.email("example@example.com")
.build())
.description("Springwolf example project to demonstrate springwolfs abilities")
.license(License.builder()
.name("Apache License 2.0")
.build())
.build();
return AsyncApiDocket.builder()
.basePackage("io.github.stavshamir.springwolf.example.consumers")
.info(info)
.id("urn:io:github:stavshamir:springwolf:example")
.defaultContentType("application/json")
.server("kafka", Server.builder()
.protocol("kafka")
.url(BOOTSTRAP_SERVERS)
.build())
.build();
}
}
Properties
basePackage (required)
It is recommended to structure the project such that all consumers and producers (classes containing listener/producer methods) are in the same package - it is not mandatory, and if they are scattered across multiple packages, just provide the highest in hierarchy package that contains all of them.
The base package will be scanned for classes containing @Component annotated classes (that includes @Service annotated classes) for methods annotated with @KafkaListener, @RabbitListener, @AsyncListener, @AsyncPublisher, etc.
id
The Identifier value represents a unique universal identifier of the application. See Identifier.
default-content-type
A string representing the default content type to use when encoding/decoding a message's payload. See Default Content Type
Info (required)
The Info object provides metadata about the API (see Info Object).
All provided fields will be present in the generated document, but not all will be displayed in the UI.
Server
The Server object provides metadata the can help the reader understand the protocol, version, login details and more (see Server Object).
An AsyncAPI document can contain more than one server, but it is not common.
As with the Info object, all provided fields will be present in the generated document, but not all will be displayed in the UI.
Additional application.properties
The following table contains additional properties that can be specified in the application.properties file:
| Property Name | Default Value | Description |
|---|---|---|
springwolf.enabled | true | Allows to enable/disable springwolf at one central place. |
springwolf.paths.docs | /springwolf/docs | The path of the AsyncAPI document in JSON format. Note that at the moment the UI will work only with the default value. |
springwolf.scanner.consumer-data.enabled | true | Enable scanner to find consumers defined in AsyncApiDocket. |
springwolf.scanner.producer-data.enabled | true | Enable scanner to find producers defined in AsyncApiDocket. |
springwolf.scanner.async-listener.enabled | true | Enable scanner to find methods annotated with @AsyncListener. |
springwolf.scanner.async-publisher.enabled | true | Enable scanner to find methods annotated with @AsyncPublisher. |
| AMQP | ||
springwolf.plugin.amqp.publishing.enabled | false | Allow (anyone) to produce amqp messages from the UI. Note that this has security implications |
springwolf.plugin.amqp.scanner.rabbit-listener.enabled | true | Enable scanner to find methods annotated with @RabbitListener. |
| Kafka | ||
springwolf.plugin.kafka.publishing.enabled | false | Allow (anyone) to produce kafka messages from the UI. Note that this has security implications |
springwolf.plugin.kafka.publishing.producer | null | Configure the kafka producer used to publish messages from the UI. Uses identical parameters as spring.kafka.producer |
springwolf.plugin.kafka.scanner.kafka-listener.enabled | true | Enable scanner to find methods annotated with @KafkaListener. |