URI_INFO = DocGenTestHelper.createMockUriInfo("http://localhost/path");
}
- protected static List<String> getPathParameters(final ObjectNode paths, final String path) {
+ protected static List<String> getPathPostParameters(final ObjectNode paths, final String path) {
final var params = new ArrayList<String>();
paths.get(path).get("post").get("parameters").elements()
.forEachRemaining(p -> params.add(p.get("name").asText()));
return params;
}
+
+ /**
+ * Get path parameters names for {@code path} for GET operation.
+ *
+ * @return {@link List} of parameters excluding `content` parameter
+ */
+ public static List<String> getPathGetParameters(final ObjectNode paths, final String path) {
+ final var params = new ArrayList<String>();
+ paths.get(path).get("get").get("parameters").elements()
+ .forEachRemaining(p -> {
+ final String name = p.get("name").asText();
+ if (!"content".equals(name)) {
+ params.add(name);
+ }
+ });
+ return params;
+ }
}
var pathToList1 = "/rests/data/path-params-test:cont/list1={name}";
assertTrue(doc.getPaths().has(pathToList1));
- assertEquals(List.of("name"), getPathParameters(doc.getPaths(), pathToList1));
+ assertEquals(List.of("name"), getPathGetParameters(doc.getPaths(), pathToList1));
var pathToList2 = "/rests/data/path-params-test:cont/list1={name}/list2={name1}";
assertTrue(doc.getPaths().has(pathToList2));
- assertEquals(List.of("name", "name1"), getPathParameters(doc.getPaths(), pathToList2));
+ assertEquals(List.of("name", "name1"), getPathGetParameters(doc.getPaths(), pathToList2));
var pathToList3 = "/rests/data/path-params-test:cont/list3={name}";
assertTrue(doc.getPaths().has(pathToList3));
- assertEquals(List.of("name"), getPathParameters(doc.getPaths(), pathToList3));
+ assertEquals(List.of("name"), getPathGetParameters(doc.getPaths(), pathToList3));
var pathToList4 = "/rests/data/path-params-test:cont/list1={name}/list4={name1}";
assertTrue(doc.getPaths().has(pathToList4));
- assertEquals(List.of("name", "name1"), getPathParameters(doc.getPaths(), pathToList4));
+ assertEquals(List.of("name", "name1"), getPathGetParameters(doc.getPaths(), pathToList4));
var pathToList5 = "/rests/data/path-params-test:cont/list1={name}/cont2";
assertTrue(doc.getPaths().has(pathToList4));
- assertEquals(List.of("name"), getPathParameters(doc.getPaths(), pathToList5));
+ assertEquals(List.of("name"), getPathGetParameters(doc.getPaths(), pathToList5));
}
private static void verifyThatPropertyDoesNotHaveRequired(final List<String> expected,
final var pathWithParameters = "/rests/operations/action-types:list={name}/list-action";
assertTrue(doc.getPaths().has(pathWithParameters));
- assertEquals(List.of("name"), getPathParameters(doc.getPaths(), pathWithParameters));
+ assertEquals(List.of("name"), getPathPostParameters(doc.getPaths(), pathWithParameters));
final var pathWithoutParameters = "/rests/operations/action-types:multi-container/inner-container/action";
assertTrue(doc.getPaths().has(pathWithoutParameters));
- assertEquals(List.of(), getPathParameters(doc.getPaths(), pathWithoutParameters));
+ assertEquals(List.of(), getPathPostParameters(doc.getPaths(), pathWithoutParameters));
}
@Test
var pathToList1 = "/rests/data/nodes/node=123/yang-ext:mount/path-params-test:cont/list1={name}";
assertTrue(mountPointApi.getPaths().has(pathToList1));
- assertEquals(List.of("name"), getPathParameters(mountPointApi.getPaths(), pathToList1));
+ assertEquals(List.of("name"), getPathGetParameters(mountPointApi.getPaths(), pathToList1));
var pathToList2 = "/rests/data/nodes/node=123/yang-ext:mount/path-params-test:cont/list1={name}/list2={name1}";
assertTrue(mountPointApi.getPaths().has(pathToList2));
- assertEquals(List.of("name", "name1"), getPathParameters(mountPointApi.getPaths(), pathToList2));
+ assertEquals(List.of("name", "name1"), getPathGetParameters(mountPointApi.getPaths(), pathToList2));
var pathToList3 = "/rests/data/nodes/node=123/yang-ext:mount/path-params-test:cont/list3={name}";
assertTrue(mountPointApi.getPaths().has(pathToList3));
- assertEquals(List.of("name"), getPathParameters(mountPointApi.getPaths(), pathToList3));
+ assertEquals(List.of("name"), getPathGetParameters(mountPointApi.getPaths(), pathToList3));
var pathToList4 = "/rests/data/nodes/node=123/yang-ext:mount/path-params-test:cont/list1={name}/list4={name1}";
assertTrue(mountPointApi.getPaths().has(pathToList4));
- assertEquals(List.of("name", "name1"), getPathParameters(mountPointApi.getPaths(), pathToList4));
+ assertEquals(List.of("name", "name1"), getPathGetParameters(mountPointApi.getPaths(), pathToList4));
var pathToList5 = "/rests/data/nodes/node=123/yang-ext:mount/path-params-test:cont/list1={name}/cont2";
assertTrue(mountPointApi.getPaths().has(pathToList5));
- assertEquals(List.of("name"), getPathParameters(mountPointApi.getPaths(), pathToList5));
+ assertEquals(List.of("name"), getPathGetParameters(mountPointApi.getPaths(), pathToList5));
}
/**
final var pathWithParameters =
"/rests/operations/nodes/node=123/yang-ext:mount/action-types:list={name}/list-action";
assertTrue(mountPointApi.getPaths().has(pathWithParameters));
- assertEquals(List.of("name"), getPathParameters(mountPointApi.getPaths(), pathWithParameters));
+ assertEquals(List.of("name"), getPathPostParameters(mountPointApi.getPaths(), pathWithParameters));
final var pathWithoutParameters =
"/rests/operations/nodes/node=123/yang-ext:mount/action-types:multi-container/inner-container/action";
assertTrue(mountPointApi.getPaths().has(pathWithoutParameters));
- assertEquals(List.of(), getPathParameters(mountPointApi.getPaths(), pathWithoutParameters));
+ assertEquals(List.of(), getPathPostParameters(mountPointApi.getPaths(), pathWithoutParameters));
}
@Test