Skip to content

Commit 2dcbeea

Browse files
committed
docs: Springwolf 1.0.0 release
1 parent f8845cc commit 2dcbeea

18 files changed

+103
-366
lines changed

.github/styles/Vocab/Springwolf/accept.txt

Lines changed: 0 additions & 18 deletions
This file was deleted.

.vale.ini

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ Vocab = Springwolf
44
MinAlertLevel = warning
55
Packages = Microsoft
66

7+
[formats]
8+
mdx = md
79

810
[*.md]
911
BasedOnStyles = Vale, Microsoft
1012

1113
BlockIgnores = (import .*;)
1214

13-
Microsoft.Headings = NO
15+
Microsoft.Headings = NO

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ vale sync
3636
vale docs/
3737
```
3838

39-
Words not part of the dictionary yet are added in [accept.txt](.github/styles/Vocab/Springwolf/accept.txt).
39+
Words not part of the dictionary yet are added in [accept.txt](.github/styles/config/vocabularies/Springwolf/accept.txt).

docs/behind-the-scenes.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ The following paragraphs describe how Springwolf works internally.
88

99
## Big Picture
1010
When the Spring Boot application is started, Springwolf uses its scanners to find defined consumers and producers within the application.
11-
Based on the results, the channels/topics are extracted including payload type and merged together into an [AsyncApi conform document](https://www.asyncapi.com/docs/reference/specification/v2.6.0).
11+
Based on the results, the channels/topics are extracted including payload type and merged together into an [AsyncAPI conform document](https://www.asyncapi.com/docs/reference/specification/v2.6.0).
1212

13-
The AsyncApi document is accessible an endpoint.
13+
The AsyncAPI document is accessible an endpoint.
1414
When the Springwolf UI is opened, the browser fetches the document and renders it (see demo).
1515

1616
When publishing is enabled, the user can publish a message through the UI to another endpoint.
@@ -27,15 +27,15 @@ When building own scanner plugins, your plugin will need to implement the `Chann
2727
When the same channel/topic is found multiple times, it's merged as well.
2828

2929
The result is a [`ChannelItem`](https://www.asyncapi.com/docs/reference/specification/v2.6.0#channelItemObject).
30-
The `ChannelItem` contains the `Message` for the subscribe and/or publish operation.
30+
The `ChannelObject` contains the `Message` for the receive and/or send operation.
3131

3232
## Building an example payload
3333
When the scanners scan and build the result, they also extract the payload type.
34-
The payload is registered in the `SchemasService`, which allows to split the `Message` from the schema definition - within the AsyncAPI doc a `$ref` references is used.
34+
The payload is registered in the `ComponentsService`, which allows to split the `Message` from the schema definition - within the AsyncAPI doc a `$ref` references is used.
3535

36-
Using `swagger-core` any class can be converted into a OpenApi schema.
37-
The schema is used in the AsyncApi document.
38-
Additionally, Springwolf generates an example JSON based on the provided schema.
36+
Using `swagger-core` any class can be converted into an OpenApi schema.
37+
The schema is [mapped into an AsyncAPI schema](https://www.asyncapi.com/docs/tutorials/getting-started/coming-from-openapi) and included in the AsyncAPI document.
38+
Additionally, Springwolf generates an example based on the provided schema.
3939

4040
By using `swagger-parser`, all the `@Schema` and other swagger annotations are supported as well as `@JsonProperty` through the use of the objectmapper.
4141

docs/configuration/configuration.mdx

Lines changed: 24 additions & 48 deletions
Large diffs are not rendered by default.

docs/configuration/customizing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ public class AsyncApiTitleCustomizer implements AsyncApiCustomizer {
4040

4141
All `ChannelScanner` beans are called to scan for channels.
4242
This interface is helpful when a protocol currently unsupported by Springwolf is used.
43-
Remember to register all payloads in the `SchemasService`.
43+
Remember to register all payloads in the `ComponentsService`.

docs/configuration/documenting-bindings.md

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Add at least one binding so that readers know the protocol in use and functional
99

1010
To use the protocol specific bindings, ensure that you have added the corresponding [plugin](../introduction/supported-protocols.md).
1111

12-
## Option 1: Annotations
12+
## Protocol specific annotations
1313

1414
### `@AmqpAsyncOperationBinding`
1515

@@ -52,9 +52,12 @@ Associate this operation with SQS, see [operation-binding] for details.
5252
@SqsAsyncOperationBinding
5353
```
5454

55-
### `@AsyncGenericOperationBinding`
55+
## Generic annotation
5656

5757
This binding is generic, so that any properties can be specified.
58+
59+
### `@AsyncGenericOperationBinding`
60+
5861
You can define anything and there is no validation.
5962

6063
```java
@@ -67,31 +70,6 @@ You can define anything and there is no validation.
6770
)
6871
```
6972

70-
## Option 2: AsyncApiDocket (deprecated)
71-
72-
### `AmqpProducerData` / `AmqpConsumerData`
73-
74-
```java
75-
AmqpProducerData exampleProducer = AmqpProducerData.amqpProducerDataBuilder()
76-
.queueName("example-producer-channel")
77-
.description("example-producer-channel-description")
78-
.exchangeName("example-topic-exchange")
79-
.routingKey("example-topic-routing-key")
80-
.payloadType(AnotherPayloadDto.class)
81-
.build();
82-
```
83-
84-
### `KafkaProducerData` / `KafkaConsumeData`
85-
86-
```java
87-
KafkaProducerData exampleProducerData = KafkaProducerData.kafkaProducerDataBuilder()
88-
.topicName("example-producer-topic")
89-
.description("Optional. Customer uploaded an example payload")
90-
.payloadType(ExamplePayloadDto.class)
91-
.headers(AsyncHeaders.NOT_USED)
92-
.build();
93-
```
94-
9573
## Binding properties
9674
Explanation of the different binding properties.
9775

docs/configuration/documenting-consumers.md

Lines changed: 9 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,31 @@ For these use-cases, Springwolf provides additional ways to explicitly add them
1111

1212
To document consumers, either:
1313
- add the `@AsyncListener` annotation or
14-
- (deprecated) declare the `ConsumerData` object as part of the `AsyncApiDocket` or
1514
- rely on the auto-detection of `@JmsListener`, `@KafkaListener`, `@RabbitListener`, `@SqsListener`
1615

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.
16+
You are free to use both options together. Channel and operation, documented via `@AsyncListener` have a higher precedence than auto-detected annotations.
1817

19-
## Option 1: `@AsyncListener`
18+
## `@AsyncListener`
2019

2120
The `@AsyncListener` annotation is added to the method of the listeners and extracts the payload from its arguments.
2221
Additional fields can be documented.
2322

24-
The protocol operation binding is configured via `@AmqpAsyncOperationBinding`, `@KafkaAsyncOperationBinding` or `@AsyncGenericOperationBinding`, which has to be on the same method.
23+
On the same method, the protocol binding is defined. More details can be found in the [bindings](documenting-bindings.md) section.
2524

2625
Below is an example to demonstrate the annotation:
2726
```java
2827
@KafkaListener
2928
@AsyncListener(operation = @AsyncOperation(
3029
channelName = "example-consumer-topic",
31-
description = "Optional. Customer uploaded an example payload",
32-
servers = {"kafka"},
33-
headers = @AsyncOperation.Headers(
30+
description = "Customer uploaded an example payload", // Optional
31+
servers = {"kafka"}, // Optional
32+
headers = @AsyncOperation.Headers( // Optional
3433
schemaName = "SpringKafkaDefaultHeaders",
3534
values = {
3635
@AsyncOperation.Headers.Header(
3736
name = DEFAULT_CLASSID_FIELD_NAME,
3837
description = "Spring Type Id Header",
39-
value = "io.github.stavshamir.springwolf.example.dtos.ExamplePayloadDto"
38+
value = "io.github.springwolf.example.dtos.ExamplePayloadDto"
4039
),
4140
// (demonstrating https://cloudevents.io)
4241
@AsyncOperation.Headers.Header(
@@ -74,92 +73,7 @@ Optional. The headers describing the metadata of the payload.
7473
Optional. Useful when an application is connect to multiple brokers and wants to indicate to which broker the channel belongs to.
7574
The server needs to exist in [configuration > Servers](configuration.mdx) as well.
7675

77-
78-
## Option 2: `ConsumerData` (deprecated)
79-
80-
:::note
81-
Must use configuration via `AsyncApiDocket` and can't use `application.properties`.
82-
:::
83-
84-
Below is an example of describing a Kafka consumer:
85-
86-
```java
87-
@Bean
88-
public AsyncApiDocket asyncApiDocket() {
89-
90-
ConsumerData exampleConsumerData = ConsumerData.builder()
91-
.channelName("example-consumer-topic")
92-
.description("Optional. Customer uploaded an example payload")
93-
.operationBinding(ImmutableMap.of("kafka", new KafkaOperationBinding()))
94-
.payloadType(ExamplePayloadDto.class)
95-
.headers(AsyncHeaders.NOT_USED)
96-
.build();
97-
98-
return AsyncApiDocket.builder()
99-
.basePackage(...)
100-
.info(...)
101-
.server(...)
102-
.consumer(exampleConsumerData)
103-
.build();
104-
}
105-
```
106-
107-
Multiple consumers can be configured by calling the `consumer()` method multiple times.
108-
109-
:::tip
110-
Use specific ConsumerData types `AmqpConsumerData` & `KafkaConsumerData` for protocol specific attributes
111-
:::
112-
113-
### Channel Name
114-
115-
The channel name (or topic name in case of Kafka) - this is the name that will be used to subscribe to messages to by the UI.
116-
117-
### Description
118-
119-
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.
120-
121-
### Binding
122-
123-
This property is used to discriminate the producer's protocol and provide protocol-specific properties (see [documenting bindings](documenting-bindings.md)).
124-
125-
### Payload Type
126-
127-
The class object of the payload that will be consumed from this channel.
128-
129-
### Header
130-
131-
Optional. The headers describing the metadata of the payload.
132-
By default, `AsyncHeaders.NOT_DOCUMENTED` is used to indicate that no explicit header documentation exists.
133-
Use `AsyncHeaders` to add your custom headers, use `AsyncHeaders.NOT_USED` if you don't use headers and `AsyncHeadersForCloudEventsBuilder` if your events follow the CloudEvent specification.
134-
135-
136-
### `AmqpConsumerData`
137-
138-
The above Kafka `ConsumerData` equivalent in `AmqpConsumerData`:
139-
```java
140-
AmqpConsumerData exampleConsumer = AmqpConsumerData.amqpConsumerDataBuilder()
141-
.queueName("example-consumer-channel")
142-
.description("example-consumer-channel-description")
143-
.exchangeName("example-topic-exchange")
144-
.routingKey("example-topic-routing-key")
145-
.payloadType(AnotherPayloadDto.class)
146-
.build();
147-
```
148-
149-
### `KafkaConsumerData`
150-
151-
The above Kafka `ConsumerData` simplifies to the following `KafkaConsumerData`:
152-
```java
153-
KafkaConsumerData exampleConsumerData = KafkaConsumerData.kafkaConsumerDataBuilder()
154-
.topicName("example-consumer-topic")
155-
.description("Optional. Customer uploaded an example payload")
156-
.payloadType(ExamplePayloadDto.class)
157-
.headers(AsyncHeaders.NOT_USED)
158-
.build();
159-
```
160-
161-
162-
## Option 3: `@JmsListener`, `@KafkaListener`, `@RabbitListener`, `@SqsListener`
76+
## `@JmsListener`, `@KafkaListener`, `@RabbitListener`, `@SqsListener`
16377
The `@JmsListener`, `@KafkaListener`, `@RabbitListener`, `@SqsListener` annotations are detected automatically.
16478
There is nothing more to do.
165-
Use the other options if the provided documentation is insufficient.
79+
Use the other option if the provided documentation is insufficient.

docs/configuration/documenting-messages.mdx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import CodeSchemaMaven from '!!raw-loader!./snippets/_schema_maven.xml';
1010

1111
# Messages
1212

13-
Springwolf provides different ways to document the messages. The `message` is part of the AsyncApi `operationObject`
13+
Springwolf provides different ways to document the messages. The `message` is part of the AsyncAPI `operationObject`
1414

1515
> A definition of the message that will be published or received by this operation
1616
@@ -20,25 +20,25 @@ For example:
2020
```java
2121
@AsyncPublisher(operation = @AsyncOperation(
2222
channelName = "example-producer-topic",
23-
description = "Optional. Customer uploaded an example payload",
24-
payloadType = ExamplePayloadDto.class, // optional
25-
message = @AsyncMessage(
23+
description = "Customer uploaded an example payload", // Optional
24+
payloadType = ExamplePayloadDto.class, // Optional
25+
message = @AsyncMessage( // Optional
2626
messageId = "my-unique-id",
2727
name = "ExamplePayloadDto",
28-
schemaFormat = "application/schema+json;version=draft-07",
28+
schemaFormat = "application/vnd.aai.asyncapi+json;version=3.0.0",
2929
description = "Example payload model for sending messages"
3030
)
3131
))
3232
public void sendMessage(ExamplePayloadDto msg) {
33-
// send
33+
// process
3434
}
3535
```
3636

3737
## Payload Type
3838

3939
Springwolf tries to auto-detect the payload type based on the method signature.
4040

41-
When the method has multiple arguments, the payload can be indicated via `@Payload`, i.e.
41+
When the method has multiple arguments, the payload can be indicated via `@Payload`, that's
4242
```java
4343
public void sendMessage(@Payload ExamplePayloadDto msg, String traceId, Object loggingContext) {}
4444
```
@@ -74,7 +74,7 @@ The default Jackson `ModelResolver` supports schema definitions via `@Schema` to
7474

7575
The `@Schema` annotation allows to set many properties like `description`, `example`, `requiredMode`, `minimum` to document payloads.
7676

77-
All properties are part of the produced AsyncApi file. However, not all are displayed in `springwolf-ui` (see [#378](https://github.com/springwolf/springwolf-core/issues/378))
77+
All properties are part of the produced AsyncAPI file. However, not all are displayed in `springwolf-ui` (see [#378](https://github.com/springwolf/springwolf-core/issues/378))
7878

7979
#### Usage
8080

@@ -112,11 +112,11 @@ public class ExamplePayloadDto {
112112
The `@AsyncMessage.description` field will always override the `@Schema` description if provided
113113
:::
114114

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)
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/springwolf/examples/amqp/dtos/ExamplePayloadDto.java)
116116

117117
#### Primitive, final and external classes
118118

119-
When the `@Schema` annotation cannot be attached to the payload class (i.e. `java.lang.String`), the payload can be wrapped in an envelope class. The actual payload is a field within this class (`StringEnvelope`), marked using `@AsyncApiPayload` and documented using the `@Schema` annotation.
119+
When the `@Schema` annotation can't be attached to the payload class (that's `java.lang.String`), the payload can be wrapped in an envelope class. The actual payload is a field within this class (`StringEnvelope`), marked using `@AsyncApiPayload` and documented using the `@Schema` annotation.
120120

121121
```java
122122
@AsyncListener( operation = @AsyncOperation( channelName = TOPIC,
@@ -136,7 +136,7 @@ static class StringEnvelope {
136136

137137
### `json-schema`
138138

139-
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.
139+
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.
140140

141141
## Custom ModelConverters
142142

0 commit comments

Comments
 (0)