Skip to content

Commit

Permalink
Merge pull request #1403 from brhaible/issue-1402
Browse files Browse the repository at this point in the history
Issue 1402: Fix NPE when a path references an undeclared path parameter.
  • Loading branch information
gracekarina authored Aug 1, 2020
2 parents a92ddf7 + 680c88b commit 93676f0
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -560,12 +560,16 @@ public Paths getPaths(ObjectNode obj, String location, ParseResult result) {
if (!definedInPathLevel) {
List<Operation> operationsInAPath = getAllOperationsInAPath(pathObj);
operationsInAPath.forEach(operation -> {
operation.getParameters().forEach(parameter -> {
List<Parameter> operationParameters = operation.getParameters();
if (operationParameters == null) {
operationParameters = Collections.<Parameter>emptyList();
}
operationParameters.forEach(parameter -> {
if(PATH_PARAMETER.equalsIgnoreCase(parameter.getIn()) && Boolean.FALSE.equals(parameter.getRequired())){
result.warning(location, "For path parameter "+ parameter.getName() + " the required value should be true");
}
});
if (!isPathParamDefined(pathParam, operation.getParameters())) {
if (!isPathParamDefined(pathParam, operationParameters)) {
result.warning(location + ".'" + pathName + "'"," Declared path parameter " + pathParam + " needs to be defined as a path parameter in path or operation level");
return;
}
Expand Down

0 comments on commit 93676f0

Please sign in to comment.