Skip to content

Commit c257b36

Browse files
timonbacksam0r040
andauthored
Docs/customizer (#47)
* feat: Add section for customizer Resolves #39 * chore: Spelling of Springwolf/AsyncAPI/OpenAPI * feat: Add AsyncApiCustomizer example * Update customizing.md --------- Co-authored-by: sam0r040 <[email protected]>
1 parent 8724218 commit c257b36

File tree

7 files changed

+66
-25
lines changed

7 files changed

+66
-25
lines changed

docs/behind-the-scenes.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,39 @@ sidebar_position: 70
44

55
# Behind the scenes
66

7-
The following paragraphs describe how springwolf works internally.
7+
The following paragraphs describe how Springwolf works internally.
88

99
## Big Picture
10-
When the Spring Boot application is started, springwolf uses its scanners to find defined consumers and producers within the application.
10+
When the Spring Boot application is started, Springwolf uses its scanners to find defined consumers and producers within the application.
1111
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.
14-
When the springwolf ui is opened, the browser fetches the document and renders it (see demo).
13+
The AsyncAPI document is accessible an endpoint.
14+
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.
17-
From there, springwolf forwards the message to the protocol specific producer.
17+
From there, Springwolf forwards the message to the protocol specific producer.
1818

1919
## Plugins
20-
`springwolf-core` provides the base functionality to orchestrate the scanning and building of the AsyncApi document.
20+
`springwolf-core` provides the base functionality to orchestrate the scanning and building of the AsyncAPI document.
2121
The different protocol (AMQP, Kafka) are supported through plugins.
2222
These plugins are found through the Spring dependency injection functionality.
2323
When building own scanner plugins, your plugin will need to implement the `ChannelsScanner` interface.
2424

2525
## Scanners
26-
`springwolf-core` runs all scanners and merges the found results together into one AsyncApi document.
26+
`springwolf-core` runs all scanners and merges the found results together into one AsyncAPI document.
2727
When the same channel/topic is found multiple times, it is merged as well.
2828

2929
The result is a [`ChannelItem`](https://www.asyncapi.com/docs/reference/specification/v2.6.0#channelItemObject).
3030
The `ChannelItem` contains the `Message` for the subscribe and/or publish 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 `SchemasService`, which allows to split the `Message` from the schema definition - within the AsyncAPI doc a `$ref` references is used.
3535

36-
Using `swagger-inflector` any class can be converted into a OpenApi schema.
37-
This is used to instantiate an Example object with default values and serialized into an example json for the AsyncApi document.
36+
Using `swagger-parser` any class can be converted into a OpenAPI schema.
37+
The schema is then used to serialized it into an example json for the AsyncAPI document.
3838

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

4141
### ModelConverters
4242
ModelConverters provide a way to improve documentation for classes, which cannot be modified, for example because they are part of an external library.

docs/configuration/configuration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import CodeConfigurationAsyncApiDocket from '!!raw-loader!./snippets/_configurat
99

1010
# Configuration
1111

12-
There are 2 ways to configure springwolf which cannot be combined:
12+
There are 2 ways to configure Springwolf which cannot be combined:
1313

1414
1. `application.properties`, which is simple and moves all configuration to this file and annotations
1515
2. (deprecated) `AsyncApiDocket`, which allows adding producers and consumers via code (instead of annotations)
@@ -61,7 +61,7 @@ The following table contains additional properties that can be specified in the
6161

6262
| Property Name | Default Value | Description |
6363
|----------------------------------------------------------|--------------------|---------------------------------------------------------------------------------------------------------------------------|
64-
| `springwolf.enabled` | `true` | Allows to enable/disable springwolf at one central place. |
64+
| `springwolf.enabled` | `true` | Allows to enable/disable Springwolf at one central place. |
6565
| `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.* |
6666
| `springwolf.scanner.consumer-data.enabled` | `true` | Enable scanner to find consumers defined in `AsyncApiDocket`. |
6767
| `springwolf.scanner.producer-data.enabled` | `true` | Enable scanner to find producers defined in `AsyncApiDocket`. |

docs/configuration/customizing.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
sidebar_position: 80
3+
---
4+
5+
# Customizing
6+
Adding and changing functionality of Springwolf is easy.
7+
The [configuration](../configuration/configuration.md) page mentions the existing ones.
8+
9+
When you feel that Springwolf is missing a feature, you are able to add it yourself.
10+
To learn more about how Springwolf works, look [behind the scenes](../behind-the-scenes.md).
11+
12+
:::note
13+
Please let us know on GitHub or Discord, so that other people can benefit from it as well.
14+
[Contributions are welcome, here are some basic tips](https://github.com/springwolf/springwolf-core/blob/master/CONTRIBUTING.md).
15+
:::
16+
17+
Springwolf uses interfaces to allow to inject functionality at integration points.
18+
Springwolf provides default implementation, but those can be replaced.
19+
All default implementations are Spring managed beans, which can be overridden.
20+
21+
## `AsyncApiCustomizer` - Full AsyncAPI document
22+
23+
By implementing the `AsyncApiCustomizer`, the AsyncAPI document can be modified after Springwolf has done all the scanning and has built the document.
24+
It is the final interception point before the document is available to the user.
25+
26+
For example, the title can be adjusted - although this should be done through the configuration:
27+
```java
28+
@Component
29+
public class AsyncApiTitleCustomizer implements AsyncApiCustomizer {
30+
@Override
31+
public void customize(AsyncAPI asyncAPI) {
32+
asyncAPI.getInfo().setTitle("Title set through customizer");
33+
}
34+
}
35+
```
36+
37+
## `ChannelScanners` - Channel detection
38+
39+
All `ChannelScanner` beans are called to scan for channels.
40+
This interface is helpful when a protocol currently unsupported by Springwolf is used.
41+
Remember to register all payloads in the `SchemasService`.

docs/configuration/documenting-messages.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public void sendMessage(ExamplePayloadDto msg) {
3535

3636
## Schema
3737

38-
Under the hood springwolf relies on swagger-core `ModelConverters` to define the message schema.
38+
Under the hood Springwolf relies on swagger-core `ModelConverters` to define the message schema.
3939

4040
By default, the type and example values for the properties are guessed.
4141
The default Jackson `ModelResolver` supports schema definitions via `@Schema` to overwrite the property definitions.
@@ -44,7 +44,7 @@ The default Jackson `ModelResolver` supports schema definitions via `@Schema` to
4444

4545
The `@Schema` annotation allows to set many properties like `description`, `example`, `requiredMode` to document payloads.
4646

47-
All properties are part of the produced AsyncApi file. However, not all of them are displayed in springwolf-ui. The ones listed above are included.
47+
All properties are part of the produced AsyncApi file. However, not all of them are displayed in Springwolf-ui. The ones listed above are included.
4848

4949
### Usage
5050

docs/faq.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ sidebar_position: 80
66

77
## General
88

9-
### Is springwolf free? What is the license?
9+
### Is Springwolf free? What is the license?
1010

11-
Yes, you can use springwolf for private and commercial purposes as long as you comply to the [Apache License 2.0](https://github.com/springwolf/springwolf-core/blob/master/LICENSE).
11+
Yes, you can use Springwolf for private and commercial purposes as long as you comply to the [Apache License 2.0](https://github.com/springwolf/springwolf-core/blob/master/LICENSE).
1212

1313
## Troubleshooting
1414

15-
### The springwolf UI is not showing
15+
### The Springwolf UI is not showing
1616

1717
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).
1818

@@ -45,7 +45,7 @@ Spring Security allows to limit access to authorized users.
4545

4646
### Is Spring Boot 2.X supported?
4747

48-
You can use an older version of springwolf, which is build to support Spring Boot 2.X.
48+
You can use an older version of Springwolf, which is build to support Spring Boot 2.X.
4949
However, these versions do not get any updates.
5050

5151
Last versions to support Spring Boot 2.X:
@@ -66,7 +66,7 @@ Use the `AsyncApiService` to access the generated documentation.
6666
#### With Gradle
6767

6868
You can use the [springdoc-openapi-gradle-plugin](https://github.com/springdoc/springdoc-openapi-gradle-plugin) and configure the plugin
69-
for springwolf by pointing it to the springwolf docs endpoint:
69+
for Springwolf by pointing it to the Springwolf docs endpoint:
7070

7171
```groovy
7272
openApi {
@@ -87,7 +87,7 @@ properties can help you.
8787

8888
### My consumers are detected multiple times (with different payloads)
8989

90-
When springwolf finds multiple consumers/producers for the same channel/topic, these are merged together.
90+
When Springwolf finds multiple consumers/producers for the same channel/topic, these are merged together.
9191
This is expected, as there are use-cases where different payloads are sent via the same channel/topic.
9292

9393
Springwolf uses on scanners to find all consumer and producers in your application.

docs/introduction/introduction.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ sidebar_position: 10
44

55
# Introduction
66

7-
## What is springwolf
7+
## What is Springwolf
88
API Documentation is an important part of every project and product, but can be painful to maintain manually.
99
Spring Boot projects have great solutions for auto-generated documentation for REST APIs to overcome this pain (such as springfox, or springdoc-openapi).
1010

@@ -14,7 +14,7 @@ Springwolf is compliant to [AsyncAPI](https://www.asyncapi.com), which brings th
1414

1515
### Demo
1616

17-
View the [live demo](https://demo.springwolf.dev) of springwolf in action.
17+
View the [live demo](https://demo.springwolf.dev) of Springwolf in action.
1818

1919
Also, the demos of the
2020
[amqp](https://amqp.demo.springwolf.dev),

docs/quickstart.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ springwolf.docket.servers.kafka.protocol=kafka
4444
springwolf.docket.servers.kafka.url=${kafka.bootstrap.servers:localhost:29092}
4545
```
4646

47-
*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.*
47+
*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.*
4848

4949
## 3. View the docs
5050
Start the application and open the urls in your browser:
5151
- Json: [`<host>:<port>/springwolf/docs`](http://localhost:8080/springwolf/docs)
5252
- Yaml: [`<host>:<port>/springwolf/docs.yaml`](http://localhost:8080/springwolf/docs.yaml)
5353
- UI: [`<host>:<port>/springwolf/asyncapi-ui.html`](http://localhost:8080/springwolf/asyncapi-ui.html)
5454

55-
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`
55+
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`
5656

5757
## 4. Next steps
5858

0 commit comments

Comments
 (0)