File tree Expand file tree Collapse file tree 3 files changed +32
-1
lines changed
deployment/src/main/resources/templates/libraries/microprofile
integration-tests/array-enum/src
test/java/io/quarkiverse/openapi/generator/it Expand file tree Collapse file tree 3 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -107,12 +107,18 @@ public class {m.classname} {#if m.parent}extends {m.parent}{/if}{#if m.serializa
107107 }
108108 {#if v.isArray}
109109 public {m.classname} add{v.nameInCamelCase}Item({v.items.datatypeWithEnum} {v.name}Item) {
110+ if (this.{v.name} == null){
111+ {v.name} = {#if v.defaultValue}{v.defaultValue}{#else}new {#if v.uniqueItems}LinkedHashSet{/if}{#if !v.uniqueItems}ArrayList{/if}<>(){/if};
112+ }
110113 this.{v.name}.add({v.name}Item);
111114 return this;
112115 }
113116 {/if}
114117 {#if v.isMap}
115118 public {m.classname} put{v.nameInCamelCase}Item(String key, {v.items.datatypeWithEnum} {v.name}Item) {
119+ if (this.{v.name} == null){
120+ {v.name} = {#if v.defaultValue}{v.defaultValue}{#else}new HashMap<>(){/if};
121+ }
116122 this.{v.name}.put(key, {v.name}Item);
117123 return this;
118124 }
Original file line number Diff line number Diff line change 3030components :
3131 schemas :
3232 webhook_create_update_payload :
33+ required : [url, subscriptions]
3334 type : object
3435 properties :
3536 url :
@@ -46,4 +47,13 @@ components:
4647 - message_created
4748 - message_updated
4849 - webwidget_triggered
49- description : The events you want to subscribe to.
50+ description : The events you want to subscribe to.
51+ message :
52+ type : array
53+ items :
54+ type : string
55+ description : Non required Field to safe messages
56+ messageMap :
57+ type : object
58+ additionalProperties : true
59+ description : Non required Map Field to safe messages
Original file line number Diff line number Diff line change 77import org .eclipse .microprofile .rest .client .inject .RestClient ;
88import org .junit .jupiter .api .Test ;
99import org .openapi .quarkus .array_enum_yaml .api .ArrayEnumResourceApi ;
10+ import org .openapi .quarkus .array_enum_yaml .model .WebhookCreateUpdatePayload ;
1011
1112import io .quarkus .test .junit .QuarkusTest ;
1213
@@ -21,4 +22,18 @@ class ArrayEnumTest {
2122 void apiIsBeingGenerated () {
2223 assertThat (api ).isNotNull ();
2324 }
25+
26+ @ Test
27+ void modelNonRequiredFieldTest () {
28+ WebhookCreateUpdatePayload webhookCreateUpdatePayload = new WebhookCreateUpdatePayload ();
29+
30+ assertThat (webhookCreateUpdatePayload .getMessage ()).isNull ();
31+ assertThat (webhookCreateUpdatePayload .getMessageMap ()).isNull ();
32+
33+ webhookCreateUpdatePayload .addMessageItem ("Test" );
34+ webhookCreateUpdatePayload .putMessageMapItem ("Test" , "Test" );
35+
36+ assertThat (webhookCreateUpdatePayload .getMessage ()).isNotNull ();
37+ assertThat (webhookCreateUpdatePayload .getMessageMap ()).isNotNull ();
38+ }
2439}
You can’t perform that action at this time.
0 commit comments