parsing request body (partial implementation)
@@ -18,6 +18,7 @@ import io.swagger.oas.models.parameters.HeaderParameter;
import io.swagger.oas.models.parameters.Parameter;
import io.swagger.oas.models.parameters.PathParameter;
import io.swagger.oas.models.parameters.QueryParameter;
+import io.swagger.oas.models.parameters.RequestBody;
import io.swagger.oas.models.responses.ApiResponse;
import io.swagger.oas.models.responses.ApiResponses;
import io.swagger.oas.models.security.SecurityRequirement;
@@ -704,7 +705,8 @@ public class OpenAPIDeserializer {
ApiResponses responses = getResponses(responsesNode, "responses", result);
operation.setResponses(responses);
- //output.setResponses(responsesObject);
+ final ObjectNode requestObjectNode = getObject("requestBody", obj, false, location, result);
+ operation.setRequestBody(getRequestBody(requestObjectNode, location, result));
array = getArray("schemes", obj, false, location, result);
if (array != null) {
@@ -782,6 +784,21 @@ public class OpenAPIDeserializer {
return output;
}
+ protected RequestBody getRequestBody(ObjectNode node, String location, ParseResult result) {
+ final RequestBody body = new RequestBody();
+ final String description = getString("description", node, false, location, result);
+ final Boolean required = getBoolean("required", node, false, location, result);
+
+ body.setDescription(description);
+ body.setRequired(required);
+
+ final ObjectNode contentNode = getObject("content", node, false, location, result);
+ // TODO parse content and media type objects.
+ return body;
+ }
+
+
+
protected static class ParseResult {
private boolean valid = true;
