Skip to content

Commit 9572619

Browse files
author
Carlos Tasada
committed
feat: Added @asyncmessage documentation
Solves #38
1 parent ab4ed46 commit 9572619

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

docs/configuration/documenting-schemas.md renamed to docs/configuration/documenting-messages.md

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,34 @@ import CodeBlock from '@theme/CodeBlock';
88
import CodeSchemaGroovy from '!!raw-loader!./snippets/_schema_groovy.md';
99
import CodeSchemaMaven from '!!raw-loader!./snippets/_schema_maven.md';
1010

11-
# Schemas
11+
# Messages
1212

13-
Under the hood springwolf relies on swagger-core `ModelConverters`.
13+
Springwolf provides different ways to document the messages. The `message` is part of the AsyncApi `operationObject`
14+
15+
> A definition of the message that will be published or received by this operation
16+
17+
A message can be defined as part of the `@AsyncOperation` annotation, using `message = @AsyncMessage()` field.
18+
19+
For example:
20+
```java
21+
@AsyncPublisher(operation = @AsyncOperation(
22+
channelName = "example-producer-topic",
23+
description = "Optional. Customer uploaded an example payload",
24+
message = @AsyncMessage(
25+
messageId = "my-unique-id",
26+
name = "ExamplePayloadDto",
27+
schemaFormat = "application/schema+json;version=draft-07",
28+
description = "Example payload model for sending messages"
29+
)
30+
))
31+
public void sendMessage(ExamplePayloadDto msg) {
32+
// send
33+
}
34+
```
35+
36+
## Schema
37+
38+
Under the hood springwolf relies on swagger-core `ModelConverters` to define the message schema.
1439

1540
By default, the type and example values for the properties are guessed.
1641
The default Jackson `ModelResolver` supports schema definitions via `@Schema` to overwrite the property definitions.
@@ -50,6 +75,10 @@ public class ExamplePayloadDto {
5075
}
5176
```
5277

78+
:::note
79+
The `@AsyncMessage.description` field will always override the `@Schema` description if provided
80+
:::
81+
5382
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)
5483

5584
## Custom ModelConverters

0 commit comments

Comments
 (0)