Skip to content

Commit 430108a

Browse files
committed
rest spec parser picks up deprecated paths as paths too
1 parent 8fe223e commit 430108a

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

test/framework/src/main/java/org/elasticsearch/test/rest/yaml/restspec/ClientYamlSuiteRestApiParser.java

+16-4
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,16 @@ public ClientYamlSuiteRestApi parse(String location, XContentParser parser) thro
7070
}
7171
if (parser.currentToken() == XContentParser.Token.START_ARRAY && "paths".equals(currentFieldName)) {
7272
while (parser.nextToken() == XContentParser.Token.VALUE_STRING) {
73-
String path = parser.text();
74-
if (restApi.getPaths().contains(path)) {
75-
throw new IllegalArgumentException("Found duplicate path [" + path + "]");
73+
addPathToApi(parser.text(), restApi);
74+
}
75+
}
76+
if (parser.currentToken() == XContentParser.Token.START_ARRAY && "deprecated_paths".equals(currentFieldName)) {
77+
while (parser.nextToken() != XContentParser.Token.END_ARRAY) {
78+
if (parser.currentToken() == XContentParser.Token.FIELD_NAME && "path".equals(parser.currentName()))
79+
{
80+
parser.nextToken();
81+
addPathToApi(parser.text(), restApi);
7682
}
77-
restApi.addPath(path);
7883
}
7984
}
8085

@@ -142,6 +147,13 @@ public ClientYamlSuiteRestApi parse(String location, XContentParser parser) thro
142147
return restApi;
143148
}
144149

150+
private void addPathToApi(String path, ClientYamlSuiteRestApi restApi) {
151+
if (restApi.getPaths().contains(path)) {
152+
throw new IllegalArgumentException("Found duplicate path [" + path + "]");
153+
}
154+
restApi.addPath(path);
155+
}
156+
145157
private static class Parameter {
146158
private boolean required;
147159
public boolean isRequired() {

0 commit comments

Comments
 (0)