@@ -46,7 +46,14 @@ public void start() throws Exception {
46
46
//Consumer for addPet
47
47
vertx .eventBus ().<JsonObject > consumer (ADDPET_SERVICE_ID ).handler (message -> {
48
48
try {
49
- Pet body = Json .mapper .readValue (message .body ().getJsonObject ("body" ).encode (), Pet .class );
49
+ // Workaround for #allParams section clearing the vendorExtensions map
50
+ String serviceId = "addPet" ;
51
+ JsonObject bodyParam = message .body ().getJsonObject ("body" );
52
+ if (bodyParam == null ) {
53
+ manageError (message , new MainApiException (400 , "body is required" ), serviceId );
54
+ return ;
55
+ }
56
+ Pet body = Json .mapper .readValue (bodyParam .encode (), Pet .class );
50
57
service .addPet (body , result -> {
51
58
if (result .succeeded ())
52
59
message .reply (null );
@@ -64,8 +71,16 @@ public void start() throws Exception {
64
71
//Consumer for deletePet
65
72
vertx .eventBus ().<JsonObject > consumer (DELETEPET_SERVICE_ID ).handler (message -> {
66
73
try {
67
- Long petId = Json .mapper .readValue (message .body ().getString ("petId" ), Long .class );
68
- String apiKey = message .body ().getString ("api_key" );
74
+ // Workaround for #allParams section clearing the vendorExtensions map
75
+ String serviceId = "deletePet" ;
76
+ String petIdParam = message .body ().getString ("petId" );
77
+ if (petIdParam == null ) {
78
+ manageError (message , new MainApiException (400 , "petId is required" ), serviceId );
79
+ return ;
80
+ }
81
+ Long petId = Json .mapper .readValue (petIdParam , Long .class );
82
+ String apiKeyParam = message .body ().getString ("api_key" );
83
+ String apiKey = (apiKeyParam == null ) ? null : apiKeyParam ;
69
84
service .deletePet (petId , apiKey , result -> {
70
85
if (result .succeeded ())
71
86
message .reply (null );
@@ -83,8 +98,15 @@ public void start() throws Exception {
83
98
//Consumer for findPetsByStatus
84
99
vertx .eventBus ().<JsonObject > consumer (FINDPETSBYSTATUS_SERVICE_ID ).handler (message -> {
85
100
try {
86
- List <String > status = Json .mapper .readValue (message .body ().getJsonArray ("status" ).encode (),
87
- Json .mapper .getTypeFactory ().constructCollectionType (List .class , String .class ));
101
+ // Workaround for #allParams section clearing the vendorExtensions map
102
+ String serviceId = "findPetsByStatus" ;
103
+ JsonArray statusParam = message .body ().getJsonArray ("status" );
104
+ if (statusParam == null ) {
105
+ manageError (message , new MainApiException (400 , "status is required" ), serviceId );
106
+ return ;
107
+ }
108
+ List <String > status = Json .mapper .readValue (statusParam .encode (),
109
+ Json .mapper .getTypeFactory ().constructCollectionType (List .class , String .class ));
88
110
service .findPetsByStatus (status , result -> {
89
111
if (result .succeeded ())
90
112
message .reply (new JsonArray (Json .encode (result .result ())).encodePrettily ());
@@ -102,8 +124,15 @@ public void start() throws Exception {
102
124
//Consumer for findPetsByTags
103
125
vertx .eventBus ().<JsonObject > consumer (FINDPETSBYTAGS_SERVICE_ID ).handler (message -> {
104
126
try {
105
- List <String > tags = Json .mapper .readValue (message .body ().getJsonArray ("tags" ).encode (),
106
- Json .mapper .getTypeFactory ().constructCollectionType (List .class , String .class ));
127
+ // Workaround for #allParams section clearing the vendorExtensions map
128
+ String serviceId = "findPetsByTags" ;
129
+ JsonArray tagsParam = message .body ().getJsonArray ("tags" );
130
+ if (tagsParam == null ) {
131
+ manageError (message , new MainApiException (400 , "tags is required" ), serviceId );
132
+ return ;
133
+ }
134
+ List <String > tags = Json .mapper .readValue (tagsParam .encode (),
135
+ Json .mapper .getTypeFactory ().constructCollectionType (List .class , String .class ));
107
136
service .findPetsByTags (tags , result -> {
108
137
if (result .succeeded ())
109
138
message .reply (new JsonArray (Json .encode (result .result ())).encodePrettily ());
@@ -121,7 +150,14 @@ public void start() throws Exception {
121
150
//Consumer for getPetById
122
151
vertx .eventBus ().<JsonObject > consumer (GETPETBYID_SERVICE_ID ).handler (message -> {
123
152
try {
124
- Long petId = Json .mapper .readValue (message .body ().getString ("petId" ), Long .class );
153
+ // Workaround for #allParams section clearing the vendorExtensions map
154
+ String serviceId = "getPetById" ;
155
+ String petIdParam = message .body ().getString ("petId" );
156
+ if (petIdParam == null ) {
157
+ manageError (message , new MainApiException (400 , "petId is required" ), serviceId );
158
+ return ;
159
+ }
160
+ Long petId = Json .mapper .readValue (petIdParam , Long .class );
125
161
service .getPetById (petId , result -> {
126
162
if (result .succeeded ())
127
163
message .reply (new JsonObject (Json .encode (result .result ())).encodePrettily ());
@@ -139,7 +175,14 @@ public void start() throws Exception {
139
175
//Consumer for updatePet
140
176
vertx .eventBus ().<JsonObject > consumer (UPDATEPET_SERVICE_ID ).handler (message -> {
141
177
try {
142
- Pet body = Json .mapper .readValue (message .body ().getJsonObject ("body" ).encode (), Pet .class );
178
+ // Workaround for #allParams section clearing the vendorExtensions map
179
+ String serviceId = "updatePet" ;
180
+ JsonObject bodyParam = message .body ().getJsonObject ("body" );
181
+ if (bodyParam == null ) {
182
+ manageError (message , new MainApiException (400 , "body is required" ), serviceId );
183
+ return ;
184
+ }
185
+ Pet body = Json .mapper .readValue (bodyParam .encode (), Pet .class );
143
186
service .updatePet (body , result -> {
144
187
if (result .succeeded ())
145
188
message .reply (null );
@@ -157,9 +200,18 @@ public void start() throws Exception {
157
200
//Consumer for updatePetWithForm
158
201
vertx .eventBus ().<JsonObject > consumer (UPDATEPETWITHFORM_SERVICE_ID ).handler (message -> {
159
202
try {
160
- Long petId = Json .mapper .readValue (message .body ().getString ("petId" ), Long .class );
161
- String name = message .body ().getString ("name" );
162
- String status = message .body ().getString ("status" );
203
+ // Workaround for #allParams section clearing the vendorExtensions map
204
+ String serviceId = "updatePetWithForm" ;
205
+ String petIdParam = message .body ().getString ("petId" );
206
+ if (petIdParam == null ) {
207
+ manageError (message , new MainApiException (400 , "petId is required" ), serviceId );
208
+ return ;
209
+ }
210
+ Long petId = Json .mapper .readValue (petIdParam , Long .class );
211
+ String nameParam = message .body ().getString ("name" );
212
+ String name = (nameParam == null ) ? null : nameParam ;
213
+ String statusParam = message .body ().getString ("status" );
214
+ String status = (statusParam == null ) ? null : statusParam ;
163
215
service .updatePetWithForm (petId , name , status , result -> {
164
216
if (result .succeeded ())
165
217
message .reply (null );
@@ -177,9 +229,22 @@ public void start() throws Exception {
177
229
//Consumer for uploadFile
178
230
vertx .eventBus ().<JsonObject > consumer (UPLOADFILE_SERVICE_ID ).handler (message -> {
179
231
try {
180
- Long petId = Json .mapper .readValue (message .body ().getString ("petId" ), Long .class );
181
- String additionalMetadata = message .body ().getString ("additionalMetadata" );
182
- File file = Json .mapper .readValue (message .body ().getJsonObject ("file" ).encode (), File .class );
232
+ // Workaround for #allParams section clearing the vendorExtensions map
233
+ String serviceId = "uploadFile" ;
234
+ String petIdParam = message .body ().getString ("petId" );
235
+ if (petIdParam == null ) {
236
+ manageError (message , new MainApiException (400 , "petId is required" ), serviceId );
237
+ return ;
238
+ }
239
+ Long petId = Json .mapper .readValue (petIdParam , Long .class );
240
+ String additionalMetadataParam = message .body ().getString ("additionalMetadata" );
241
+ String additionalMetadata = (additionalMetadataParam == null ) ? null : additionalMetadataParam ;
242
+ JsonObject fileParam = message .body ().getJsonObject ("file" );
243
+ if (fileParam == null ) {
244
+ manageError (message , new MainApiException (400 , "file is required" ), serviceId );
245
+ return ;
246
+ }
247
+ File file = Json .mapper .readValue (fileParam .encode (), File .class );
183
248
service .uploadFile (petId , additionalMetadata , file , result -> {
184
249
if (result .succeeded ())
185
250
message .reply (new JsonObject (Json .encode (result .result ())).encodePrettily ());
0 commit comments