You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import CodeConfigurationProperties from '!!raw-loader!./snippets/_configuration_properties.md';
8
+
import CodeConfigurationAsyncApiDocket from '!!raw-loader!./snippets/_configuration_asyncApiDocket.md';
4
9
5
10
# Configuration
6
11
7
-
## Configuration Class
12
+
## Activating
8
13
9
14
- You need to provide a configuration class annotated with:
10
15
1.`@Configuration`
@@ -14,31 +19,32 @@ sidebar_position: 3
14
19
```java
15
20
@Configuration
16
21
@EnableAsyncApi
17
-
publicclassAsyncApiConfiguration {
18
-
...
19
-
}
22
+
publicclassAsyncApiConfiguration { }
20
23
```
21
24
22
-
## AsyncApiDocket
25
+
## Springwolf configuration
23
26
24
-
You need to provide an `AsyncApiDocket` bean, which provides Springwolf with metadata that is either not specified in code or can't be picked up automatically.
27
+
There are 2 ways to configure springwolf:
25
28
26
-
```java
27
-
@Bean
28
-
publicAsyncApiDocket asyncApiDocket() {
29
-
returnAsyncApiDocket.builder()
30
-
.basePackage(...)
31
-
.info(...)
32
-
.server(...)
33
-
.build();
34
-
}
35
-
```
29
+
1.`application.properties`, which is simple and should suit most use-cases
30
+
2.`AsyncApiDocket`, which allows adding producers and consumers via code (and avoiding annotations)
It is recommended to structue the project such that all consumers (classes containing listener methods) are in the same package - it is not mandatory, and if the consumer are scattered across multiple packages, just provide the highest in hierarchy package that containes all of them.
45
+
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.
40
46
41
-
The base package will be scanned for classes containing `@Component` annotated classes (that includes `@Service` annotated classes) for methods annotated with `@KafkaListener`, `@RabbitListener`, etc.
47
+
The base package will be scanned for classes containing `@Component` annotated classes (that includes `@Service` annotated classes) for methods annotated with `@KafkaListener`, `@RabbitListener`, `@AsyncSubscriber`, `@AsyncPublisher`, etc.
42
48
43
49
### Info (required)
44
50
@@ -52,33 +58,18 @@ The `Server` object provides metadata the can help the reader understand the pro
52
58
53
59
An AsyncAPI document can contain more than one server, but it is not common.
54
60
55
-
The server is provided to the document with an arbitrary name as the key, and a `Server` object as the value:
56
-
57
-
```java
58
-
@Bean
59
-
publicAsyncApiDocket asyncApiDocket() {
60
-
Server kafkaServer =Server.builder()
61
-
.protocol("kafka")
62
-
.url(BOOTSTRAP_SERVERS)
63
-
.build();
64
-
65
-
returnAsyncApiDocket.builder()
66
-
.basePackage(...)
67
-
.info(...)
68
-
.server("whatever name you want", kafkaServer)
69
-
.build();
70
-
}
71
-
```
72
-
73
61
As with the `Info` object, all provided fields will be present in the generated document, but not all will be displayed in the UI.
74
62
75
-
## application.properties
63
+
## Additional `application.properties`
76
64
77
-
The following table contains the complete list of additional properties that can be specified in the `application.properties` file:
65
+
The following table contains additional properties that can be specified in the `application.properties` file:
78
66
79
-
| Property Name | Default Value | Description |
80
-
| ------------- | ------------- | ----------- |
81
-
|`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.enabled`|`true`| Allows to disable springwolf at one central place. |
70
+
|`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.*|
71
+
|`springwolf.plugin.amqp.publishing.enabled`|`false`| Allow (anyone) to produce amqp messages from the UI. *Note that this has security implications*|
72
+
|`springwolf.plugin.kafka.publishing.enabled`|`false`| Allow (anyone) to produce kafka messages from the UI. *Note that this has security implications*|
*Make sure to change the value of `springwolf.docket.base-package` to the package containing your listeners.*
52
+
63
53
## View the docs
64
54
After starting the application, visit `<host>:<port>/springwolf/asyncapi-ui.html` to view the UI or `<host>:<port>/springwolf/docs` to view the raw AsyncAPI document.
65
55
66
56
If you configured a different context path in your application, make sure to prepend it to springwolf urls, i.e. `<host>:<port>/<context-path>/springwolf/asyncapi-ui.html`
0 commit comments