REPO-3344: Web Api Parameter required is not being used (#49)

* REPO-3344: Web Api Parameter `required` is not being used
   - Added condition that checks if a body is optional and not provided
This commit is contained in:
ramunteanu
2018-03-06 10:06:46 +02:00
committed by GitHub
parent 32641d1b03
commit 9f695c33a7

View File

@@ -171,7 +171,16 @@ public class ResourceWebScriptPost extends AbstractResourceWebScript implements
Object jsonContent = null;
if (objType != null)
{
jsonContent = extractJsonContent(req, assistant.getJsonHelper(), objType);
// check if the body is optional and is not provided
if (!resourceParameter.isRequired() && Integer.valueOf(req.getHeader("content-length")) <= 0)
{
// in some cases the body is optional and the json doesn't need to be extracted
return null;
}
else
{
jsonContent = extractJsonContent(req, assistant.getJsonHelper(), objType);
}
}
if (isTypeOperation)