Skip to content

Commit

Permalink
rest spec parser picks up deprecated paths as paths too
Browse files Browse the repository at this point in the history
  • Loading branch information
Mpdreamz committed Apr 9, 2019
1 parent 8fe223e commit 430108a
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,16 @@ public ClientYamlSuiteRestApi parse(String location, XContentParser parser) thro
}
if (parser.currentToken() == XContentParser.Token.START_ARRAY && "paths".equals(currentFieldName)) {
while (parser.nextToken() == XContentParser.Token.VALUE_STRING) {
String path = parser.text();
if (restApi.getPaths().contains(path)) {
throw new IllegalArgumentException("Found duplicate path [" + path + "]");
addPathToApi(parser.text(), restApi);
}
}
if (parser.currentToken() == XContentParser.Token.START_ARRAY && "deprecated_paths".equals(currentFieldName)) {
while (parser.nextToken() != XContentParser.Token.END_ARRAY) {
if (parser.currentToken() == XContentParser.Token.FIELD_NAME && "path".equals(parser.currentName()))
{
parser.nextToken();
addPathToApi(parser.text(), restApi);
}
restApi.addPath(path);
}
}

Expand Down Expand Up @@ -142,6 +147,13 @@ public ClientYamlSuiteRestApi parse(String location, XContentParser parser) thro
return restApi;
}

private void addPathToApi(String path, ClientYamlSuiteRestApi restApi) {
if (restApi.getPaths().contains(path)) {
throw new IllegalArgumentException("Found duplicate path [" + path + "]");
}
restApi.addPath(path);
}

private static class Parameter {
private boolean required;
public boolean isRequired() {
Expand Down

0 comments on commit 430108a

Please sign in to comment.