}
/**
- * Get path parameters name for {@code path}.
+ * Get path parameters names for {@code path} for GET operation.
+ *
+ * @return {@link List} of parameters excluding `content` parameter
+ */
+ public static List<String> getPathGetParameters(final Map<String, Path> paths, final String path) {
+ return paths.get(path).get().parameters()
+ .stream()
+ .map(Parameter::name)
+ .filter(p -> !"content".equals(p))
+ .toList();
+ }
+
+ /**
+ * Get path parameters names for {@code path} for POST operation.
*
* @return {@link List} of parameters
*/
- public static List<String> getPathParameters(final Map<String, Path> paths, final String path) {
+ public static List<String> getPathPostParameters(final Map<String, Path> paths, final String path) {
return paths.get(path).post().parameters()
.stream()
.map(Parameter::name)
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import static org.opendaylight.restconf.openapi.OpenApiTestUtils.getPathParameters;
+import static org.opendaylight.restconf.openapi.OpenApiTestUtils.getPathGetParameters;
import java.util.List;
import org.junit.BeforeClass;
+ "/multiple-key-list2={name1},{name3}/multiple-key-list3={name31},{name4}/multiple-key-list4={name5}";
assertTrue(doc.paths().containsKey(pathToMultipleKeyList4));
assertEquals(List.of("name","name2", "name1", "name3", "name31", "name4", "name5"),
- getPathParameters(doc.paths(), pathToMultipleKeyList4));
+ getPathGetParameters(doc.paths(), pathToMultipleKeyList4));
}
}
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import static org.opendaylight.restconf.openapi.OpenApiTestUtils.getPathParameters;
+import static org.opendaylight.restconf.openapi.OpenApiTestUtils.getPathGetParameters;
+import static org.opendaylight.restconf.openapi.OpenApiTestUtils.getPathPostParameters;
import static org.opendaylight.restconf.openapi.impl.BaseYangOpenApiGenerator.BASIC_AUTH_NAME;
import com.fasterxml.jackson.databind.JsonNode;
var pathToList1 = "/rests/data/path-params-test:cont/list1={name}";
assertTrue(doc.paths().containsKey(pathToList1));
- assertEquals(List.of("name"), getPathParameters(doc.paths(), pathToList1));
+ assertEquals(List.of("name"), getPathGetParameters(doc.paths(), pathToList1));
var pathToList2 = "/rests/data/path-params-test:cont/list1={name}/list2={name1}";
assertTrue(doc.paths().containsKey(pathToList2));
- assertEquals(List.of("name", "name1"), getPathParameters(doc.paths(), pathToList2));
+ assertEquals(List.of("name", "name1"), getPathGetParameters(doc.paths(), pathToList2));
var pathToList3 = "/rests/data/path-params-test:cont/list3={name}";
assertTrue(doc.paths().containsKey(pathToList3));
- assertEquals(List.of("name"), getPathParameters(doc.paths(), pathToList3));
+ assertEquals(List.of("name"), getPathGetParameters(doc.paths(), pathToList3));
var pathToList4 = "/rests/data/path-params-test:cont/list1={name}/list4={name1}";
assertTrue(doc.paths().containsKey(pathToList4));
- assertEquals(List.of("name", "name1"), getPathParameters(doc.paths(), pathToList4));
+ assertEquals(List.of("name", "name1"), getPathGetParameters(doc.paths(), pathToList4));
var pathToList5 = "/rests/data/path-params-test:cont/list1={name}/cont2";
assertTrue(doc.paths().containsKey(pathToList4));
- assertEquals(List.of("name"), getPathParameters(doc.paths(), pathToList5));
+ assertEquals(List.of("name"), getPathGetParameters(doc.paths(), pathToList5));
}
/**
final var pathWithParameters = "/rests/operations/action-types:list={name}/list-action";
assertTrue(doc.paths().containsKey(pathWithParameters));
- assertEquals(List.of("name"), getPathParameters(doc.paths(), pathWithParameters));
+ assertEquals(List.of("name"), getPathPostParameters(doc.paths(), pathWithParameters));
final var pathWithoutParameters = "/rests/operations/action-types:multi-container/inner-container/action";
assertTrue(doc.paths().containsKey(pathWithoutParameters));
- assertEquals(List.of(), getPathParameters(doc.paths(), pathWithoutParameters));
+ assertEquals(List.of(), getPathPostParameters(doc.paths(), pathWithoutParameters));
}
@Test
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import static org.opendaylight.restconf.openapi.OpenApiTestUtils.getPathParameters;
+import static org.opendaylight.restconf.openapi.OpenApiTestUtils.getPathGetParameters;
+import static org.opendaylight.restconf.openapi.OpenApiTestUtils.getPathPostParameters;
import static org.opendaylight.restconf.openapi.impl.BaseYangOpenApiGenerator.BASIC_AUTH_NAME;
import java.util.ArrayList;
var pathToList1 = "/rests/data/nodes/node=123/yang-ext:mount/path-params-test:cont/list1={name}";
assertTrue(mountPointApi.paths().containsKey(pathToList1));
- assertEquals(List.of("name"), getPathParameters(mountPointApi.paths(), pathToList1));
+ assertEquals(List.of("name"), getPathGetParameters(mountPointApi.paths(), pathToList1));
var pathToList2 = "/rests/data/nodes/node=123/yang-ext:mount/path-params-test:cont/list1={name}/list2={name1}";
assertTrue(mountPointApi.paths().containsKey(pathToList2));
- assertEquals(List.of("name", "name1"), getPathParameters(mountPointApi.paths(), pathToList2));
+ assertEquals(List.of("name", "name1"), getPathGetParameters(mountPointApi.paths(), pathToList2));
var pathToList3 = "/rests/data/nodes/node=123/yang-ext:mount/path-params-test:cont/list3={name}";
assertTrue(mountPointApi.paths().containsKey(pathToList3));
- assertEquals(List.of("name"), getPathParameters(mountPointApi.paths(), pathToList3));
+ assertEquals(List.of("name"), getPathGetParameters(mountPointApi.paths(), pathToList3));
var pathToList4 = "/rests/data/nodes/node=123/yang-ext:mount/path-params-test:cont/list1={name}/list4={name1}";
assertTrue(mountPointApi.paths().containsKey(pathToList4));
- assertEquals(List.of("name", "name1"), getPathParameters(mountPointApi.paths(), pathToList4));
+ assertEquals(List.of("name", "name1"), getPathGetParameters(mountPointApi.paths(), pathToList4));
var pathToList5 = "/rests/data/nodes/node=123/yang-ext:mount/path-params-test:cont/list1={name}/cont2";
assertTrue(mountPointApi.paths().containsKey(pathToList5));
- assertEquals(List.of("name"), getPathParameters(mountPointApi.paths(), pathToList5));
+ assertEquals(List.of("name"), getPathGetParameters(mountPointApi.paths(), pathToList5));
}
/**
final var pathWithParameters =
"/rests/operations/nodes/node=123/yang-ext:mount/action-types:list={name}/list-action";
assertTrue(mountPointApi.paths().containsKey(pathWithParameters));
- assertEquals(List.of("name"), getPathParameters(mountPointApi.paths(), pathWithParameters));
+ assertEquals(List.of("name"), getPathPostParameters(mountPointApi.paths(), pathWithParameters));
final var pathWithoutParameters =
"/rests/operations/nodes/node=123/yang-ext:mount/action-types:multi-container/inner-container/action";
assertTrue(mountPointApi.paths().containsKey(pathWithoutParameters));
- assertEquals(List.of(), getPathParameters(mountPointApi.paths(), pathWithoutParameters));
+ assertEquals(List.of(), getPathPostParameters(mountPointApi.paths(), pathWithoutParameters));
}
/**