Skip to content

Commit 4aab4af

Browse files
fix: generated code examples are now commented out. (#129)
Co-authored-by: Michael Davis <[email protected]>
1 parent 990246f commit 4aab4af

File tree

2 files changed

+29
-19
lines changed

2 files changed

+29
-19
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ There are two specification extentions you can use to shape how the bindings are
7575

7676
```x-scs-group``` : This will add the group value on a binding which configures your microservice to use [Consumer Groups](https://cloud.spring.io/spring-cloud-static/spring-cloud-stream/current/reference/html/spring-cloud-stream.html#consumer-groups)
7777

78+
### Limitations
79+
Currently any schemas that are used must be in the components/schemas part of the document. We do not support anonymous object-type schemas in the message/payload sections.
80+
7881
### Parameters
7982

8083
Parameters can be passed to the generator using command line arguments in the form ```-p param=value -p param2=value2```. Here is a list of the parameters that can be used with this template. In some cases these can be put into the AsyncAPI documents using the specification extensions feature. In those cases, the 'info' prefix means that it belongs in the info section of the document.

template/src/main/java/Application.java

+26-19
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,12 @@
44

55
import org.slf4j.Logger;
66
import org.slf4j.LoggerFactory;
7-
{% if extraIncludes.dynamicTopics %}
8-
import org.springframework.beans.factory.annotation.Autowired;
9-
{% endif %}
107
import org.springframework.boot.SpringApplication;
118
import org.springframework.boot.autoconfigure.SpringBootApplication;
12-
{% if extraIncludes.dynamicTopics %}
13-
import org.springframework.cloud.stream.binder.BinderHeaders;
14-
import org.springframework.cloud.stream.function.StreamBridge;
15-
{% endif %}
169
import org.springframework.context.annotation.Bean;
17-
{% if extraIncludes.dynamicTopics or extraIncludes.needMessageInclude %}
10+
{% if extraIncludes.needMessageInclude %}
1811
import org.springframework.messaging.Message;
1912
{% endif %}
20-
{% if extraIncludes.dynamicTopics %}
21-
import org.springframework.messaging.support.MessageBuilder;
22-
{% endif %}
2313
{%- if params.reactive === 'true' %}
2414
import reactor.core.publisher.Flux;
2515
{%- endif -%}
@@ -47,18 +37,32 @@
4737
{%- if hasSuppliers %}
4838
import java.util.function.Supplier;
4939
{%- endif %}
40+
{% if extraIncludes.dynamicTopics %}
41+
// Uncomment this if you want to use one of the sample functions commented out below.
42+
/*
43+
import org.springframework.beans.factory.annotation.Autowired;
44+
import org.springframework.cloud.stream.binder.BinderHeaders;
45+
import org.springframework.cloud.stream.function.StreamBridge;
46+
{%- if extraIncludes.dynamicTopics and not extraIncludes.needMessageInclude %}
47+
import org.springframework.messaging.Message;
48+
{%- endif %}
49+
import org.springframework.messaging.support.MessageBuilder;
50+
*/
51+
{% endif %}
5052

5153
{% set className = [asyncapi.info(), params] | mainClassName %}
5254
@SpringBootApplication
5355
public class {{ className }} {
54-
{%- if dynamicFuncs.size %}
55-
private static final String DYNAMIC_BINDING = "dynamic";
56+
57+
private static final Logger logger = LoggerFactory.getLogger({{ className }}.class);
58+
{%- if dynamicFuncs.size %}
59+
//Uncomment this if you want to use one of the sample functions commented out below.
60+
/*
61+
private static final String DYNAMIC_BINDING = "dynamic";
62+
@Autowired
63+
private StreamBridge streamBridge;
64+
*/
5665
{%- endif %}
57-
private static final Logger logger = LoggerFactory.getLogger({{ className }}.class);
58-
{%- if dynamicFuncs.size %}
59-
@Autowired
60-
private StreamBridge streamBridge;
61-
{%- endif %}
6266

6367
public static void main(String[] args) {
6468
SpringApplication.run({{ className }}.class);
@@ -71,6 +75,8 @@ public static void main(String[] args) {
7175
}
7276
{%- endfor %}
7377

78+
{% if dynamicFuncs.size %}
79+
/* Here is an example of how to send a message to a dynamic topic:
7480
{% for dynFuncName, dynFuncSpec in dynamicFuncs %}
7581
public void {{ dynFuncName }}(
7682
{{ dynFuncSpec.payloadClass }} payload, {{ dynFuncSpec.topicInfo.functionParamList }}
@@ -84,5 +90,6 @@ public static void main(String[] args) {
8490
streamBridge.send(DYNAMIC_BINDING, message);
8591
}
8692
{%- endfor %}
87-
93+
*/
94+
{%- endif %}
8895
}

0 commit comments

Comments
 (0)