diff --git a/components/mediation-commons/src/main/java/org/wso2/carbon/mediation/commons/rest/api/swagger/OpenAPIProcessor.java b/components/mediation-commons/src/main/java/org/wso2/carbon/mediation/commons/rest/api/swagger/OpenAPIProcessor.java index 30b3b7e140..07fd00f722 100644 --- a/components/mediation-commons/src/main/java/org/wso2/carbon/mediation/commons/rest/api/swagger/OpenAPIProcessor.java +++ b/components/mediation-commons/src/main/java/org/wso2/carbon/mediation/commons/rest/api/swagger/OpenAPIProcessor.java @@ -338,28 +338,27 @@ private void addDefaultResponseAndPathItem(PathItem pathItem, Operation operatio */ private void addDefaultRequestBody(Operation operation, Map.Entry methodEntry) { if (operation.getRequestBody() == null) { - RequestBody requestBody = new RequestBody(); - requestBody.description("Sample Payload"); - requestBody.setRequired(false); - - MediaType mediaType = new MediaType(); - Schema bodySchema = new Schema(); - bodySchema.setType("object"); - - Map inputProperties = new HashMap<>(); - ObjectSchema objectSchema = new ObjectSchema(); - - bodySchema.setProperties(inputProperties); - inputProperties.put("payload", objectSchema); - mediaType.setSchema(bodySchema); - Content content = new Content(); - content.addMediaType("application/json", mediaType); - requestBody.setContent(content); - switch ((String) methodEntry.getKey()) { case OPERATION_HTTP_POST: case OPERATION_HTTP_PUT: case OPERATION_HTTP_PATCH: + RequestBody requestBody = new RequestBody(); + requestBody.description("Sample Payload"); + requestBody.setRequired(false); + + MediaType mediaType = new MediaType(); + Schema bodySchema = new Schema(); + bodySchema.setType("object"); + + Map inputProperties = new HashMap<>(); + ObjectSchema objectSchema = new ObjectSchema(); + + bodySchema.setProperties(inputProperties); + inputProperties.put("payload", objectSchema); + mediaType.setSchema(bodySchema); + Content content = new Content(); + content.addMediaType("application/json", mediaType); + requestBody.setContent(content); operation.setRequestBody(requestBody); break; }