Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 1402: Fix NPE when a path references an undeclared path parameter. #1403

Merged
merged 2 commits into from Aug 1, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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