Skip to content

Commit

Permalink
fix PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rosensilva committed Oct 5, 2023
1 parent 131e12c commit e6d36df
Showing 1 changed file with 17 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Schema> 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<String, Schema> 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;
}
Expand Down

0 comments on commit e6d36df

Please sign in to comment.