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
Copy file name to clipboardExpand all lines: docs/configuration/configuration.md
+7-3Lines changed: 7 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,7 +31,7 @@ There are 2 ways to configure Springwolf which can't be combined:
31
31
32
32
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.
33
33
34
-
The base package will be scanned for classes containing `@Component` annotated classes (that includes `@Service` annotated classes) for methods annotated with `@KafkaListener`, `@RabbitListener`, `@SqsListener`, `@AsyncListener`, `@AsyncPublisher`, etc.
34
+
The base package will be scanned for classes containing `@Component` annotated classes (that includes `@Service` annotated classes) for methods annotated with `@JmsListener`, `@KafkaListener`, `@RabbitListener`, `@SqsListener`, `@AsyncListener`, `@AsyncPublisher`, etc.
35
35
36
36
### `id`
37
37
@@ -47,9 +47,9 @@ The `Info` object provides metadata about the API (see [Info Object][info]).
47
47
48
48
All provided fields will be present in the generated document, but not all will be displayed in the UI.
49
49
50
-
### `Server`
50
+
### `Servers`
51
51
52
-
The `Server` object provides metadata the can help the reader understand the protocol, version, login details and more (see [Server Object][server]).
52
+
The `Server` object provides metadata to help the reader understand the protocol, version, login details and more (see [AsyncAPI Server Object][server]).
53
53
54
54
An AsyncAPI document can contain more than one server, but it's not common.
55
55
@@ -75,13 +75,17 @@ The following table contains additional properties that can be specified in the
75
75
|`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.*|
76
76
|`springwolf.endpoint.actuator.enabled`|`false`| Publish the AsyncAPI document as part of Spring Boot’s actuator feature. |
77
77
|`springwolf.use-fqn`|`false`| Use fully qualified names for the schema classes. It's recommended and **required for publishing**, but deactivated due to backwards compatibility |
78
+
|`springwolf.payload.extractable-classes..`| N/A | Extract additional payload types. See [message payloads](documenting-messages.md) for more details. |
78
79
|`springwolf.scanner.consumer-data.enabled`|`true`| Enable scanner to find consumers defined in `AsyncApiDocket`. |
79
80
|`springwolf.scanner.producer-data.enabled`|`true`| Enable scanner to find producers defined in `AsyncApiDocket`. |
80
81
|`springwolf.scanner.async-listener.enabled`|`true`| Enable scanner to find methods annotated with `@AsyncListener`. |
81
82
|`springwolf.scanner.async-publisher.enabled`|`true`| Enable scanner to find methods annotated with `@AsyncPublisher`. |
82
83
|**AMQP**|||
83
84
|`springwolf.plugin.amqp.publishing.enabled`|`false`| Allow (anyone) to produce AMQP messages from the UI. *Note that this has security implications*|
84
85
|`springwolf.plugin.amqp.scanner.rabbit-listener.enabled`|`true`| Enable scanner to find methods annotated with `@RabbitListener`. |
86
+
|**JMS**|||
87
+
|`springwolf.plugin.jms.publishing.enabled`|`false`| Allow (anyone) to produce JMS messages from the UI. *Note that this has security implications*|
88
+
|`springwolf.plugin.jms.scanner.jms-listener.enabled`|`true`| Enable scanner to find methods annotated with `@JmsListener`. |
85
89
|**Kafka**|||
86
90
|`springwolf.plugin.kafka.publishing.enabled`|`false`| Allow (anyone) to produce Kafka messages from the UI. *Note that this has security implications*|
87
91
|`springwolf.plugin.kafka.publishing.producer`|`null`| Configure the Kafka producer used to publish messages from the UI. Uses identical parameters as `spring.kafka.producer`|
.description("Optional. Customer uploaded an example payload")
90
+
.payloadType(ExamplePayloadDto.class)
91
+
.headers(AsyncHeaders.NOT_USED)
92
+
.build();
93
+
```
94
+
95
+
## Binding properties
96
+
Explanation of the different binding properties.
97
+
98
+
### General
99
+
The following properties are the same for all bindings.
100
+
101
+
#### Queue Name (Channel Name)
102
+
103
+
The queue name that will be used to publish messages to by the UI.
104
+
105
+
#### Description
106
+
107
+
Optional. The description allows for human-friendly text to verbosely explain the _message_, like specific domain, what the topic is used for and which data it contains.
108
+
109
+
#### Payload Type
110
+
111
+
The class object of the payload that will be published to this channel.
112
+
113
+
#### Headers
114
+
115
+
The Kafka headers describing the metadata of the payload, more details in the generic ProducerData.
116
+
117
+
The Springwolf comes with a special `AsyncHeadersCloudEventConstants` to document CloudEvents.
118
+
119
+
The `kafka` header `__TypeId__` (constant from ` AbstractJavaTypeMapper.DEFAULT_CLASSID_FIELD_NAME`) can be documented as well.
120
+
121
+
### AMQP
122
+
123
+
#### Exchange Name
124
+
125
+
The exchange name that will be used to bind queues to.
126
+
127
+
#### Routing Key
128
+
129
+
The routing key used when publishing a message.
130
+
131
+
132
+
### Kafka
133
+
134
+
#### Group Id
135
+
The group id that will be used during message consumption
Copy file name to clipboardExpand all lines: docs/configuration/documenting-consumers.md
+14-78Lines changed: 14 additions & 78 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ For these use-cases, Springwolf provides additional ways to explicitly add them
12
12
To document consumers, either:
13
13
- add the `@AsyncListener` annotation or
14
14
- (deprecated) declare the `ConsumerData` object as part of the `AsyncApiDocket` or
15
-
- rely on the auto-detection of `@KafkaListener`, `@RabbitListener`, `@SqsListener`
15
+
- rely on the auto-detection of `@JmsListener`, `@KafkaListener`, `@RabbitListener`, `@SqsListener`
16
16
17
17
You are free to use all options together. Per channel and operation, first `ConsumerData` is used, then `@AsyncListener` and last the auto-detected annotations.
18
18
@@ -29,6 +29,7 @@ Below is an example to demonstrate the annotation:
29
29
@AsyncListener(operation=@AsyncOperation(
30
30
channelName="example-consumer-topic",
31
31
description="Optional. Customer uploaded an example payload",
32
+
servers= {"kafka"},
32
33
headers=@AsyncOperation.Headers(
33
34
schemaName="SpringKafkaDefaultHeaders",
34
35
values= {
@@ -37,6 +38,12 @@ Below is an example to demonstrate the annotation:
@@ -58,34 +65,14 @@ The channel name (or topic name in case of Kafka) - this is the name that will b
58
65
59
66
Optional. The description allows for human-friendly text to verbosely explain the _message_, like specific domain, what the topic is used for and which data it contains.
60
67
61
-
### Payload Type
62
-
63
-
The class object of the payload that will be consumed from this channel.
64
-
If not specified, it's extracted from the method arguments.
65
-
66
68
### Header
67
69
68
70
Optional. The headers describing the metadata of the payload.
69
71
70
-
### `@AmqpAsyncOperationBinding`
71
-
72
-
Associate this operation with AMQP, see [operation-binding] for details.
Associate this operation with Kafka, see [operation-binding] for details.
81
-
82
-
```java
83
-
@KafkaAsyncOperationBinding(
84
-
bindingVersion="1",
85
-
clientId="foo-clientId",
86
-
groupId="#{'foo-groupId'}"
87
-
)
88
-
```
74
+
Optional. Useful when an application is connect to multiple brokers and wants to indicate to which broker the channel belongs to.
75
+
The server needs to exist in [configuration > Servers](configuration.md) as well.
89
76
90
77
91
78
## Option 2: `ConsumerData` (deprecated)
@@ -133,7 +120,7 @@ Optional. The description allows for human-friendly text to verbosely explain th
133
120
134
121
### Binding
135
122
136
-
This property is used to discriminate the producer's protocol and provide protocol-specific properties (see [operation-binding])).
123
+
This property is used to discriminate the producer's protocol and provide protocol-specific properties (see [documenting bindings](documenting-bindings.md)).
137
124
138
125
### Payload Type
139
126
@@ -172,58 +159,7 @@ The above Kafka `ConsumerData` simplifies to the following `KafkaConsumerData`:
The `@JmsListener`, `@KafkaListener`, `@RabbitListener`, `@SqsListener` annotations are detected automatically.
177
164
There is nothing more to do.
178
165
Use the other options if the provided documentation is insufficient.
179
-
180
-
181
-
## AMQP Parameters
182
-
### Queue Name (Channel Name)
183
-
184
-
The queue name that will be used to consume messages from.
185
-
186
-
### Description
187
-
188
-
Optional. The description allows for human-friendly text to verbosely explain the _message_, like specific domain, what the topic is used for and which data it contains.
189
-
190
-
### Exchange Name
191
-
192
-
The exchange name that will be used to bind queues to.
193
-
194
-
### Routing Key
195
-
196
-
The routing key used when publishing a message.
197
-
198
-
### Payload Type
199
-
200
-
The class object of the payload that will be consumed from this channel.
201
-
202
-
203
-
## Kafka Parameters
204
-
205
-
### Topic Name (Channel Name)
206
-
207
-
The topic name that will be used to consume messages from.
208
-
209
-
### Description
210
-
211
-
Optional. The description allows for human-friendly text to verbosely explain the _message_, like specific domain, what the topic is used for and which data it contains.
212
-
213
-
### Payload Type
214
-
215
-
The class object of the payload that will be consumed from this channel.
216
-
217
-
### Headers
218
-
219
-
The Kafka headers describing the metadata of the payload, more details in the generic ConsumerData.
220
-
221
-
The Springwolf Kafka plugin comes with a special `AsyncHeadersForSpringKafkaBuilder` to document the `__TypeId__` header of the `spring-kafka` dependency.
Alternatively, the annotation property `payloadType` of `@AsyncOperation` allows to overwrite the detected class.
47
+
48
+
### Unwrapping the Payload
49
+
50
+
Sometimes, the payload type is wrapped in other objects.
51
+
Some wrappers are automatically unwrapped, including `Message<String>`, which becomes `String`.
52
+
53
+
:::note
54
+
The [configuration property](configuration.md) to modify the defaults is currently in _beta_.
55
+
:::
56
+
57
+
Assuming a method signature of `sendMessage(Function<Void, String> msg)`, where the actual payload is located in parameter index 1 (String).
58
+
Adding the configuration property `springwolf.payload.extractable-classes.java.util.function.Function=1` tells Springwolf how to handle this payload type.
59
+
60
+
The configuration property is split into three parts.
61
+
First, the base property `springwolf.payload.extractable-classes`.
62
+
Second, the canonical class name, `java.util.function.Function` in this case.
63
+
And third, the generic parameter index (`1`).
64
+
65
+
36
66
## Schema
37
67
38
68
Under the hood Springwolf relies on swagger-core `ModelConverters` to define the message schema.
39
69
40
70
By default, the type and example values for the properties are guessed.
41
71
The default Jackson `ModelResolver` supports schema definitions via `@Schema` to overwrite the property definitions.
42
72
43
-
## Using `@Schema`
73
+
###Using `@Schema`
44
74
45
75
The `@Schema` annotation allows to set many properties like `description`, `example`, `requiredMode` to document payloads.
46
76
@@ -84,6 +114,10 @@ The `@AsyncMessage.description` field will always override the `@Schema` descrip
84
114
85
115
For a full example, take a look at [ExamplePayloadDto.java in `springwolf-amqp-example`](https://github.com/springwolf/springwolf-core/blob/master/springwolf-examples/springwolf-amqp-example/src/main/java/io/github/stavshamir/springwolf/example/amqp/dtos/ExamplePayloadDto.java)
86
116
117
+
### `json-schema`
118
+
119
+
The [`springwolf-add-ons/springwolf-json-schema`](https://github.com/springwolf/springwolf-core/tree/master/springwolf-add-ons/springwolf-json-schema) adds the [json-schema](https://json-schema.org) schema to the AsyncApi document.
120
+
87
121
## Custom ModelConverters
88
122
89
123
Additionally, custom `ModelConverters` are supported.
0 commit comments