|
| 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:  |
| 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:  |
| 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:  |
| 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:  |
| 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) |
0 commit comments