From 430108a1434067d9d9929fef3ececd60d0087b32 Mon Sep 17 00:00:00 2001 From: Mpdreamz Date: Mon, 8 Apr 2019 18:00:43 +0200 Subject: [PATCH] rest spec parser picks up deprecated paths as paths too --- .../ClientYamlSuiteRestApiParser.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/restspec/ClientYamlSuiteRestApiParser.java b/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/restspec/ClientYamlSuiteRestApiParser.java index fefd6e6a276c6..3c6216eed76ed 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/restspec/ClientYamlSuiteRestApiParser.java +++ b/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/restspec/ClientYamlSuiteRestApiParser.java @@ -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); } } @@ -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() {