@@ -46,7 +46,14 @@ public void start() throws Exception {
4646 //Consumer for addPet
4747 vertx .eventBus ().<JsonObject > consumer (ADDPET_SERVICE_ID ).handler (message -> {
4848 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 );
5057 service .addPet (body , result -> {
5158 if (result .succeeded ())
5259 message .reply (null );
@@ -64,8 +71,16 @@ public void start() throws Exception {
6471 //Consumer for deletePet
6572 vertx .eventBus ().<JsonObject > consumer (DELETEPET_SERVICE_ID ).handler (message -> {
6673 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 ;
6984 service .deletePet (petId , apiKey , result -> {
7085 if (result .succeeded ())
7186 message .reply (null );
@@ -83,8 +98,15 @@ public void start() throws Exception {
8398 //Consumer for findPetsByStatus
8499 vertx .eventBus ().<JsonObject > consumer (FINDPETSBYSTATUS_SERVICE_ID ).handler (message -> {
85100 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 ));
88110 service .findPetsByStatus (status , result -> {
89111 if (result .succeeded ())
90112 message .reply (new JsonArray (Json .encode (result .result ())).encodePrettily ());
@@ -102,8 +124,15 @@ public void start() throws Exception {
102124 //Consumer for findPetsByTags
103125 vertx .eventBus ().<JsonObject > consumer (FINDPETSBYTAGS_SERVICE_ID ).handler (message -> {
104126 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 ));
107136 service .findPetsByTags (tags , result -> {
108137 if (result .succeeded ())
109138 message .reply (new JsonArray (Json .encode (result .result ())).encodePrettily ());
@@ -121,7 +150,14 @@ public void start() throws Exception {
121150 //Consumer for getPetById
122151 vertx .eventBus ().<JsonObject > consumer (GETPETBYID_SERVICE_ID ).handler (message -> {
123152 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 );
125161 service .getPetById (petId , result -> {
126162 if (result .succeeded ())
127163 message .reply (new JsonObject (Json .encode (result .result ())).encodePrettily ());
@@ -139,7 +175,14 @@ public void start() throws Exception {
139175 //Consumer for updatePet
140176 vertx .eventBus ().<JsonObject > consumer (UPDATEPET_SERVICE_ID ).handler (message -> {
141177 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 );
143186 service .updatePet (body , result -> {
144187 if (result .succeeded ())
145188 message .reply (null );
@@ -157,9 +200,18 @@ public void start() throws Exception {
157200 //Consumer for updatePetWithForm
158201 vertx .eventBus ().<JsonObject > consumer (UPDATEPETWITHFORM_SERVICE_ID ).handler (message -> {
159202 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 ;
163215 service .updatePetWithForm (petId , name , status , result -> {
164216 if (result .succeeded ())
165217 message .reply (null );
@@ -177,9 +229,22 @@ public void start() throws Exception {
177229 //Consumer for uploadFile
178230 vertx .eventBus ().<JsonObject > consumer (UPLOADFILE_SERVICE_ID ).handler (message -> {
179231 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 );
183248 service .uploadFile (petId , additionalMetadata , file , result -> {
184249 if (result .succeeded ())
185250 message .reply (new JsonObject (Json .encode (result .result ())).encodePrettily ());
0 commit comments