Skip to content

Commit

Permalink
chore: Fixed MarkDown Linting
Browse files Browse the repository at this point in the history
Added support for MarkDown Linting and fixed all the reported issues.
  • Loading branch information
carlos.tasada committed Apr 17, 2024
1 parent e3da4d9 commit e34647d
Show file tree
Hide file tree
Showing 12 changed files with 708 additions and 26 deletions.
4 changes: 4 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"default": true,
"MD013": false
}
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,10 @@ vale docs/
```

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

## Run Markdown Linter

To validate that the created Markdown follows the rules:
```bash
npm run lint:md
```
6 changes: 6 additions & 0 deletions docs/behind-the-scenes.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ sidebar_position: 70
The following paragraphs describe how Springwolf works internally.

## Big Picture

When the Spring Boot application is started, Springwolf uses its scanners to find defined consumers and producers within the application.
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/v3.0.0).

Expand All @@ -17,19 +18,22 @@ When publishing is enabled, the user can publish a message through the UI to ano
From there, Springwolf forwards the message to the protocol specific producer.

## Plugins

`springwolf-core` provides the base functionality to orchestrate the scanning and building of the AsyncAPI document.
The different protocol (AMQP, Cloud-Stream, JMS, Kafka, SNS, SQS) are supported through plugins.
These plugins are found through the Spring dependency injection functionality.
When building own scanner plugins, your plugin will need to implement the `ChannelsScanner` interface.

## Scanners

`springwolf-core` runs all scanners and merges the found results together into one AsyncAPI document.
When the same channel/topic is found multiple times, it's merged as well.

The result is a [`ChannelItem`](https://www.asyncapi.com/docs/reference/specification/v3.0.0#channelObject).
The `ChannelObject` contains the `Message` for the receive and/or send operation.

## Building an example payload

When the scanners scan and build the result, they also extract the payload type.
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.

Expand All @@ -40,9 +44,11 @@ Additionally, Springwolf generates an example based on the provided schema.
By using `swagger-parser`, all the `@Schema` and other swagger annotations are supported as well as `@JsonProperty` through the use of the ObjectMapper.

### ModelConverters

ModelConverters provide a way to improve documentation for classes, which can't be modified, for example because they're part of an external library.
They follow the same plugin model.

## Putting it all together

The `AsyncApiService` collects all the channels, schemas and general info and builds the AsyncApi document.
The controller access this services to serve the document to the UI.
2 changes: 2 additions & 0 deletions docs/configuration/customizing.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ sidebar_position: 80
---

# Customizing

Adding and changing functionality of Springwolf is easy.
The [configuration](../configuration/configuration.mdx) page mentions the existing ones.

Expand All @@ -26,6 +27,7 @@ By implementing the `AsyncApiCustomizer`, the AsyncAPI document can be modified
It's the final interception point before the document is available to the user.

For example, the title can be adjusted - although this should be done through the configuration:

```java
@Component
public class AsyncApiTitleCustomizer implements AsyncApiCustomizer {
Expand Down
24 changes: 19 additions & 5 deletions docs/configuration/documenting-bindings.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Associate this operation with JMS, see [operation-binding] for details.
### `@SnsAsyncOperationBinding`

Associate this operation with SNS, see [operation-binding] for details.

```java
@SnsAsyncOperationBinding
```
Expand Down Expand Up @@ -71,9 +72,11 @@ You can define anything and there is no validation.
```

## Binding properties

Explanation of the different binding properties.

### General

The following properties are the same for all bindings.

#### Queue Name (Channel Name)
Expand All @@ -94,7 +97,7 @@ The Kafka headers describing the metadata of the payload, more details in the ge

The Springwolf comes with a special `AsyncHeadersCloudEventConstants` to document CloudEvents.

The `kafka` header `__TypeId__` (constant from ` AbstractJavaTypeMapper.DEFAULT_CLASSID_FIELD_NAME`) can be documented as well.
The `kafka` header `__TypeId__` (constant from `AbstractJavaTypeMapper.DEFAULT_CLASSID_FIELD_NAME`) can be documented as well.

### AMQP

Expand All @@ -106,18 +109,22 @@ The exchange name that will be used to bind queues to.

The routing key used when publishing a message.


### Kafka

#### Group Id

The group id that will be used during message consumption

#### Client Id

The client id to identify the consumer

### Google PubSub binding annotations

#### Channel Binding Object

The Channel Bindings Object is used to describe the Google Cloud Pub/Sub Topic details.

```java
@GooglePubSubAsyncChannelBinding(
messageRetentionDuration = "messageRetentionDuration",
Expand All @@ -130,27 +137,34 @@ The Channel Bindings Object is used to describe the Google Cloud Pub/Sub Topic d
lastRevisionId = "lastRevisionId",
name = "projects/{project}/schemas/{schema}"))
```
`MessageRetentionDuration`: Indicates the minimum duration to retain a message after it's published to the topic

`MessageRetentionDuration`: Indicates the minimum duration to retain a message after it's published to the topic

`Message Storage Policy`: The Message Storage Policy Object is used to describe the Google Cloud Pub/Sub MessageStoragePolicy.
- A list of IDs of GCP regions where messages that are published to the topic may be persisted in storage

- A list of IDs of GCP regions where messages that are published to the topic may be persisted in storage

`Schema Settings`:The Schema Settings Object is used to describe the Google Cloud Pub/Sub SchemaSettings.

- encoding: The encoding of the message
- firstRevisionId: The minimum (inclusive) revision allowed for validating messages
- lastRevisionId: The maximum (inclusive) revision allowed for validating messages
- name: The name of the schema that messages published should be validated against (The format is `projects/{project}/schemas/{schema}`.)

#### Message Binding Object

The Message Binding Object is used to describe the Google Cloud Pub/Sub PubsubMessage details, alongside with pertinent parts of the Google Cloud Pub/Sub Schema Object.

```java
@GooglePubSubAsyncMessageBinding(
orderingKey = "key",
schema = @GooglePubSubAsyncMessageSchema(name = "projects/{project}/schemas/{schema}"))
```

`OrderingKey`: If non-empty, identifies related messages for which publish order should be respected

`Schema Definition`: The Schema Definition Object is used to describe the Google Cloud Pub/Sub Schema Object with AsyncAPI. While some of this information could be, or is, described using native AsyncAPI, for consistency it makes sense to provide this information here at all times, especially for cases where AsyncAPI doesn't natively support describing payloads using a supported Google Cloud Pub/Sub schema format like Protobuf
- name: The name of the schema

- name: The name of the schema

[operation-binding]: https://www.asyncapi.com/docs/reference/specification/v3.0.0#operationBindingsObject
3 changes: 3 additions & 0 deletions docs/configuration/documenting-consumers.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Sometimes projects are configured in a way that makes Springwolf unable to autom
For these use-cases, Springwolf provides additional ways to explicitly add them to the generated document.

To document consumers, either:

- add the `@AsyncListener` annotation or
- rely on the auto-detection of `@JmsListener`, `@KafkaListener`, `@RabbitListener`, `@SqsListener`

Expand All @@ -23,6 +24,7 @@ Additional fields can be documented.
On the same method, the protocol binding is defined. More details can be found in the [bindings](documenting-bindings.md) section.

Below is an example to demonstrate the annotation:

```java
@KafkaListener
@AsyncListener(operation = @AsyncOperation(
Expand Down Expand Up @@ -74,6 +76,7 @@ Optional. Useful when an application is connect to multiple brokers and wants to
The server needs to exist in [configuration > Servers](configuration.mdx) as well.

## `@JmsListener`, `@KafkaListener`, `@RabbitListener`, `@SqsListener`

The `@JmsListener`, `@KafkaListener`, `@RabbitListener`, `@SqsListener` annotations are detected automatically.
There is nothing more to do.
Use the other option if the provided documentation is insufficient.
5 changes: 3 additions & 2 deletions docs/configuration/documenting-producers.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ sidebar_position: 64

# Producers

Unlike consumers which are defined declaratively with an annotation,
producers are defined imperatively (that's `KafkaTemplate`),
Unlike consumers which are defined declaratively with an annotation,
producers are defined imperatively (that's `KafkaTemplate`),
and there is no implementation uniform enough so that metadata can be picked up automatically.

Because producers are also an important part of AsyncAPI,
Expand All @@ -19,6 +19,7 @@ Additional fields can be documented.
On the same method, the protocol binding is defined. More details can be found in the [bindings](documenting-bindings.md) section.

Below is an example to demonstrate the annotation:

```java
@AsyncPublisher(operation = @AsyncOperation(
channelName = "example-producer-topic",
Expand Down
16 changes: 11 additions & 5 deletions docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ logging.level.io.github.springwolf=DEBUG
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).

If not, whether
1. you customized the spring `context-path` setting

1. you customized the spring `context-path` setting
2. static assets are being served at all. See the code below:
```java

```java
@Configuration
public class WebConfig implements WebMvcConfigurer {
@Override
Expand Down Expand Up @@ -83,10 +85,13 @@ Due to java type erasure some generic type information is lost during runtime.
Defining your own type can resolve this.

Change

```java
public void sendMessage(List<String> msg) {}
```

to

```java
class ListWrapper extends ArrayList<String> {}

Expand All @@ -95,18 +100,19 @@ public void sendMessage(ListWrapper<String> msg) {}

### How to migrate from Springwolf 0.18.0 to 1.0.0

See https://github.com/springwolf/springwolf-core/releases/tag/v1.0.0.
See <https://github.com/springwolf/springwolf-core/releases/tag/v1.0.0>.

### How to migrate from the deprecated `AsyncApiDocket` bean to Spring properties

See https://github.com/springwolf/springwolf-core/issues/445.
See <https://github.com/springwolf/springwolf-core/issues/445>.

### Is Spring Boot 2.X supported

You can use an older version of Springwolf, which is build to support Spring Boot 2.X.
However, these versions don't get any updates.
Last versions to support Spring Boot 2.X:
- `springwolf-amqp:0.6.0`
- `springwolf-cloud-stream:0.1.0`
- `springwolf-core:0.6.0`
Expand All @@ -124,7 +130,7 @@ Use the `AsyncApiService` to access the generated documentation.
#### With Gradle
You can use the [`springdoc-openapi-gradle-plugin`](https://github.com/springdoc/springdoc-openapi-gradle-plugin) and configure the plugin
for Springwolf by pointing it to the Springwolf docs endpoint:
for Springwolf by pointing it to the Springwolf docs endpoint:
```groovy
openApi {
Expand Down
6 changes: 4 additions & 2 deletions docs/introduction/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Integrate Springwolf in minutes using the [Quickstart](../quickstart.mdx).
:::

## What's Springwolf

API Documentation is an important part of every project and product, but can be painful to maintain manually.
Spring Boot projects have great solutions for auto-generated documentation for REST APIs to overcome this pain (such as Springfox, or springdoc-openapi).

Expand All @@ -20,8 +21,8 @@ Springwolf is compliant to [AsyncAPI](https://www.asyncapi.com), which brings th

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

Also, the demos of the
[AMQP](https://amqp.demo.springwolf.dev),
Also, the demos of the
[AMQP](https://amqp.demo.springwolf.dev),
[Spring Cloud Stream](https://cloud-stream.demo.springwolf.dev),
[JMS](https://jms.demo.springwolf.dev),
[Kafka](https://kafka.demo.springwolf.dev),
Expand All @@ -48,6 +49,7 @@ public class ExampleConsumer {
```

By simply adding Springwolf dependency to your project you will automatically get:

- An endpoint returning an AsyncAPI document describing your asynchronous API.
- A web UI for convenient use by your developers, QA or clients of your asynchronous API.
- An easy way to publish messages to your asynchronous API with a click of a button
1 change: 1 addition & 0 deletions docs/introduction/supported-protocols.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Using [`@AsyncListener`](../configuration/documenting-consumers.md) and [`@Async
The protocols with native support come along with a `@_ProtocolName_Binding` annotation to define protocol specific properties.

### `springwolf-generic-binding` add-on

The `springwolf-generic-binding` add-on allows to document any binding.
This includes bindings not supported by Springwolf, but also any custom fields not part of the AsyncAPI specification.

Expand Down
Loading

0 comments on commit e34647d

Please sign in to comment.