Skip to content

Commit 282a7c0

Browse files
author
Carlos Tasada
committed
(feat) Added add-ons documentation
Fixes #77. This MR adds documentation about the add-ons, including the new Kotlinx add-on.
1 parent ae70943 commit 282a7c0

13 files changed

+171
-11
lines changed

.github/styles/config/vocabularies/Springwolf/accept.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ APIs
88
Baeldung
99
declaratively
1010
Gradle
11+
Kotlinx
1112
Protobuf
1213
Springfox
1314
Springwolf

.vale.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@ mdx = md
1111
BasedOnStyles = Vale, Microsoft
1212

1313
BlockIgnores = (import .*;)
14+
; Lets ignore Markdown links
15+
BlockIgnores = (?:\[(?P<text>.*?)\])\((?P<link>.*?)\)
1416

1517
Microsoft.Headings = NO

docs/add-ons.mdx

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
---
2+
sidebar_position: 50
3+
---
4+
import Tabs from '@theme/Tabs';
5+
import TabItem from '@theme/TabItem';
6+
import CodeBlock from '@theme/CodeBlock';
7+
import CodeCommonModelGroovy from '!!raw-loader!./snippets/_springwolf_common_model_converters_groovy.gradle';
8+
import CodeCommonModelMaven from '!!raw-loader!./snippets/_springwolf_common_model_converters_maven.xml';
9+
import CodeJsonSchemaGroovy from '!!raw-loader!./snippets/_springwolf_json_schema_groovy.gradle';
10+
import CodeJsonSchemaMaven from '!!raw-loader!./snippets/_springwolf_json_schema_maven.xml';
11+
import CodeGenericBindingGroovy from '!!raw-loader!./snippets/_springwolf_generic_binding_groovy.gradle';
12+
import CodeGenericBindingMaven from '!!raw-loader!./snippets/_springwolf_generic_binding_maven.xml';
13+
import CodeKotlinxGroovy from '!!raw-loader!./snippets/_springwolf_kotlinx_serialization_model_converter_groovy.gradle';
14+
import CodeKotlinxMaven from '!!raw-loader!./snippets/_springwolf_kotlinx_serialization_model_converter_maven.xml';
15+
16+
# Add-Ons
17+
18+
## Common Model Converters
19+
20+
The [`springwolf-add-ons/springwolf-common-model-converters`](https://github.com/springwolf/springwolf-core/tree/master/springwolf-add-ons/springwolf-common-model-converters) adds support for different Model Converters.
21+
22+
These are needed when swagger is unable to extract a schema from a class.
23+
24+
Add the following dependency:
25+
26+
<Tabs>
27+
<TabItem value="Groovy" label="Groovy" default>
28+
<CodeBlock language="groovy">{CodeCommonModelGroovy}</CodeBlock>
29+
</TabItem>
30+
<TabItem value="Maven" label="Maven">
31+
<CodeBlock language="xml">{CodeCommonModelMaven}</CodeBlock>
32+
</TabItem>
33+
</Tabs>
34+
Latest version: ![Maven Central](https://img.shields.io/maven-central/v/io.github.springwolf/springwolf-common-model-converters?color=green&label=springwolf&style=plastic)
35+
36+
### `javax.money.MonetaryAmount`
37+
38+
Adding a model converter is demoed in [`springwolf-add-ons/springwolf-common-model-converters`](https://github.com/springwolf/springwolf-core/tree/master/springwolf-add-ons/springwolf-common-model-converters)
39+
40+
## Generic Binding
41+
42+
<Tabs>
43+
<TabItem value="Groovy" label="Groovy" default>
44+
<CodeBlock language="groovy">{CodeGenericBindingGroovy}</CodeBlock>
45+
</TabItem>
46+
<TabItem value="Maven" label="Maven">
47+
<CodeBlock language="xml">{CodeGenericBindingMaven}</CodeBlock>
48+
</TabItem>
49+
</Tabs>
50+
Latest version: ![Maven Central](https://img.shields.io/maven-central/v/io.github.springwolf/springwolf-json-schema?color=green&label=springwolf&style=plastic)
51+
52+
Specific bindings are provided for the different [supported protocols](introduction/supported-protocols) but if you need
53+
to document a protocol that's not support yet, you can use this generic binding and specify any property you need.
54+
55+
### `@AsyncGenericOperationBinding`
56+
57+
The annotation parameter `type` is expected to contain the id of a valid [operation binding protocol](https://www.asyncapi.com/docs/reference/specification/v3.0.0#operationBindingsObject)
58+
but no validation is done.
59+
60+
The annotation parameter `fields` is intended to contain the fields that describe the protocol fields.
61+
62+
* **Key-Value**: A simple field can be described like `{"key-name=value"}`
63+
* **Array**: An array structure can be defined like `{"key=[valueA, valueB, valueC]"}`
64+
* **Map**: A map can be defined as `{"nested.keyA=value", "nested.keyB=value", "nested.keyC.subvalue=value"}`
65+
66+
You can define anything and there is **no validation**.
67+
68+
```java
69+
@AsyncGenericOperationBinding(
70+
type = "custom-binding",
71+
fields = {
72+
"internal-field=customValue",
73+
"nested.key=nestedValue",
74+
"listKey=[a,b,c,d,e]"
75+
}
76+
)
77+
```
78+
79+
## Json-Schema
80+
81+
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.
82+
83+
Add the following dependency:
84+
85+
<Tabs>
86+
<TabItem value="Groovy" label="Groovy" default>
87+
<CodeBlock language="groovy">{CodeJsonSchemaGroovy}</CodeBlock>
88+
</TabItem>
89+
<TabItem value="Maven" label="Maven">
90+
<CodeBlock language="xml">{CodeJsonSchemaMaven}</CodeBlock>
91+
</TabItem>
92+
</Tabs>
93+
Latest version: ![Maven Central](https://img.shields.io/maven-central/v/io.github.springwolf/springwolf-json-schema?color=green&label=springwolf&style=plastic)
94+
95+
## Kotlinx Serialization
96+
97+
:::caution
98+
This add-on is still **Beta** so some features may not be yet implemented or some issues may be
99+
expected. Please, fill a [SpringWold Issue](https://github.com/springwolf/springwolf.github.io/issues/new) if you find
100+
any bug or a missing feature.
101+
:::
102+
103+
To support [Kotlinx Serialization](https://github.com/Kotlin/kotlinx.serialization) classes, add the following dependency:
104+
105+
<Tabs>
106+
<TabItem value="Groovy" label="Groovy" default>
107+
<CodeBlock language="groovy">{CodeKotlinxGroovy}</CodeBlock>
108+
</TabItem>
109+
<TabItem value="Maven" label="Maven">
110+
<CodeBlock language="xml">{CodeKotlinxMaven}</CodeBlock>
111+
</TabItem>
112+
</Tabs>
113+
Latest version: ![Maven Central](https://img.shields.io/maven-central/v/io.github.springwolf/springwolf-kotlinx-serialization-model-converter?color=green&label=springwolf&style=plastic)
114+
115+
Using this add-on, any Kotlin class annotated with the `@Serializable` annotation is _properly_ converted to AsyncAPI specification.
116+
117+
The fields annotated with `@SerialName` are named as defined in the annotation.
118+
119+
**Known issues:**
120+
121+
* Polymorphism is still **not** supported. See [issue #707](https://github.com/springwolf/springwolf-core/issues/707)

docs/configuration/documenting-bindings.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ You can define anything and there is no validation.
7171
)
7272
```
7373

74+
:::info
75+
See [Add-Ons / Generic Annotation Binding](../add-ons#generic-binding) for more information
76+
:::
77+
7478
## Binding properties
7579

7680
Explanation of the different binding properties.

docs/configuration/documenting-messages.mdx

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,6 @@ static class StringEnvelope {
135135
}
136136
```
137137

138-
### `json-schema`
139-
140-
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.
141-
142-
## Custom ModelConverters
143-
144-
Additionally, custom `ModelConverters` are supported.
145-
These are needed when swagger is unable to extract a schema from a class.
146-
147-
One example is `javax.money.MonetaryAmount`.
148-
Adding a model converter is demoed in [`springwolf-add-ons/springwolf-common-model-converters`](https://github.com/springwolf/springwolf-core/tree/master/springwolf-add-ons/springwolf-common-model-converters)
138+
:::info
139+
See [Add-Ons](../add-ons.md) for more information on how to document other formats
140+
:::
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dependencies {
2+
implementation 'io.github.springwolf:springwolf-common-model-converters:1.1.0'
3+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<dependencies>
2+
<dependency>
3+
<groupId>io.github.springwolf</groupId>
4+
<artifactId>springwolf-common-model-converters</artifactId>
5+
<version>1.1.0</version>
6+
</dependency>
7+
</dependencies>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dependencies {
2+
implementation 'io.github.springwolf:springwolf-generic-binding:1.1.0'
3+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<dependencies>
2+
<dependency>
3+
<groupId>io.github.springwolf</groupId>
4+
<artifactId>springwolf-generic-binding</artifactId>
5+
<version>1.1.0</version>
6+
</dependency>
7+
</dependencies>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dependencies {
2+
implementation 'io.github.springwolf:springwolf-json-schema:1.1.0'
3+
}

0 commit comments

Comments
 (0)