Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: 18.x
node-version: 22.x
cache: npm

- name: Install dependencies
Expand Down
24 changes: 14 additions & 10 deletions docs/configuration/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,31 @@ import CodeConfigurationProperties from '!!raw-loader!./snippets/_configuration_

# Configuration

Add the following to the spring `application.properties` file:
Starting in version 2.0.0, all properties are optional and have sensible defaults.

Selected configuration properties on short glance for the `application.properties` file:
<CodeBlock language="properties">{CodeConfigurationProperties}</CodeBlock>

## Properties
## Main Properties

### `base-backage`

### `base-backage` (required)
The `base-package` is scanned for listeners and publishers.

In detail, Springwolf searches for `@Component` annotated classes (that includes `@Service` annotated classes) with methods annotated with `@AsyncListener`, `@AsyncPublisher`, `@JmsListener`, `@KafkaListener`, `@MessageMapping`, `@RabbitListener`, `@SqsListener`, etc.
Also, `@Configuration` classes are scanned for `@Bean` classes containing the previously mentioned annotations.

It's recommended to structure the project such that all consumers and producers (classes containing listener/producer methods) are in the same package - it's not mandatory, and if they're scattered across multiple packages, just provide the highest in hierarchy package that contains all classes.

You can add multiple base packages separated by commas.

The `base-package` will be scanned for classes containing `@Component` annotated classes (that includes `@Service` annotated classes) for methods annotated with `@JmsListener`, `@KafkaListener`, `MessageMapping`, `@RabbitListener`, `@SqsListener`, `@AsyncListener`, `@AsyncPublisher`, etc.
`@Configuration` classes are scanned for `@Bean` containing the previously mentioned annotations as well.

### `Info` (required)
### `Info`

The `Info` object provides metadata about the API (see [Info Object](https://www.asyncapi.com/docs/reference/specification/v3.0.0#infoObject)).

All provided fields will be present in the generated document, but not all will be displayed in the UI.

### `Servers` (required)
### `Servers`

The `Server` object provides metadata to help the reader understand the protocol, version, login details and more (see [AsyncAPI Server Object](https://www.asyncapi.com/docs/reference/specification/v3.0.0#serversObject)).
Any name (`kafka-server` in the example) can be chosen.
Expand All @@ -35,7 +39,7 @@ An AsyncAPI document can contain more than one server, but it's 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`
## Additional Properties

The following table contains additional properties that can be specified in the `application.properties` file:

Expand Down Expand Up @@ -81,7 +85,7 @@ The following table contains additional properties that can be specified in the
The AsyncAPI specification allows the definition of additional data fields to extend the
specification at certain points (see [Specification Extensions](https://www.asyncapi.com/docs/reference/specification/v3.0.0#specificationExtensions) ).

Extension Fields may be added to `Info`, `Contact`, `License` and `Server` objects both via `application.properties`.
Extension Fields may be added to `Info`, `Contact`, `License` and `Server` objects in `application.properties`.
Every custom extension field must begin with `x-`, for example `x-internal-id` (see sample configurations above).

## Grouping
Expand Down
2 changes: 1 addition & 1 deletion docs/configuration/customizing.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public class TagCustomizer implements OperationCustomizer {

The `DefaultAsyncApiSerializerService` is responsible for serializing the AsyncAPI document into a `String` for the Controller.

Use `DefaultAsyncApiSerializerService#getJsonObjectMapper()` and `DefaultAsyncApiSerializerService#getYamlObjectMapper()` to customize the `ObjectMapper`.
Use `DefaultAsyncApiSerializerService#getJsonMapper()` and `DefaultAsyncApiSerializerService#getYamlMapper()` to customize the `ObjectMapper` (will change with migration to Jackson 3).

## `ChannelScanners` - Channel detection

Expand Down
2 changes: 1 addition & 1 deletion docs/configuration/documenting-consumers.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Below is an example to demonstrate the annotation:
))
@KafkaAsyncOperationBinding
public void receiveMessage(ExamplePayloadDto msg) {
// process
// do work
}
```

Expand Down
4 changes: 2 additions & 2 deletions docs/configuration/documenting-headers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public void receiveExamplePayload(
@Payload ExamplePayloadDto payload, // @Payload is required for multiple parameters
@Header(KafkaHeaders.RECEIVED_KEY) String key,
@Header(KafkaHeaders.OFFSET) Integer offset) {
// process
// do work
}
```

Expand Down Expand Up @@ -45,6 +45,6 @@ Again, the annotation property `headers` of `@AsyncOperation` allows to overwrit
)
))
public void sendMessage(ExamplePayloadDto msg) {
// process
// do work
}
```
2 changes: 1 addition & 1 deletion docs/configuration/documenting-messages.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ For example:
)
))
public void sendMessage(ExamplePayloadDto msg) {
// process
// do work
}
```

Expand Down
2 changes: 1 addition & 1 deletion docs/configuration/documenting-producers.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Below is an example to demonstrate the annotation:
))
@KafkaAsyncOperationBinding
public void sendMessage(ExamplePayloadDto msg) {
// process
// do work
}
```

Expand Down
11 changes: 5 additions & 6 deletions docs/configuration/snippets/_configuration_properties.properties
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
# Springwolf - required fields
# Springwolf - optional, auto-detected fields
springwolf.docket.base-package=io.github.springwolf.example
springwolf.docket.info.title=${spring.application.name}
springwolf.docket.info.version=1.0.0

springwolf.docket.servers.kafka-server.protocol=kafka
springwolf.docket.servers.kafka-server.host=${spring.kafka.bootstrap-servers}

# Springwolf - optional fields
springwolf.enabled=true
springwolf.docket.default-content-type=application/json
springwolf.docket.id=urn:io:github:springwolf:example
springwolf.docket.info.description=Springwolf example project to demonstrate springwolfs abilities
springwolf.docket.info.terms-of-service=http://asyncapi.org/terms
springwolf.docket.info.version=1.0.0
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.info.x-internal-id=xyz-123

springwolf.docket.servers.kafka-server.protocol=kafka
springwolf.docket.servers.kafka-server.host=${spring.kafka.bootstrap-servers}

# Springwolf - debugging
logging.level.io.github.springwolf=DEBUG
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
dependencies {
implementation 'io.swagger.core.v3:swagger-core-jakarta:2.2.32'
implementation 'io.swagger.core.v3:swagger-core-jakarta:2.2.40'
}
2 changes: 1 addition & 1 deletion docs/configuration/snippets/_schema_dependency_maven.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-core-jakarta</artifactId>
<version>2.2.32</version>
<version>2.2.40</version>
</dependency>
</dependencies>
56 changes: 52 additions & 4 deletions docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,52 @@ See [Static Generation](static-generation.md).
### Show `debug` output in the logs

Springwolf uses the default logging setup of Spring Boot.
To enable `DEBUG` output, add the following line to the `application.properties`:
To enable `DEBUG` output (`TRACE` for even more debugging), add the following line to the `application.properties`:

```properties
logging.level.io.github.springwolf=DEBUG
```

Log output:

```log
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/

:: Spring Boot :: (v4.0.2)

INFO 1792 --- [Springwolf example project - Kafka] [ Test worker] i.g.s.examples.kafka.ApiIntegrationTest : Starting ApiIntegrationTest using Java 17.0.7 with PID 1792 (started by user in /springwolf-core/springwolf-examples/springwolf-kafka-example)
DEBUG 1792 --- [Springwolf example project - Kafka] [ Test worker] i.g.s.examples.kafka.ApiIntegrationTest : Running with Spring Boot v4.0.2, Spring v7.0.3
INFO 1792 --- [Springwolf example project - Kafka] [ Test worker] i.g.s.examples.kafka.ApiIntegrationTest : No active profile set, falling back to 1 default profile: "default"
INFO 1792 --- [Springwolf example project - Kafka] [ Test worker] o.s.boot.tomcat.TomcatWebServer : Tomcat initialized with port 0 (http)
INFO 1792 --- [Springwolf example project - Kafka] [ Test worker] o.apache.catalina.core.StandardService : Starting service [Tomcat]
INFO 1792 --- [Springwolf example project - Kafka] [ Test worker] o.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/11.0.15]
INFO 1792 --- [Springwolf example project - Kafka] [ Test worker] b.w.c.s.WebApplicationContextInitializer : Root WebApplicationContext: initialization completed in 522 ms
DEBUG 1792 --- [Springwolf example project - Kafka] [ Test worker] i.g.s.c.c.SpringwolfUiResourceConfigurer : Serving Springwolf with base-path: /springwolf
DEBUG 1792 --- [Springwolf example project - Kafka] [ Test worker] i.g.s.c.c.PublishingBaseController : Message publishing via SpringwolfKafkaController is active.
INFO 1792 --- [Springwolf example project - Kafka] [ Test worker] o.s.b.a.e.web.EndpointLinksResolver : Exposing 1 endpoint beneath base path '/actuator'
INFO 1792 --- [Springwolf example project - Kafka] [ Test worker] o.s.boot.tomcat.TomcatWebServer : Tomcat started on port 8080 (http) with context path '/'
INFO 1792 --- [Springwolf example project - Kafka] [ Test worker] i.g.s.examples.kafka.ApiIntegrationTest : Started ApiIntegrationTest in 1.461 seconds (process running for 2.123)
DEBUG 1792 --- [Springwolf example project - Kafka] [ Test worker] .g.s.c.SpringwolfInitApplicationListener : Triggering asyncapi creation
DEBUG 1792 --- [Springwolf example project - Kafka] [ Test worker] i.g.s.c.asyncapi.DefaultAsyncApiService : Building AsyncAPI document
DEBUG 1792 --- [Springwolf example project - Kafka] [ Test worker] i.g.s.c.a.s.c.a.AnnotationScannerUtil : Detected method io.github.springwolf.examples.kafka.consumers.ExampleClassLevelKafkaListener#receiveMonetaryAmount
...
DEBUG 1792 --- [Springwolf example project - Kafka] [ Test worker] i.g.s.c.a.s.c.a.AnnotationScannerUtil : Detected method io.github.springwolf.examples.kafka.consumers.AvroConsumer#receiveExampleAvroPayload
DEBUG 1792 --- [Springwolf example project - Kafka] [ Test worker] i.g.s.c.asyncapi.DefaultAsyncApiService : Starting customizer io.github.springwolf.addons.json_schema.JsonSchemaCustomizer
DEBUG 1792 --- [Springwolf example project - Kafka] [ Test worker] i.g.s.c.a.grouping.AsyncApiGroupService : Loaded AsyncApiGroup from configuration: AsyncApiGroup(groupName=Only Vehicles, groupInfo=Info(title=null, version=1.0.0, description=This group only contains endpoints that are related to vehicles., termsOfService=null, contact=null, license=null, tags=null, externalDocs=null), operationActionsToKeep=[], channelNamesToKeep=[], messageNamesToKeep=[.*Vehicle.*])
DEBUG 1792 --- [Springwolf example project - Kafka] [ Test worker] i.g.s.c.asyncapi.DefaultAsyncApiService : AsyncAPI document was built
INFO 1792 --- [Springwolf example project - Kafka] [o-auto-1-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
INFO 1792 --- [Springwolf example project - Kafka] [o-auto-1-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
INFO 1792 --- [Springwolf example project - Kafka] [o-auto-1-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 1 ms
DEBUG 1792 --- [Springwolf example project - Kafka] [o-auto-1-exec-1] i.g.s.c.controller.AsyncApiController : Returning AsyncApi document for group Only Vehicles
DEBUG 1792 --- [Springwolf example project - Kafka] [o-auto-1-exec-2] i.g.s.c.controller.AsyncApiController : Returning AsyncApi document for group default
DEBUG 1792 --- [Springwolf example project - Kafka] [o-auto-1-exec-3] i.g.s.c.a.grouping.AsyncApiGroupService : Loaded AsyncApiGroup from configuration: AsyncApiGroup(groupName=Only Vehicles, groupInfo=Info(title=null, version=1.0.0, description=This group only contains endpoints that are related to vehicles., termsOfService=null, contact=null, license=null, tags=null, externalDocs=null), operationActionsToKeep=[], channelNamesToKeep=[], messageNamesToKeep=[.*Vehicle.*])
```

### The Springwolf UI isn't showing

When the `springwolf-ui` dependency is added, the UI should be visible at [http://localhost:8080/springwolf/asyncapi-ui.html](http://localhost:8080/springwolf/asyncapi-ui.html).
Expand Down Expand Up @@ -62,7 +102,7 @@ If not, whether
### Unable to publish message from the UI

Publishing messages from the UI is disabled by default due to security concerns.
Springwolf doesn't offer authentication nor authorization, anyone can publish messages to (production) channels.
Springwolf doesn't offer authentication nor authorization, anyone can publish messages to channels (in production).

Check the [configuration](configuration/configuration.mdx) to enable this feature.
Be sure to enable fully qualified names ([`use-fqn`](configuration/configuration.mdx)) as well.
Expand Down Expand Up @@ -112,7 +152,7 @@ public void sendMessage(ListWrapper<String> msg) {}
When Springwolf finds multiple consumers/producers for the same channel/topic, these are merged together.
This is expected, as there are use-cases where different payloads are sent via the same channel/topic.

Springwolf uses on scanners to find all consumer and producers in your application.
Springwolf uses scanners to find all consumer and producers in your application.
Most likely two scanners found your consumer/producer each.
See [configuration](configuration/configuration.mdx) to disable scanners.

Expand All @@ -131,7 +171,15 @@ See the [customization page](configuration/customizing.md)
Releases are managed in [GitHub Releases](https://github.com/springwolf/springwolf-core/releases),
which feature noteworthy changes, the full changelog and notes on how to migrate.

Since each release has a git _tag_, the [Springwolf examples for each plugin](https://github.com/springwolf/springwolf-core/blob/master/springwolf-examples) showcase the use of Springwolf for any previous version.
Since each release has a git [_tag_](https://github.com/springwolf/springwolf-core/tags),
the [Springwolf examples](https://github.com/springwolf/springwolf-core/blob/master/springwolf-examples) showcase the use of Springwolf for any version.

### Is Spring Boot 3.X supported

You can use an older version of Springwolf, which is build to support Spring Boot 3.X.
However, these versions don't get any updates.

Last version to support Spring Boot 3.X is `1.20.0` as Spring Boot 4 started the Springwolf 2.X release line.

### How to migrate from Springwolf 0.18.0 to 1.0.0

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
dependencies {
implementation 'io.github.springwolf:springwolf-common-model-converters:1.20.0'
implementation 'io.github.springwolf:springwolf-common-model-converters:2.0.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<dependency>
<groupId>io.github.springwolf</groupId>
<artifactId>springwolf-common-model-converters</artifactId>
<version>1.20.0</version>
<version>2.0.0</version>
</dependency>
</dependencies>
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
dependencies {
implementation 'io.github.springwolf:springwolf-generic-binding:1.20.0'
implementation 'io.github.springwolf:springwolf-generic-binding:2.0.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<dependency>
<groupId>io.github.springwolf</groupId>
<artifactId>springwolf-generic-binding</artifactId>
<version>1.20.0</version>
<version>2.0.0</version>
</dependency>
</dependencies>
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
dependencies {
implementation 'io.github.springwolf:springwolf-json-schema:1.20.0'
implementation 'io.github.springwolf:springwolf-json-schema:2.0.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<dependency>
<groupId>io.github.springwolf</groupId>
<artifactId>springwolf-json-schema</artifactId>
<version>1.20.0</version>
<version>2.0.0</version>
</dependency>
</dependencies>
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
dependencies {
implementation 'io.github.springwolf:springwolf-kotlinx-serialization-model-converter:1.20.0'
implementation 'io.github.springwolf:springwolf-kotlinx-serialization-model-converter:2.0.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<dependency>
<groupId>io.github.springwolf</groupId>
<artifactId>springwolf-kotlinx-serialization-model-converter</artifactId>
<version>1.20.0</version>
<version>2.0.0</version>
</dependency>
</dependencies>
31 changes: 17 additions & 14 deletions docs/quickstart.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,17 @@ import CodeSpringwolfMaven from '!!raw-loader!./snippets/_springwolf_maven.xml';

# Quickstart

*The following instructions are for Kafka services - other protocols are almost the same. Check out the [example project for complete examples](https://github.com/springwolf/springwolf-core/tree/master/springwolf-examples).*
In just 3 steps:

## 1. Add dependencies
1. Add dependency
2. Configure properties (optional)
3. Start application & View the docs

Let's get started!

*The following instructions are for Kafka services - [other protocols](./introduction/supported-protocols.md) are almost the same.*

## 1. Add dependency

Add the following dependencies:

Expand All @@ -24,30 +32,25 @@ Add the following dependencies:
</TabItem>
</Tabs>

Latest version: ![Maven Central](https://img.shields.io/maven-central/v/io.github.springwolf/springwolf-core?color=green&label=springwolf&style=plastic)
Latest version is ![Maven Central](https://img.shields.io/maven-central/v/io.github.springwolf/springwolf-core?color=green&label=springwolf&style=plastic)

## 2. Configure properties
## 2. Configure properties (optional)

Add the following to your application.properties:
To customize, add the following to your `application.properties`:

```properties
springwolf.docket.base-package=io.github.springwolf.example.consumers

springwolf.docket.info.title=${spring.application.name}
springwolf.docket.info.version=1.0.0

springwolf.docket.servers.kafka-server.protocol=kafka
springwolf.docket.servers.kafka-server.host=${spring.kafka.bootstrap-servers:localhost:29092}
```

*Make sure to change the value of `springwolf.docket.base-package` to the package containing your listeners, so that Springwolf will automatically pick them up.*

## 3. View the docs
## 3. Start application & View the docs

Start the application and open the URLs in your browser:

- JSON: [`<host>:<port>/springwolf/docs`](http://localhost:8080/springwolf/docs)
- YAML: [`<host>:<port>/springwolf/docs.yaml`](http://localhost:8080/springwolf/docs.yaml)
- AsyncAPI: [`<host>:<port>/springwolf/docs`](http://localhost:8080/springwolf/docs)
- Use the `Accept: application/yaml` header to request `yaml` instead of `json`
- UI: [`<host>:<port>/springwolf/asyncapi-ui.html`](http://localhost:8080/springwolf/asyncapi-ui.html)

If you configured a different context path in your application, make sure to prepend it to Springwolf URLs: `<host>:<port>/<context-path>/springwolf/asyncapi-ui.html`
Expand All @@ -57,5 +60,5 @@ If you configured a different context path in your application, make sure to pre
- [Kickstart Your AsyncAPI journey with Springwolf](https://www.youtube.com/live/nNl0HUdBnmg?t=1682) at AsyncAPI Webinar 2025
- [AsyncAPI and Springwolf presentation](https://www.youtube.com/watch?v=DylvTW_ia4Y) at Spring I/O 2024
- Read an elaborated tutorial on Baeldung at https://www.baeldung.com/java-spring-doc-asyncapi-springwolf
- Check out the [supported protocols and example projects](introduction/supported-protocols)
- Check out the [supported protocols](introduction/supported-protocols) and [example projects](https://github.com/springwolf/springwolf-core/tree/master/springwolf-examples)
- Dive deeper on the next pages
Loading