From 8ac78ef598f0b751dad481b997150f9e91b63472 Mon Sep 17 00:00:00 2001 From: Ivan Hrasko Date: Tue, 10 Oct 2023 15:41:24 +0200 Subject: [PATCH] Adapt tests for OpenApi As intermediate step in adaptation from OpenApiObject record removed all tests. Edited AbstractDocumentTest class to save functionality. JIRA: NETCONF-938 Change-Id: Ie64b28037652a7608f2129b19dd822400216e88e Signed-off-by: Ivan Hrasko Signed-off-by: lubos-cicut --- .../impl/BaseYangOpenApiGenerator.java | 2 +- .../restconf/openapi/DocGenTestHelper.java | 61 -- .../restconf/openapi/JsonModelNameTest.java | 99 --- .../restconf/openapi/OpenApiTestUtils.java | 45 -- .../restconf/openapi/OperationalDataTest.java | 267 ------- .../restconf/openapi/SchemaObjectsTest.java | 114 --- .../openapi/impl/AbstractDocumentTest.java | 34 +- .../openapi/impl/DefinitionGeneratorTest.java | 310 -------- .../openapi/impl/KeysMappingTest.java | 91 --- .../openapi/impl/ListPostRequestsTest.java | 76 -- .../impl/OpenApiGeneratorRFC8040Test.java | 658 ---------------- .../openapi/impl/OpenApiServiceImplTest.java | 71 -- .../openapi/impl/OpenApiXmlNamespaceTest.java | 171 ---- .../openapi/impl/PostPayloadTest.java | 171 ---- .../CustomOpenApiBasePathTest.java | 128 --- .../mountpoints/MountPointOpenApiTest.java | 443 ----------- .../controller-action-types.json | 2 +- .../operational-document/controller-all.json | 2 +- .../controller-operational.json | 2 +- .../device-action-types.json | 2 +- .../operational-document/device-all.json | 2 +- .../device-operational.json | 2 +- .../test/resources/sample-swagger-spec.json | 440 ----------- .../toaster-document/controller-all.json | 2 +- .../toaster-document/controller-toaster.json | 2 +- .../toaster-document/device-all.json | 2 +- .../toaster-document/device-toaster.json | 2 +- .../src/test/resources/toaster.json | 167 ---- .../src/test/resources/topology-good.json | 106 --- .../src/test/resources/topology-new.json | 35 - .../src/test/resources/topology.json | 730 ------------------ .../src/test/resources/wadl.xml | 142 ---- .../controller-action-types.json | 2 +- .../yang-document/controller-all.json | 2 +- .../yang-document/controller-choice-test.json | 2 +- .../controller-definition-test.json | 2 +- .../controller-mandatory-test.json | 2 +- .../yang-document/controller-my-yang.json | 2 +- .../yang-document/controller-opflex.json | 2 +- .../controller-path-params-test.json | 2 +- .../yang-document/controller-recursive.json | 2 +- .../controller-string-from-regex.json | 2 +- .../controller-string-types.json | 2 +- .../controller-test-container-childs.json | 2 +- .../controller-toaster-augmented.json | 2 +- .../yang-document/controller-toaster.json | 2 +- .../yang-document/controller-toaster2.json | 2 +- .../controller-typed-params.json | 2 +- .../yang-document/device-action-types.json | 2 +- .../resources/yang-document/device-all.json | 2 +- .../yang-document/device-choice-test.json | 2 +- .../yang-document/device-definition-test.json | 2 +- .../yang-document/device-mandatory-test.json | 2 +- .../yang-document/device-my-yang.json | 2 +- .../yang-document/device-opflex.json | 2 +- .../device-path-params-test.json | 2 +- .../yang-document/device-recursive.json | 2 +- .../device-string-from-regex.json | 2 +- .../yang-document/device-string-types.json | 2 +- .../device-test-container-childs.json | 2 +- .../device-toaster-augmented.json | 2 +- .../yang-document/device-toaster.json | 2 +- .../yang-document/device-toaster2.json | 2 +- .../yang-document/device-typed-params.json | 2 +- 64 files changed, 70 insertions(+), 4375 deletions(-) delete mode 100644 restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/DocGenTestHelper.java delete mode 100644 restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/JsonModelNameTest.java delete mode 100644 restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/OpenApiTestUtils.java delete mode 100644 restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/OperationalDataTest.java delete mode 100644 restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/SchemaObjectsTest.java delete mode 100644 restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/impl/DefinitionGeneratorTest.java delete mode 100644 restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/impl/KeysMappingTest.java delete mode 100644 restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/impl/ListPostRequestsTest.java delete mode 100644 restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/impl/OpenApiGeneratorRFC8040Test.java delete mode 100644 restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/impl/OpenApiServiceImplTest.java delete mode 100644 restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/impl/OpenApiXmlNamespaceTest.java delete mode 100644 restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/impl/PostPayloadTest.java delete mode 100644 restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/mountpoints/CustomOpenApiBasePathTest.java delete mode 100644 restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/mountpoints/MountPointOpenApiTest.java delete mode 100644 restconf/restconf-openapi/src/test/resources/sample-swagger-spec.json delete mode 100644 restconf/restconf-openapi/src/test/resources/toaster.json delete mode 100644 restconf/restconf-openapi/src/test/resources/topology-good.json delete mode 100644 restconf/restconf-openapi/src/test/resources/topology-new.json delete mode 100644 restconf/restconf-openapi/src/test/resources/topology.json delete mode 100644 restconf/restconf-openapi/src/test/resources/wadl.xml diff --git a/restconf/restconf-openapi/src/main/java/org/opendaylight/restconf/openapi/impl/BaseYangOpenApiGenerator.java b/restconf/restconf-openapi/src/main/java/org/opendaylight/restconf/openapi/impl/BaseYangOpenApiGenerator.java index f9ab42c6ac..2f6648b474 100644 --- a/restconf/restconf-openapi/src/main/java/org/opendaylight/restconf/openapi/impl/BaseYangOpenApiGenerator.java +++ b/restconf/restconf-openapi/src/main/java/org/opendaylight/restconf/openapi/impl/BaseYangOpenApiGenerator.java @@ -85,7 +85,7 @@ public abstract class BaseYangOpenApiGenerator { public static final String DESCRIPTION = """ We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE). For operational data we only provide GET API.\n - For majority of request you can see only config data in examples. That’s because we can show only one example + For majority of request you can see only config data in examples. That is because we can show only one example per request. The exception when you can see operational data in example is when data are representing operational (config false) container with no config data in it."""; diff --git a/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/DocGenTestHelper.java b/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/DocGenTestHelper.java deleted file mode 100644 index 0b91b0979a..0000000000 --- a/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/DocGenTestHelper.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2014 Brocade Communications Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.restconf.openapi; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.net.URI; -import java.util.Map; -import javax.ws.rs.core.UriBuilder; -import javax.ws.rs.core.UriInfo; -import org.mockito.ArgumentCaptor; -import org.opendaylight.restconf.openapi.model.Property; -import org.opendaylight.restconf.openapi.model.Schema; - -public final class DocGenTestHelper { - - private DocGenTestHelper() { - // hidden on purpose - } - - public static UriInfo createMockUriInfo(final String urlPrefix) throws Exception { - final URI uri = new URI(urlPrefix); - final UriBuilder mockBuilder = mock(UriBuilder.class); - - final ArgumentCaptor subStringCapture = ArgumentCaptor.forClass(String.class); - when(mockBuilder.path(subStringCapture.capture())).thenReturn(mockBuilder); - when(mockBuilder.build()).then(invocation -> URI.create(uri + "/" + subStringCapture.getValue())); - - final UriInfo info = mock(UriInfo.class); - when(info.getRequestUriBuilder()).thenReturn(mockBuilder); - when(mockBuilder.replaceQuery(any())).thenReturn(mockBuilder); - when(info.getBaseUri()).thenReturn(uri); - - return info; - } - - /** - * Checks whether object {@code mainObject} contains in properties/items key $ref with concrete value. - */ - public static void containsReferences(final Schema mainObject, final String childObject, - final String expectedRef) { - final Map properties = mainObject.properties(); - assertNotNull(properties); - - final Property childNode = properties.get(childObject); - assertNotNull(childNode); - - //list case - String refWrapper = childNode.items() == null ? childNode.ref() : childNode.items().ref(); - assertEquals(expectedRef, refWrapper); - } -} diff --git a/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/JsonModelNameTest.java b/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/JsonModelNameTest.java deleted file mode 100644 index d04eb4d959..0000000000 --- a/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/JsonModelNameTest.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2023 PANTHEON.tech, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.restconf.openapi; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.util.Arrays; -import java.util.Optional; -import javax.ws.rs.core.UriInfo; -import org.junit.BeforeClass; -import org.junit.Test; -import org.opendaylight.mdsal.dom.api.DOMMountPoint; -import org.opendaylight.mdsal.dom.api.DOMMountPointService; -import org.opendaylight.mdsal.dom.api.DOMSchemaService; -import org.opendaylight.restconf.openapi.impl.MountPointOpenApiGeneratorRFC8040; -import org.opendaylight.restconf.openapi.model.OpenApiObject; -import org.opendaylight.restconf.openapi.model.Operation; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; - -public class JsonModelNameTest { - private static final String HTTP_URL = "http://localhost/path"; - private static final YangInstanceIdentifier INSTANCE_ID = YangInstanceIdentifier.builder() - .node(QName.create("", "nodes")) - .node(QName.create("", "node")) - .nodeWithKey(QName.create("", "node"), QName.create("", "id"), "123").build(); - - private static OpenApiObject mountPointApi; - - @BeforeClass - public static void beforeClass() throws Exception { - final var schemaService = mock(DOMSchemaService.class); - final var context = YangParserTestUtils.parseYangResourceDirectory("/yang"); - when(schemaService.getGlobalContext()).thenReturn(context); - final UriInfo mockInfo = DocGenTestHelper.createMockUriInfo(HTTP_URL); - final DOMMountPointService service = mock(DOMMountPointService.class); - final DOMMountPoint mountPoint = mock(DOMMountPoint.class); - when(mountPoint.getService(DOMSchemaService.class)).thenReturn(Optional.of(schemaService)); - when(service.getMountPoint(INSTANCE_ID)).thenReturn(Optional.of(mountPoint)); - final var openApi = new MountPointOpenApiGeneratorRFC8040(schemaService, service).getMountPointOpenApi(); - openApi.onMountPointCreated(INSTANCE_ID); - - mountPointApi = openApi.getMountPointApi(mockInfo, 1L, null); - assertNotNull("Failed to find MountPoint API", mountPointApi); - } - - @Test - public void testIfFirstNodeInJsonPayloadContainsCorrectModelName() { - for (final var stringPathEntry : mountPointApi.paths().entrySet()) { - final var put = stringPathEntry.getValue().put(); - if (put != null) { - final var moduleName = getSchemaPutOperationModuleName(put); - assertNotNull("PUT module name for [" + put + "] is in wrong format", moduleName); - final var key = stringPathEntry.getKey(); - final var expectedModuleName = extractModuleName(key); - assertTrue(moduleName.contains(expectedModuleName)); - } - } - } - - private static String getSchemaPutOperationModuleName(final Operation put) { - final var parentName = put.requestBody().content().get("application/json").schema().properties() - .keySet().iterator().next(); - - final var doubleDotsIndex = parentName.indexOf(':'); - if (doubleDotsIndex >= 0 && doubleDotsIndex < parentName.length() - 1) { - return parentName.substring(0, doubleDotsIndex + 1); - } - return null; // Return null if there is no string after the last "/" - } - - /** - * Return last module name in provided path. - *

- * For example if path looks like this: - * `/rests/data/nodes/node=123/yang-ext:mount/mandatory-test:root-container/optional-list={id}/data2:data` - * then returned string should look like this: `data2`. - *

- * @param path String URI path - * @return last module name in URI - */ - private static String extractModuleName(final String path) { - final var components = Arrays.stream(path.split("/")) - .filter(c -> c.contains(":")) - .toList(); - assertFalse("No module name found in path: " + path, components.isEmpty()); - return components.get(components.size() - 1).split(":")[0]; - } -} diff --git a/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/OpenApiTestUtils.java b/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/OpenApiTestUtils.java deleted file mode 100644 index 03b7fbb859..0000000000 --- a/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/OpenApiTestUtils.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2022 PANTHEON.tech, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.restconf.openapi; - -import java.util.List; -import java.util.Map; -import org.opendaylight.restconf.openapi.model.Parameter; -import org.opendaylight.restconf.openapi.model.Path; - -public final class OpenApiTestUtils { - - private OpenApiTestUtils() { - // Hidden on purpose - } - - /** - * Get path parameters names for {@code path} for GET operation. - * - * @return {@link List} of parameters excluding `content` parameter - */ - public static List getPathGetParameters(final Map 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 getPathPostParameters(final Map paths, final String path) { - return paths.get(path).post().parameters() - .stream() - .map(Parameter::name) - .toList(); - } -} diff --git a/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/OperationalDataTest.java b/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/OperationalDataTest.java deleted file mode 100644 index 8637083a09..0000000000 --- a/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/OperationalDataTest.java +++ /dev/null @@ -1,267 +0,0 @@ -/* - * Copyright (c) 2023 PANTHEON.tech, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.restconf.openapi; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.mdsal.dom.api.DOMMountPoint; -import org.opendaylight.mdsal.dom.api.DOMMountPointService; -import org.opendaylight.mdsal.dom.api.DOMSchemaService; -import org.opendaylight.restconf.openapi.impl.MountPointOpenApiGeneratorRFC8040; -import org.opendaylight.restconf.openapi.model.OpenApiObject; -import org.opendaylight.restconf.openapi.model.Schema; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; - -public class OperationalDataTest { - private static final String DATA_MP_URI = "/rests/data/nodes/node=123/yang-ext:mount"; - private static final String OPERATIONS_MP_URI = "/rests/operations/nodes/node=123/yang-ext:mount"; - private static final Set EXPECTED_SCHEMAS = Set.of( - "action-types_container", - "action-types_list", - "action-types_multi-container", - "action-types_container-action_input", - "action-types_container-action_output", - "action-types_list-action_output", - "action-types_list-action_input", - "action-types_multi-container_inner-container", - "operational_root", - "operational_root_config-container", - "operational_root_config-container_config-container-oper-list", - "operational_root_oper-container", - "operational_root_oper-container_config-container", - "operational_root_oper-container_oper-container-list"); - - private static final Set EXPECTED_PATHS = Set.of( - OPERATIONS_MP_URI + "/action-types:list={name}/list-action", - OPERATIONS_MP_URI + "/action-types:container/container-action", - OPERATIONS_MP_URI + "/action-types:multi-container/inner-container/action", - OPERATIONS_MP_URI, - DATA_MP_URI + "/action-types:list={name}", - DATA_MP_URI + "/operational:root", - DATA_MP_URI + "/operational:root/oper-container/config-container", - DATA_MP_URI + "/operational:root/oper-container/oper-container-list={oper-container-list-leaf}", - DATA_MP_URI + "/action-types:multi-container", - DATA_MP_URI + "/action-types:multi-container/inner-container", - DATA_MP_URI + "/operational:root/oper-container", - DATA_MP_URI + "/action-types:container", - DATA_MP_URI + "/operational:root/config-container/config-container-oper-list={oper-container-list-leaf}", - DATA_MP_URI + "/operational:root/config-container", - DATA_MP_URI); - private static final String HTTP_URL = "http://localhost/path"; - private static final YangInstanceIdentifier INSTANCE_ID = YangInstanceIdentifier.builder() - .node(QName.create("", "nodes")) - .node(QName.create("", "node")) - .nodeWithKey(QName.create("", "node"), QName.create("", "id"), "123").build(); - - private OpenApiObject mountPointApi; - private Map schemas; - - @Before - public void before() throws Exception { - final var schemaService = mock(DOMSchemaService.class); - final var context = YangParserTestUtils.parseYangResourceDirectory("/operational"); - when(schemaService.getGlobalContext()).thenReturn(context); - final var mountPoint = mock(DOMMountPoint.class); - when(mountPoint.getService(DOMSchemaService.class)).thenReturn(Optional.of(schemaService)); - - final var service = mock(DOMMountPointService.class); - when(service.getMountPoint(INSTANCE_ID)).thenReturn(Optional.of(mountPoint)); - final var openApi = new MountPointOpenApiGeneratorRFC8040(schemaService, service).getMountPointOpenApi(); - openApi.onMountPointCreated(INSTANCE_ID); - final var mockInfo = DocGenTestHelper.createMockUriInfo(HTTP_URL); - mountPointApi = openApi.getMountPointApi(mockInfo, 1L, null); - assertNotNull("Failed to find Datastore API", mountPointApi); - schemas = mountPointApi.components().schemas(); - } - - @Test - public void testOperationalPath() { - final var paths = mountPointApi.paths(); - assertEquals(EXPECTED_PATHS, paths.keySet()); - for (final var path : paths.values()) { - if (path.get() != null) { - final var responses = path.get().responses(); - final var response = responses.values().iterator().next(); - final var content = response.content(); - // In case of 200 no content - if (content != null) { - verifyOperationHaveCorrectXmlReference(content.get("application/xml").schema()); - verifyOperationHaveCorrectJsonReference(content.get("application/json").schema()); - } - } - if (path.put() != null) { - final var responses = path.put().requestBody(); - final var content = responses.content(); - verifyOperationHaveCorrectXmlReference(content.get("application/xml").schema()); - verifyOperationHaveCorrectJsonReference(content.get("application/json").schema()); - } - if (path.post() != null) { - final var responses = path.post().requestBody(); - final var content = responses.content(); - verifyOperationHaveCorrectXmlReference(content.get("application/xml").schema()); - verifyOperationHaveCorrectJsonReference(content.get("application/json").schema()); - } - if (path.patch() != null) { - final var responses = path.patch().requestBody(); - final var content = responses.content(); - verifyOperationHaveCorrectXmlReference(content.get("application/yang-data+xml").schema()); - verifyOperationHaveCorrectJsonReference(content.get("application/yang-data+json").schema()); - } - } - } - - @Test - public void testOperationalSchema() { - assertEquals(EXPECTED_SCHEMAS, schemas.keySet()); - } - - @Test - public void testOperationalConfigRootSchemaProperties() { - final var configRoot = schemas.get("operational_root"); - assertNotNull(configRoot); - final var actualProperties = configRoot.properties().keySet(); - assertEquals(Set.of("leaf-config", "config-container"), actualProperties); - } - - @Test - public void testOperationalConfigContOperListSchemaProperties() { - final var configContOperList = schemas.get( - "operational_root_config-container_config-container-oper-list"); - assertNotNull(configContOperList); - final var actualProperties = configContOperList.properties().keySet(); - assertEquals(Set.of("oper-container-list-leaf"), actualProperties); - } - - @Test - public void testOperationalContListSchemaProperties() { - final var operContList = schemas.get("operational_root_oper-container_oper-container-list"); - assertNotNull(operContList); - final var actualProperties = operContList.properties().keySet(); - assertEquals(Set.of("oper-container-list-leaf"), actualProperties); - } - - @Test - public void testOperationalConConfigContSchemaProperties() { - final var operConConfigCont = schemas.get("operational_root_oper-container_config-container"); - assertNotNull(operConConfigCont); - final var actualProperties = operConConfigCont.properties().keySet(); - assertEquals(Set.of("config-container-config-leaf", "opconfig-container-oper-leaf"), actualProperties); - } - - @Test - public void testOperationalConfigContSchemaProperties() { - final var configCont = schemas.get("operational_root_config-container"); - assertNotNull(configCont); - final var actualProperties = configCont.properties().keySet(); - assertEquals(Set.of("config-container-config-leaf", "leaf-second-case"), actualProperties); - } - - @Test - public void testOperationalContSchemaProperties() { - final var operCont = schemas.get("operational_root_oper-container"); - assertNotNull(operCont); - final var actualProperties = operCont.properties().keySet(); - assertEquals(Set.of("config-container", "oper-container-list", "leaf-first-case", "oper-leaf-first-case", - "oper-container-config-leaf-list"), actualProperties); - } - - @Test - public void testListActionSchemaProperties() { - final var configRoot = schemas.get("action-types_list"); - assertNotNull(configRoot); - final var actualProperties = configRoot.properties().keySet(); - assertEquals(Set.of("name"), actualProperties); - } - - @Test - public void testListActionInputSchemaProperties() { - final var configRoot = schemas.get("action-types_list-action_input"); - assertNotNull(configRoot); - final var actualProperties = configRoot.properties().keySet(); - assertEquals(Set.of("la-input"), actualProperties); - } - - @Test - public void testListActionOutputSchemaProperties() { - final var configRoot = schemas.get("action-types_list-action_output"); - assertNotNull(configRoot); - final var actualProperties = configRoot.properties().keySet(); - assertEquals(Set.of("la-output"), actualProperties); - } - - @Test - public void testContainerActionSchemaProperties() { - final var configRoot = schemas.get("action-types_container"); - assertNotNull(configRoot); - final var actualProperties = configRoot.properties().keySet(); - assertEquals(Set.of(), actualProperties); - } - - @Test - public void testContainerActionInputSchemaProperties() { - final var configRoot = schemas.get("action-types_container-action_input"); - assertNotNull(configRoot); - final var actualProperties = configRoot.properties().keySet(); - assertEquals(Set.of("ca-input"), actualProperties); - } - - @Test - public void testContainerActionOutputSchemaProperties() { - final var configRoot = schemas.get("action-types_container-action_output"); - assertNotNull(configRoot); - final var actualProperties = configRoot.properties().keySet(); - assertEquals(Set.of("ca-output"), actualProperties); - } - - private static void verifyOperationHaveCorrectXmlReference(final Schema schema) { - final var refValue = schema.ref(); - // In case of a POST RPC with a direct input body and no reference value - if (refValue != null) { - final var schemaElement = refValue.substring(refValue.lastIndexOf("/") + 1); - assertTrue("Reference [" + refValue + "] not found in EXPECTED Schemas", - EXPECTED_SCHEMAS.contains(schemaElement)); - } else { - final var type = schema.type(); - assertNotNull(type); - assertEquals("object", type); - } - } - - private static void verifyOperationHaveCorrectJsonReference(final Schema schema) { - final var properties = schema.properties(); - final String refValue; - if (properties != null) { - final var node = properties.values().iterator().next(); - final var type = node.type(); - if (type == null) { - refValue = node.ref(); - } else if (type.equals("array")) { - refValue = node.items().ref(); - } else { - assertEquals("object", type); - return; - } - } else { - refValue = schema.ref(); - } - final var schemaElement = refValue.substring(refValue.lastIndexOf("/") + 1); - assertTrue("Reference [" + refValue + "] not found in EXPECTED Schemas", - EXPECTED_SCHEMAS.contains(schemaElement)); - } -} diff --git a/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/SchemaObjectsTest.java b/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/SchemaObjectsTest.java deleted file mode 100644 index 74782cf670..0000000000 --- a/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/SchemaObjectsTest.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2023 PANTHEON.tech, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.restconf.openapi; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.util.List; -import java.util.Optional; -import javax.ws.rs.core.UriInfo; -import org.junit.BeforeClass; -import org.junit.Test; -import org.opendaylight.mdsal.dom.api.DOMMountPoint; -import org.opendaylight.mdsal.dom.api.DOMMountPointService; -import org.opendaylight.mdsal.dom.api.DOMSchemaService; -import org.opendaylight.restconf.openapi.impl.MountPointOpenApiGeneratorRFC8040; -import org.opendaylight.restconf.openapi.model.MediaTypeObject; -import org.opendaylight.restconf.openapi.model.OpenApiObject; -import org.opendaylight.restconf.openapi.model.Operation; -import org.opendaylight.restconf.openapi.model.Schema; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; - -public class SchemaObjectsTest { - private static final String HTTP_URL = "http://localhost/path"; - private static final YangInstanceIdentifier INSTANCE_ID = YangInstanceIdentifier.builder() - .node(QName.create("", "nodes")) - .node(QName.create("", "node")) - .nodeWithKey(QName.create("", "node"), QName.create("" , "id"), "123").build(); - - private static OpenApiObject mountPointApi; - - @BeforeClass - public static void beforeClass() throws Exception { - final var schemaService = mock(DOMSchemaService.class); - final var context = YangParserTestUtils.parseYangResourceDirectory("/yang"); - when(schemaService.getGlobalContext()).thenReturn(context); - final UriInfo mockInfo = DocGenTestHelper.createMockUriInfo(HTTP_URL); - final DOMMountPointService service = mock(DOMMountPointService.class); - final DOMMountPoint mountPoint = mock(DOMMountPoint.class); - when(mountPoint.getService(DOMSchemaService.class)).thenReturn(Optional.of(schemaService)); - when(service.getMountPoint(INSTANCE_ID)).thenReturn(Optional.of(mountPoint)); - final var openApi = new MountPointOpenApiGeneratorRFC8040(schemaService, service).getMountPointOpenApi(); - openApi.onMountPointCreated(INSTANCE_ID); - - mountPointApi = openApi.getMountPointApi(mockInfo, 1L, null); - assertNotNull("Failed to find MountPoint API", mountPointApi); - } - - @Test - public void testIfOperationsUseOneSchema() { - final var schemas = mountPointApi.components().schemas(); - for (final var pathsEntry : mountPointApi.paths().entrySet()) { - final var path = pathsEntry.getValue(); - if (path.post() == null || path.put() == null || path.patch() == null || path.delete() == null) { - // skip operational data - continue; - } - for (final var operation : List.of(path.put(), path.patch(), path.post())) { - final var schema = schemas.get(extractSchemaName(operation)); - assertNotNull("Schema for \"" + operation + "\" is missing.", schema); - } - } - } - - /** - * Extract schema name used for operation. - *

- * We assume that for all content types of operation (XML, JSON) the same schema is used. We extract its name from - * the schema reference used in operation. - *

- * @param operation for which we want to find schema - * @return name of the schema used for operation - */ - private static String extractSchemaName(final Operation operation) { - // Find distinct schema refs - final var references = operation.requestBody().content().values().stream() - .map(MediaTypeObject::schema) - .map(SchemaObjectsTest::getRef) - .distinct() - .toList(); - // Assert all schema refs are same - assertEquals("Inconsistent schemas for operation: " + operation.summary(), 1, references.size()); - return references.get(0).replaceAll("#/components/schemas/", ""); - } - - private static String getRef(final Schema schema) { - final String ref; - if (schema.ref() != null) { - ref = schema.ref(); - } else { - final var properties = schema.properties(); - if (properties != null && !properties.isEmpty()) { - final var property = schema.properties().values().iterator().next(); - if (property.type().equals("array")) { - ref = property.items().ref(); - } else { - ref = property.ref(); - } - } else { - ref = null; - } - } - return ref; - } -} diff --git a/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/impl/AbstractDocumentTest.java b/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/impl/AbstractDocumentTest.java index be25f6ff91..3e64359eb4 100644 --- a/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/impl/AbstractDocumentTest.java +++ b/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/impl/AbstractDocumentTest.java @@ -7,16 +7,20 @@ */ package org.opendaylight.restconf.openapi.impl; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import com.fasterxml.jackson.databind.ObjectMapper; +import java.net.URI; import java.util.Optional; +import javax.ws.rs.core.UriBuilder; +import javax.ws.rs.core.UriInfo; import org.glassfish.jersey.internal.util.collection.ImmutableMultivaluedMap; +import org.mockito.ArgumentCaptor; import org.opendaylight.mdsal.dom.api.DOMMountPoint; import org.opendaylight.mdsal.dom.api.DOMMountPointService; import org.opendaylight.mdsal.dom.api.DOMSchemaService; -import org.opendaylight.restconf.openapi.DocGenTestHelper; import org.opendaylight.restconf.openapi.api.OpenApiService; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; @@ -61,7 +65,7 @@ public abstract class AbstractDocumentTest { } protected static String getAllModulesDoc() throws Exception { - final var getAllController = DocGenTestHelper.createMockUriInfo(URI + "single"); + final var getAllController = createMockUriInfo(URI + "single"); final var controllerDocAll = openApiService.getAllModulesDoc(getAllController).getEntity(); return MAPPER.writeValueAsString(controllerDocAll); @@ -72,7 +76,7 @@ public abstract class AbstractDocumentTest { if (revision != null) { uri = uri + "(" + revision + ")"; } - final var getModuleController = DocGenTestHelper.createMockUriInfo(uri); + final var getModuleController = createMockUriInfo(uri); final var controllerDocModule = openApiService.getDocByModule(moduleName, revision, getModuleController); return MAPPER.writeValueAsString(controllerDocModule.getEntity()); @@ -80,7 +84,7 @@ public abstract class AbstractDocumentTest { protected static String getMountDoc() throws Exception { - final var getAllDevice = DocGenTestHelper.createMockUriInfo(URI + "mounts/1"); + final var getAllDevice = createMockUriInfo(URI + "mounts/1"); when(getAllDevice.getQueryParameters()).thenReturn(ImmutableMultivaluedMap.empty()); final var deviceDocAll = openApiService.getMountDoc("1", getAllDevice); @@ -89,9 +93,25 @@ public abstract class AbstractDocumentTest { protected static String getMountDocByModule(final String moduleName, final String revision) throws Exception { - final var getToasterDevice = DocGenTestHelper.createMockUriInfo(URI + "mounts/1/" + moduleName); - final var deviceDocToaster = openApiService.getMountDocByModule("1", moduleName, revision, getToasterDevice); + final var getDevice = createMockUriInfo(URI + "mounts/1/" + moduleName); + final var deviceDoc = openApiService.getMountDocByModule("1", moduleName, revision, getDevice); - return MAPPER.writeValueAsString(deviceDocToaster.getEntity()); + return MAPPER.writeValueAsString(deviceDoc.getEntity()); + } + + public static UriInfo createMockUriInfo(final String urlPrefix) throws Exception { + final java.net.URI uri = new URI(urlPrefix); + final UriBuilder mockBuilder = mock(UriBuilder.class); + + final ArgumentCaptor subStringCapture = ArgumentCaptor.forClass(String.class); + when(mockBuilder.path(subStringCapture.capture())).thenReturn(mockBuilder); + when(mockBuilder.build()).then(invocation -> java.net.URI.create(uri + "/" + subStringCapture.getValue())); + + final UriInfo info = mock(UriInfo.class); + when(info.getRequestUriBuilder()).thenReturn(mockBuilder); + when(mockBuilder.replaceQuery(any())).thenReturn(mockBuilder); + when(info.getBaseUri()).thenReturn(uri); + + return info; } } diff --git a/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/impl/DefinitionGeneratorTest.java b/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/impl/DefinitionGeneratorTest.java deleted file mode 100644 index 3caa2ae01f..0000000000 --- a/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/impl/DefinitionGeneratorTest.java +++ /dev/null @@ -1,310 +0,0 @@ -/* - * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.restconf.openapi.impl; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.io.IOException; -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import org.junit.BeforeClass; -import org.junit.Test; -import org.opendaylight.mdsal.dom.api.DOMSchemaService; -import org.opendaylight.yangtools.yang.common.Revision; -import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; -import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; - -public final class DefinitionGeneratorTest { - private static EffectiveModelContext context; - private static DOMSchemaService schemaService; - - @BeforeClass - public static void beforeClass() { - schemaService = mock(DOMSchemaService.class); - context = YangParserTestUtils.parseYangResourceDirectory("/yang"); - when(schemaService.getGlobalContext()).thenReturn(context); - } - - @Test - public void testConvertToSchemas() throws IOException { - final var module = context.findModule("opflex", Revision.of("2014-05-28")).orElseThrow(); - final var schemas = DefinitionGenerator.convertToSchemas(module, context, new DefinitionNames(), true); - assertNotNull(schemas); - } - - @Test - public void testActionTypes() throws IOException { - final var module = context.findModule("action-types").orElseThrow(); - final var schemas = DefinitionGenerator.convertToSchemas(module, context, new DefinitionNames(), true); - assertNotNull(schemas); - } - - @Test - public void testStringTypes() throws IOException { - final var module = context.findModule("string-types").orElseThrow(); - final var schemas = DefinitionGenerator.convertToSchemas(module, context, new DefinitionNames(), true); - assertNotNull(schemas); - } - - @Test - public void testEnumType() throws IOException { - final var module = context.findModule("definition-test").orElseThrow(); - final var schemas = DefinitionGenerator.convertToSchemas(module, context, new DefinitionNames(), true); - assertNotNull(schemas); - - final var properties = schemas.get("definition-test_enum-container").properties(); - assertEquals("up", properties.get("status").defaultValue()); - } - - @Test - public void testUnionTypes() throws IOException { - final var module = context.findModule("definition-test").orElseThrow(); - final var schemas = DefinitionGenerator.convertToSchemas(module, context, new DefinitionNames(), true); - assertNotNull(schemas); - - final var properties = schemas.get("definition-test_union-container").properties(); - assertEquals("5", properties.get("testUnion1").defaultValue()); - assertEquals("integer", properties.get("testUnion1").type()); - assertEquals(-2147483648, properties.get("testUnion1").example()); - assertEquals("false", properties.get("testUnion2").defaultValue()); - assertEquals("string", properties.get("testUnion2").type()); - assertEquals("Some testUnion2", properties.get("testUnion2").example()); - assertEquals("integer", properties.get("testUnion3").type()); - assertEquals(-2147483648, properties.get("testUnion3").example()); - assertEquals("false", properties.get("testUnion3").defaultValue()); - } - - @Test - public void testBinaryType() throws IOException { - final var module = context.findModule("definition-test").orElseThrow(); - final var schemas = DefinitionGenerator.convertToSchemas(module, context, new DefinitionNames(), true); - assertNotNull(schemas); - - final var properties = schemas.get("definition-test_binary-container").properties(); - assertEquals("SGVsbG8gdGVzdCE=", properties.get("binary-data").defaultValue()); - } - - @Test - public void testBooleanType() throws IOException { - final var module = context.findModule("definition-test").orElseThrow(); - final var schemas = DefinitionGenerator.convertToSchemas(module, context, new DefinitionNames(), true); - assertNotNull(schemas); - - final var properties = schemas.get("definition-test_union-container").properties(); - assertEquals(true, properties.get("testBoolean").defaultValue()); - assertEquals(true, properties.get("testBoolean").example()); - } - - @Test - public void testNumberType() throws IOException { - final var module = context.findModule("definition-test").orElseThrow(); - final var schemas = DefinitionGenerator.convertToSchemas(module, context, new DefinitionNames(), true); - assertNotNull(schemas); - - final var properties = schemas.get("definition-test_number-container").properties(); - assertEquals(42L, properties.get("testInteger").defaultValue()); - assertEquals(42L, properties.get("testInt64").defaultValue()); - assertEquals(BigDecimal.valueOf(42), properties.get("testUint64").defaultValue()); - assertEquals(100L, properties.get("testUnsignedInteger").defaultValue()); - assertEquals(BigDecimal.valueOf(3.14), properties.get("testDecimal").defaultValue()); - assertEquals(BigDecimal.valueOf(3.14159265359), properties.get("testDouble").defaultValue()); - } - - @Test - public void testInstanceIdentifierType() throws IOException { - final var module = context.findModule("definition-test").orElseThrow(); - final var schemas = DefinitionGenerator.convertToSchemas(module, context, new DefinitionNames(), true); - assertNotNull(schemas); - - final var properties = schemas.get("definition-test_network-container").properties(); - final var networkRef = properties.get("network-ref"); - - assertNotNull(networkRef); - assertEquals("string", networkRef.type()); - - assertEquals("/network/nodes[node-id='node1']", networkRef.defaultValue()); - assertEquals("/sample:binary-container", networkRef.example()); - } - - @Test - public void testStringFromRegex() throws IOException { - final var module = context.findModule("strings-from-regex").orElseThrow(); - final var jsonObject = DefinitionGenerator.convertToSchemas(module, context, new DefinitionNames(), true); - assertNotNull(jsonObject); - - final var properties = jsonObject.get("strings-from-regex_test").properties(); - assertEquals("00:00:00:00:00:00", properties.get("mac-address").example().toString()); - assertEquals("0000-00-00T00:00:00Z", properties.get("login-date-time").example().toString()); - assertEquals("0.0.0.0", properties.get("ipv4-address").example().toString()); - } - - /** - * Test that checks if namespace for rpc is present. - */ - @Test - public void testRpcNamespace() throws Exception { - final var module = context.findModule("toaster", Revision.of("2009-11-20")).orElseThrow(); - final var jsonObject = DefinitionGenerator.convertToSchemas(module, context, new DefinitionNames(), true); - assertNotNull(jsonObject); - final var schema = jsonObject.get("toaster_make-toast_input"); - assertNotNull(schema); - final var xml = schema.xml(); - assertNotNull(xml); - final var namespace = xml.namespace(); - assertNotNull(namespace); - assertEquals("http://netconfcentral.org/ns/toaster", namespace); - } - - /** - * Test that checks if namespace for actions is present. - */ - @Test - public void testActionsNamespace() throws IOException { - final var module = context.findModule("action-types").orElseThrow(); - final var jsonObject = DefinitionGenerator.convertToSchemas(module, context, new DefinitionNames(), true); - assertNotNull(jsonObject); - final var schema = jsonObject.get("action-types_container-action_input"); - assertNotNull(schema); - final var xml = schema.xml(); - assertNotNull(xml); - final var namespace = xml.namespace(); - assertNotNull(namespace); - assertEquals("urn:ietf:params:xml:ns:yang:test:action:types", namespace); - } - - /** - * This test is designed to verify if yang Identity is used correctly as string value - * and no extra schemas are generated. - */ - @Test - public void testIdentity() throws IOException { - final var module = context.findModule("toaster", Revision.of("2009-11-20")).orElseThrow(); - final var schemas = DefinitionGenerator.convertToSchemas(module, context, new DefinitionNames(), true); - assertNotNull(schemas); - - // correct number of schemas generated - assertEquals(2, schemas.size()); - final var makeToast = schemas.get("toaster_make-toast_input").properties().get("toasterToastType"); - - assertEquals("wheat-bread", makeToast.defaultValue().toString()); - assertEquals("toast-type", makeToast.example().toString()); - assertEquals("string", makeToast.type()); - assertEquals(""" - This variable informs the toaster of the type of - material that is being toasted. The toaster - uses this information, combined with - toasterDoneness, to compute for how - long the material must be toasted to achieve - the required doneness.""", makeToast.description()); - assertTrue(makeToast.enums().containsAll(Set.of("toast-type","white-bread", "wheat-bread", "frozen-waffle", - "hash-brown", "frozen-bagel", "wonder-bread"))); - } - - /** - * Test that checks if list min-elements and max-elements are present. - * Also checks if number of example elements meets the min-elements condition - */ - @Test - public void testListExamples() throws IOException { - final var module = context.findModule("test-container-childs", Revision.of("2023-09-28")).orElseThrow(); - final var jsonObject = DefinitionGenerator.convertToSchemas(module, context, new DefinitionNames(), true); - final var component = jsonObject.get("test-container-childs_root-container_nested-container"); - assertNotNull(component); - assertNotNull(component.properties()); - final var property = component.properties().get("mandatory-list"); - assertNotNull(property); - assertNotNull(property.minItems()); - assertNotNull(property.maxItems()); - assertEquals(3, (int) property.minItems()); - assertEquals(5, (int) property.maxItems()); - final var example = property.example(); - assertNotNull(example); - assertEquals(ArrayList.class, example.getClass()); - assertEquals(3, ((List)example).size()); - } - - /** - * Test that checks if list min-elements and max-elements are present. - * Also checks if number of example elements meets the min-elements condition - * and if key defined leaf have unique values. - */ - @Test - public void testListExamplesWithNonKeyLeaf() throws IOException { - final var module = context.findModule("test-container-childs", Revision.of("2023-09-28")).orElseThrow(); - final var jsonObject = DefinitionGenerator.convertToSchemas(module, context, new DefinitionNames(), true); - final var component = jsonObject.get("test-container-childs_root-container_nested-container"); - assertNotNull(component); - assertNotNull(component.properties()); - final var property = component.properties().get("mandatory-list"); - assertNotNull(property); - assertNotNull(property.minItems()); - assertNotNull(property.maxItems()); - assertEquals(3, (int) property.minItems()); - assertEquals(5, (int) property.maxItems()); - final var example = property.example(); - assertNotNull(example); - assertEquals(3, ((List)example).size()); - assertTrue(checkUniqueExample(example, "id")); - } - - /** - * Test that checks if multiple key leafs have unique values. - * Also checks if nested container node is ignored. - */ - @Test - public void testListExamplesWithTwoKeys() throws IOException { - final var module = context.findModule("test-container-childs", Revision.of("2023-09-28")).orElseThrow(); - final var jsonObject = DefinitionGenerator.convertToSchemas(module, context, new DefinitionNames(), true); - final var component = jsonObject.get("test-container-childs_root-container-two-keys_nested-container-two-keys"); - assertNotNull(component); - assertNotNull(component.properties()); - final var property = component.properties().get("mandatory-list-two-keys"); - assertNotNull(property); - final var example = property.example(); - assertNotNull(example); - assertTrue(checkUniqueExample(example, "id")); - assertTrue(checkUniqueExample(example, "name")); - assertEquals(3, ((ArrayList>)example).get(0).size()); - } - - /** - * Test that checks if sets of unique defined leafs have unique combination of values. - */ - @Test - public void testListExamplesWithUnique() throws IOException { - final var module = context.findModule("test-container-childs", Revision.of("2023-09-28")).orElseThrow(); - final var jsonObject = DefinitionGenerator.convertToSchemas(module, context, new DefinitionNames(), true); - final var component = jsonObject.get("test-container-childs_root-container-unique_nested-container-unique"); - assertNotNull(component); - assertNotNull(component.properties()); - final var property = component.properties().get("mandatory-list-unique"); - assertNotNull(property); - final var example = property.example(); - assertNotNull(example); - assertTrue(checkUniqueExample(example, "id")); - assertTrue(checkUniqueExample(example, "name") || checkUniqueExample(example, "address")); - } - - private static boolean checkUniqueExample(final Object examples, final String key) { - assertEquals(ArrayList.class, examples.getClass()); - final var exampleValues = new HashSet<>(); - - for (final Map example : (ArrayList>)examples) { - exampleValues.add(example.get(key)); - } - return (exampleValues.size() == ((ArrayList) examples).size()); - } -} diff --git a/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/impl/KeysMappingTest.java b/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/impl/KeysMappingTest.java deleted file mode 100644 index 90c5c142ae..0000000000 --- a/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/impl/KeysMappingTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2023 PANTHEON.tech, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.restconf.openapi.impl; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -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.getPathGetParameters; - -import java.util.List; -import org.junit.BeforeClass; -import org.junit.Test; -import org.opendaylight.mdsal.dom.api.DOMSchemaService; -import org.opendaylight.restconf.openapi.DocGenTestHelper; -import org.opendaylight.restconf.openapi.model.OpenApiObject; -import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; - -public class KeysMappingTest { - private static OpenApiObject doc; - - @BeforeClass - public static void startUp() throws Exception { - final var context = YangParserTestUtils.parseYang(""" - module keys-mapping { - namespace "mapping"; - prefix keys-mapping; - list multiple-key-list { - key "name name2"; - leaf name { - type string; - } - leaf name2 { - type string; - } - list multiple-key-list2 { - key "name name3"; - leaf name { - type string; - } - leaf name3 { - type string; - } - list multiple-key-list3 { - key "name3 name"; - leaf name3 { - type string; - } - leaf name { - type string; - } - list multiple-key-list4 { - key name; - leaf name { - type string; - } - } - } - } - } - }"""); - final var schemaService = mock(DOMSchemaService.class); - when(schemaService.getGlobalContext()).thenReturn(context); - final var generator = new OpenApiGeneratorRFC8040(schemaService); - final var uriInfo = DocGenTestHelper.createMockUriInfo("http://localhost/path"); - doc = generator.getApiDeclaration("keys-mapping", null, uriInfo); - assertNotNull(doc); - } - - /** - * This test is designed to verify if the request parameters for nested lists with multiple keys are being - * enumerated properly. - * - *

- * This would mean that we will have name, name1, etc., when the same parameter appears multiple times in the path. - */ - @Test - public void testKeysMapping() { - final var pathToMultipleKeyList4 = "/rests/data/keys-mapping:multiple-key-list={name},{name2}" - + "/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"), - getPathGetParameters(doc.paths(), pathToMultipleKeyList4)); - } -} diff --git a/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/impl/ListPostRequestsTest.java b/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/impl/ListPostRequestsTest.java deleted file mode 100644 index 75dfe90106..0000000000 --- a/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/impl/ListPostRequestsTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2023 PANTHEON.tech, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.restconf.openapi.impl; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.opendaylight.mdsal.dom.api.DOMSchemaService; -import org.opendaylight.restconf.openapi.DocGenTestHelper; -import org.opendaylight.restconf.openapi.model.OpenApiObject; -import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; - -public class ListPostRequestsTest { - private static OpenApiObject doc; - - @BeforeClass - public static void startUp() throws Exception { - final var context = YangParserTestUtils.parseYang(""" - module list-post { - namespace "list-post"; - prefix lp; - container container { - list list { - key "name address"; - leaf name { - type string; - } - leaf address { - type string; - } - } - } - }"""); - final var schemaService = mock(DOMSchemaService.class); - when(schemaService.getGlobalContext()).thenReturn(context); - final var generator = new OpenApiGeneratorRFC8040(schemaService); - final var uriInfo = DocGenTestHelper.createMockUriInfo("http://localhost/path"); - doc = generator.getApiDeclaration("list-post", null, uriInfo); - assertNotNull(doc); - } - - /** - * Test to verify that we do NOT generate OpenApi example POST request for path ending with list element. - * - *

- * Assert that for paths ending with container we have examples for all types of requests. - * Assert that for paths ending with list we do NOT have POST example. - */ - @Test - public void testListPostRequest() { - // for container, we have both post (with child as payload) and put (with itself as payload) - final var pathToContainer = "/rests/data/list-post:container"; - assertNotNull(doc.paths().get(pathToContainer).get()); - assertNotNull(doc.paths().get(pathToContainer).post()); - assertNotNull(doc.paths().get(pathToContainer).put()); - assertNotNull(doc.paths().get(pathToContainer).patch()); - assertNotNull(doc.paths().get(pathToContainer).delete()); - - // for list, we cannot make a post request - final var pathToList = "/rests/data/list-post:container/list={name},{address}"; - assertNotNull(doc.paths().get(pathToList).get()); - assertNull(doc.paths().get(pathToList).post()); - assertNotNull(doc.paths().get(pathToList).put()); - assertNotNull(doc.paths().get(pathToList).patch()); - assertNotNull(doc.paths().get(pathToList).delete()); - } -} diff --git a/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/impl/OpenApiGeneratorRFC8040Test.java b/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/impl/OpenApiGeneratorRFC8040Test.java deleted file mode 100644 index 711dc48c00..0000000000 --- a/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/impl/OpenApiGeneratorRFC8040Test.java +++ /dev/null @@ -1,658 +0,0 @@ -/* - * Copyright (c) 2021 PANTHEON.tech, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.restconf.openapi.impl; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -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.getPathGetParameters; -import static org.opendaylight.restconf.openapi.OpenApiTestUtils.getPathPostParameters; -import static org.opendaylight.restconf.openapi.impl.BaseYangOpenApiGenerator.BASIC_AUTH_NAME; -import static org.opendaylight.restconf.openapi.model.builder.OperationBuilder.COMPONENTS_PREFIX; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import javax.ws.rs.core.UriInfo; -import org.junit.BeforeClass; -import org.junit.Test; -import org.opendaylight.mdsal.dom.api.DOMSchemaService; -import org.opendaylight.restconf.openapi.DocGenTestHelper; -import org.opendaylight.restconf.openapi.model.MediaTypeObject; -import org.opendaylight.restconf.openapi.model.OpenApiObject; -import org.opendaylight.restconf.openapi.model.Operation; -import org.opendaylight.restconf.openapi.model.Path; -import org.opendaylight.restconf.openapi.model.Property; -import org.opendaylight.restconf.openapi.model.Schema; -import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; -import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; - -public final class OpenApiGeneratorRFC8040Test { - private static final String TOASTER_2 = "toaster2"; - private static final String REVISION_DATE = "2009-11-20"; - private static final String MANDATORY_TEST = "mandatory-test"; - private static final String CONFIG_ROOT_CONTAINER = "mandatory-test_root-container"; - private static final String CONFIG_MANDATORY_CONTAINER = "mandatory-test_root-container_mandatory-container"; - private static final String CONFIG_MANDATORY_LIST = "mandatory-test_root-container_mandatory-list"; - private static final String CONTAINER = "container"; - private static final String LIST = "list"; - - private static DOMSchemaService schemaService; - private static UriInfo uriInfo; - - private final OpenApiGeneratorRFC8040 generator = new OpenApiGeneratorRFC8040(schemaService); - - @BeforeClass - public static void beforeClass() throws Exception { - schemaService = mock(DOMSchemaService.class); - final EffectiveModelContext context = YangParserTestUtils.parseYangResourceDirectory("/yang"); - when(schemaService.getGlobalContext()).thenReturn(context); - uriInfo = DocGenTestHelper.createMockUriInfo("http://localhost/path"); - } - - /** - * Test that paths are generated according to the model. - */ - @Test - public void testPaths() { - final OpenApiObject doc = generator.getApiDeclaration(TOASTER_2, REVISION_DATE, uriInfo); - - assertEquals(Set.of("/rests/data", - "/rests/data/toaster2:toaster", - "/rests/data/toaster2:toaster/toasterSlot={slotId}", - "/rests/data/toaster2:toaster/toasterSlot={slotId}/toaster-augmented:slotInfo", - "/rests/data/toaster2:lst={lf1}", - "/rests/data/toaster2:lst={lf1}/cont1", - "/rests/data/toaster2:lst={lf1}/cont1/cont11", - "/rests/data/toaster2:lst={lf1}/cont1/lst11={lf111}", - "/rests/data/toaster2:lst={lf1}/lst1={key1},{key2}", - "/rests/operations/toaster2:make-toast", - "/rests/operations/toaster2:cancel-toast", - "/rests/operations/toaster2:restock-toaster"), - doc.paths().keySet()); - } - - /** - * Test that generated configuration paths allow to use operations: get, put, patch, delete and post. - */ - @Test - public void testConfigPaths() { - final List configPaths = List.of("/rests/data/toaster2:lst={lf1}", - "/rests/data/toaster2:lst={lf1}/cont1", - "/rests/data/toaster2:lst={lf1}/cont1/cont11", - "/rests/data/toaster2:lst={lf1}/cont1/lst11={lf111}", - "/rests/data/toaster2:lst={lf1}/lst1={key1},{key2}"); - final String configPathForPostCont = "/rests/data/toaster2:lst={lf1}/cont1"; - final String configPathForPostLeaf = "/rests/data/toaster2:lst={lf1}/cont1/cont11"; - - final OpenApiObject doc = generator.getApiDeclaration(TOASTER_2, REVISION_DATE, uriInfo); - - for (final String path : configPaths) { - final Path node = doc.paths().get(path); - assertNotNull(node.get()); - assertNotNull(node.put()); - assertNotNull(node.delete()); - assertNotNull(node.patch()); - } - - final Path node = doc.paths().get(configPathForPostCont); - assertNotNull(node.post()); - - // Assert we do not generate post for container which contains only leafs. - final Path nodeLeaf = doc.paths().get(configPathForPostLeaf); - assertNull(nodeLeaf.post()); - } - - /** - * Test that generated document contains the following schemas. - */ - @Test - public void testSchemas() { - final OpenApiObject doc = generator.getApiDeclaration(TOASTER_2, REVISION_DATE, uriInfo); - - final Map schemas = doc.components().schemas(); - assertNotNull(schemas); - - final Schema configLst = schemas.get("toaster2_lst"); - assertNotNull(configLst); - DocGenTestHelper.containsReferences(configLst, "lst1", "#/components/schemas/toaster2_lst_lst1"); - DocGenTestHelper.containsReferences(configLst, "cont1", "#/components/schemas/toaster2_lst_cont1"); - - final Schema configLst1 = schemas.get("toaster2_lst_lst1"); - assertNotNull(configLst1); - - final Schema configCont1 = schemas.get("toaster2_lst_cont1"); - assertNotNull(configCont1); - DocGenTestHelper.containsReferences(configCont1, "cont11", "#/components/schemas/toaster2_lst_cont1_cont11"); - DocGenTestHelper.containsReferences(configCont1, "lst11", "#/components/schemas/toaster2_lst_cont1_lst11"); - - final Schema configCont11 = schemas.get("toaster2_lst_cont1_cont11"); - assertNotNull(configCont11); - - final Schema configLst11 = schemas.get("toaster2_lst_cont1_lst11"); - assertNotNull(configLst11); - } - - /** - * Test that reference to schema in each path is valid (all referenced schemas exist). - */ - @Test - public void testSchemasExistenceSingleModule() { - final var document = generator.getApiDeclaration(TOASTER_2, REVISION_DATE, uriInfo); - assertNotNull(document); - final var referencedSchemas = new HashSet(); - for (final var path : document.paths().values()) { - referencedSchemas.addAll(extractSchemaRefFromPath(path)); - } - final var schemaNames = document.components().schemas().keySet(); - for (final var ref : referencedSchemas) { - assertTrue("Referenced schema " + ref + " does not exist", schemaNames.contains(ref)); - } - } - - /** - * Test that generated document contains RPC schemas for "make-toast" with correct input. - */ - @Test - public void testRPC() { - final OpenApiObject doc = generator.getApiDeclaration("toaster", "2009-11-20", uriInfo); - assertNotNull(doc); - - final Map schemas = doc.components().schemas(); - final Schema input = schemas.get("toaster_make-toast_input"); - final Map properties = input.properties(); - assertTrue(properties.containsKey("toasterDoneness")); - assertTrue(properties.containsKey("toasterToastType")); - } - - @Test - public void testChoice() { - final var doc = generator.getApiDeclaration("choice-test", null, uriInfo); - assertNotNull(doc); - - final var schemas = doc.components().schemas(); - final var firstContainer = schemas.get("choice-test_first-container"); - assertEquals("default-value", firstContainer.properties().get("leaf-default").defaultValue().toString()); - assertFalse(firstContainer.properties().containsKey("leaf-non-default")); - - final var secondContainer = schemas.get("choice-test_second-container"); - assertTrue(secondContainer.properties().containsKey("leaf-first-case")); - assertFalse(secondContainer.properties().containsKey("leaf-second-case")); - } - - @Test - public void testMandatory() { - final var doc = generator.getApiDeclaration(MANDATORY_TEST, null, uriInfo); - assertNotNull(doc); - final var schemas = doc.components().schemas(); - final var containersWithRequired = new ArrayList(); - - final var reqRootContainerElements = List.of("mandatory-root-leaf", "mandatory-container", - "mandatory-first-choice", "mandatory-list"); - verifyRequiredField(schemas.get(CONFIG_ROOT_CONTAINER), reqRootContainerElements); - containersWithRequired.add(CONFIG_ROOT_CONTAINER); - - final var reqMandatoryContainerElements = List.of("mandatory-leaf", "leaf-list-with-min-elements"); - verifyRequiredField(schemas.get(CONFIG_MANDATORY_CONTAINER), reqMandatoryContainerElements); - containersWithRequired.add(CONFIG_MANDATORY_CONTAINER); - - final var reqMandatoryListElements = List.of("mandatory-list-field"); - verifyRequiredField(schemas.get(CONFIG_MANDATORY_LIST), reqMandatoryListElements); - containersWithRequired.add(CONFIG_MANDATORY_LIST); - - verifyThatOthersNodeDoesNotHaveRequiredField(containersWithRequired, schemas); - } - - /** - * Test that checks for correct amount of parameters in requests. - */ - @Test - public void testRecursiveParameters() { - final var configPaths = Map.of("/rests/data/recursive:container-root", 0, - "/rests/data/recursive:container-root/root-list={name}", 1, - "/rests/data/recursive:container-root/root-list={name}/nested-list={name1}", 2, - "/rests/data/recursive:container-root/root-list={name}/nested-list={name1}/super-nested-list={name2}", 3); - - final var doc = generator.getApiDeclaration("recursive", "2023-05-22", uriInfo); - assertNotNull(doc); - - final var paths = doc.paths(); - assertEquals(5, paths.size()); - - for (final var expectedPath : configPaths.entrySet()) { - assertTrue(paths.containsKey(expectedPath.getKey())); - final int expectedSize = expectedPath.getValue(); - - final var path = paths.get(expectedPath.getKey()); - - final var get = path.get(); - assertNotNull(get); - assertEquals(expectedSize + 1, get.parameters().size()); - - final var put = path.put(); - assertNotNull(put); - assertEquals(expectedSize, put.parameters().size()); - - final var delete = path.delete(); - assertNotNull(delete); - assertEquals(expectedSize, delete.parameters().size()); - - final var patch = path.patch(); - assertNotNull(patch); - assertEquals(expectedSize, patch.parameters().size()); - } - - // we do not generate POST for lists - final var path = paths.get("/rests/data/recursive:container-root"); - final var post = path.post(); - final int expectedSize = configPaths.get("/rests/data/recursive:container-root"); - assertEquals(expectedSize, post.parameters().size()); - } - - /** - * Test that request parameters are correctly numbered. - * - *

- * It means we should have name and name1, etc. when we have the same parameter in path multiple times. - */ - @Test - public void testParametersNumbering() { - final var doc = generator.getApiDeclaration("path-params-test", null, uriInfo); - - var pathToList1 = "/rests/data/path-params-test:cont/list1={name}"; - assertTrue(doc.paths().containsKey(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"), getPathGetParameters(doc.paths(), pathToList2)); - - var pathToList3 = "/rests/data/path-params-test:cont/list3={name}"; - assertTrue(doc.paths().containsKey(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"), getPathGetParameters(doc.paths(), pathToList4)); - - var pathToList5 = "/rests/data/path-params-test:cont/list1={name}/cont2"; - assertTrue(doc.paths().containsKey(pathToList4)); - assertEquals(List.of("name"), getPathGetParameters(doc.paths(), pathToList5)); - } - - /** - * Test that request parameters are correctly typed. - */ - @Test - public void testParametersTypes() { - final var doc = generator.getApiDeclaration("typed-params", "2023-10-24", uriInfo); - final var pathToContainer = "/rests/data/typed-params:typed/"; - final var integerTypes = List.of("uint64", "uint32", "uint16", "uint8", "int64", "int32", "int16", "int8"); - for (final var type: integerTypes) { - final var typeKey = type + "-key"; - final var path = pathToContainer + type + "={" + typeKey + "}"; - assertTrue(doc.paths().containsKey(path)); - assertEquals("integer", doc.paths().get(path).get().parameters().get(0).schema().type()); - } - } - - /** - * Test that request for actions is correct and has parameters. - */ - @Test - public void testActionPathsParams() { - final var doc = generator.getApiDeclaration("action-types", null, uriInfo); - - final var pathWithParameters = "/rests/operations/action-types:list={name}/list-action"; - assertTrue(doc.paths().containsKey(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(), getPathPostParameters(doc.paths(), pathWithoutParameters)); - } - - @Test - public void testSimpleOpenApiObjects() { - final var doc = generator.getApiDeclaration("my-yang", "2022-10-06", uriInfo); - - assertEquals(Set.of("/rests/data", "/rests/data/my-yang:data"), doc.paths().keySet()); - final var JsonNodeMyYangData = doc.paths().get("/rests/data/my-yang:data"); - verifyRequestRef(JsonNodeMyYangData.put(), "#/components/schemas/my-yang_data", CONTAINER); - verifyRequestRef(JsonNodeMyYangData.get(), "#/components/schemas/my-yang_data", CONTAINER); - - // Test `components/schemas` objects - final var definitions = doc.components().schemas(); - assertEquals(1, definitions.size()); - assertTrue(definitions.containsKey("my-yang_data")); - } - - @Test - public void testToaster2OpenApiObjects() { - final var doc = generator.getApiDeclaration(TOASTER_2, REVISION_DATE, uriInfo); - - final var jsonNodeToaster = doc.paths().get("/rests/data/toaster2:toaster"); - verifyRequestRef(jsonNodeToaster.post(), "#/components/schemas/toaster2_toaster_toasterSlot", LIST); - verifyRequestRef(jsonNodeToaster.put(), "#/components/schemas/toaster2_toaster", CONTAINER); - verifyRequestRef(jsonNodeToaster.get(), "#/components/schemas/toaster2_toaster", CONTAINER); - - final var jsonNodeToasterSlot = doc.paths().get("/rests/data/toaster2:toaster/toasterSlot={slotId}"); - verifyRequestRef(jsonNodeToasterSlot.put(), "#/components/schemas/toaster2_toaster_toasterSlot", LIST); - verifyRequestRef(jsonNodeToasterSlot.get(), "#/components/schemas/toaster2_toaster_toasterSlot", LIST); - - final var jsonNodeSlotInfo = doc.paths().get( - "/rests/data/toaster2:toaster/toasterSlot={slotId}/toaster-augmented:slotInfo"); - verifyRequestRef(jsonNodeSlotInfo.put(), "#/components/schemas/toaster2_toaster_toasterSlot_slotInfo", - CONTAINER); - verifyRequestRef(jsonNodeSlotInfo.get(), "#/components/schemas/toaster2_toaster_toasterSlot_slotInfo", - CONTAINER); - - final var jsonNodeLst = doc.paths().get("/rests/data/toaster2:lst={lf1}"); - verifyRequestRef(jsonNodeLst.put(), "#/components/schemas/toaster2_lst", LIST); - verifyRequestRef(jsonNodeLst.get(), "#/components/schemas/toaster2_lst", LIST); - - final var jsonNodeLst1 = doc.paths().get("/rests/data/toaster2:lst={lf1}/lst1={key1},{key2}"); - verifyRequestRef(jsonNodeLst1.put(), "#/components/schemas/toaster2_lst_lst1", LIST); - verifyRequestRef(jsonNodeLst1.get(), "#/components/schemas/toaster2_lst_lst1", LIST); - - final var jsonNodeMakeToast = doc.paths().get("/rests/operations/toaster2:make-toast"); - assertNull(jsonNodeMakeToast.get()); - verifyRequestRef(jsonNodeMakeToast.post(), "#/components/schemas/toaster2_make-toast_input", CONTAINER); - - final var jsonNodeCancelToast = doc.paths().get("/rests/operations/toaster2:cancel-toast"); - assertNull(jsonNodeCancelToast.get()); - // Test RPC with empty input - final var postContent = jsonNodeCancelToast.post().requestBody().content(); - final var jsonSchema = postContent.get("application/json").schema(); - assertNull(jsonSchema.ref()); - final var xmlSchema = postContent.get("application/xml").schema(); - assertNull(xmlSchema.ref()); - - // Test `components/schemas` objects - final var definitions = doc.components().schemas(); - assertEquals(10, definitions.size()); - } - - /** - * Test that checks if securitySchemes and security elements are present. - */ - @Test - public void testAuthenticationFeature() { - final var doc = generator.getApiDeclaration(TOASTER_2, REVISION_DATE, uriInfo); - - assertEquals("[{basicAuth=[]}]", doc.security().toString()); - assertEquals("Http[type=http, scheme=basic, description=null, bearerFormat=null]", - doc.components().securitySchemes().get(BASIC_AUTH_NAME).toString()); - - // take list of all defined security scheme objects => all names of registered SecuritySchemeObjects - final var securitySchemesObjectNames = doc.components().securitySchemes().keySet(); - assertTrue("No Security Schemes Object is defined", securitySchemesObjectNames.size() > 0); - - // collect all referenced security scheme objects - final var referencedSecurityObjects = new HashSet(); - doc.security().forEach(map -> referencedSecurityObjects.addAll(map.keySet())); - - // verify, that each reference references name of registered Security Scheme Object - for (final var secObjRef : referencedSecurityObjects) { - assertTrue(securitySchemesObjectNames.contains(secObjRef)); - } - } - - /** - * Test that checks if namespace for rpc is present. - */ - @Test - public void testRpcNamespace() { - final var doc = generator.getApiDeclaration("toaster", "2009-11-20", uriInfo); - assertNotNull("Failed to find Datastore API", doc); - final var paths = doc.paths(); - final var path = paths.get("/rests/operations/toaster:cancel-toast"); - assertNotNull(path); - final var content = path.post().requestBody().content().get("application/xml"); - assertNotNull(content); - final var schema = content.schema(); - assertNotNull(schema); - final var xml = schema.xml(); - assertNotNull(xml); - final var namespace = xml.namespace(); - assertNotNull(namespace); - assertEquals("http://netconfcentral.org/ns/toaster", namespace); - } - - /** - * Test that checks if namespace for actions is present. - */ - @Test - public void testActionsNamespace() { - final var doc = generator.getApiDeclaration("action-types", null, uriInfo); - assertNotNull("Failed to find Datastore API", doc); - final var paths = doc.paths(); - final var path = paths.get("/rests/operations/action-types:multi-container/inner-container/action"); - assertNotNull(path); - final var content = path.post().requestBody().content().get("application/xml"); - assertNotNull(content); - final var schema = content.schema(); - assertNotNull(schema); - final var xml = schema.xml(); - assertNotNull(xml); - final var namespace = xml.namespace(); - assertNotNull(namespace); - assertEquals("urn:ietf:params:xml:ns:yang:test:action:types", namespace); - } - - /** - * Test that checks if list min-elements and max-elements are present. - * Also checks if number of example elements meets the min-elements condition - * and if key defined leaf have unique values. - */ - @Test - public void testListExamplesWithNonKeyLeaf() { - final var doc = generator.getApiDeclaration("test-container-childs", "2023-09-28", uriInfo); - assertNotNull("Failed to find Datastore API", doc); - final var components = doc.components(); - final var component = components.schemas().get("test-container-childs_root-container_nested-container"); - assertNotNull(component); - assertNotNull(component.properties()); - final var property = component.properties().get("mandatory-list"); - assertNotNull(property); - assertNotNull(property.minItems()); - assertNotNull(property.maxItems()); - assertEquals(3, (int) property.minItems()); - assertEquals(5, (int) property.maxItems()); - final var example = property.example(); - assertNotNull(example); - assertEquals(3, ((List)example).size()); - assertTrue(checkUniqueExample(example, "id")); - } - - /** - * Test that checks if multiple key leafs have unique values. - * Also checks if nested container node is ignored. - */ - @Test - public void testListExamplesWithTwoKeys() { - final var doc = generator.getApiDeclaration("test-container-childs", "2023-09-28", uriInfo); - assertNotNull("Failed to find Datastore API", doc); - final var components = doc.components(); - final var component = components.schemas() - .get("test-container-childs_root-container-two-keys_nested-container-two-keys"); - assertNotNull(component); - assertNotNull(component.properties()); - final var property = component.properties().get("mandatory-list-two-keys"); - assertNotNull(property); - final var example = property.example(); - assertNotNull(example); - assertTrue(checkUniqueExample(example, "id")); - assertTrue(checkUniqueExample(example, "name")); - assertEquals(3, ((ArrayList>)example).get(0).size()); - } - - /** - * Test that checks if sets of unique defined leafs have unique combination of values. - */ - @Test - public void testListExamplesWithUnique() { - final var doc = generator.getApiDeclaration("test-container-childs", "2023-09-28", uriInfo); - assertNotNull("Failed to find Datastore API", doc); - final var components = doc.components(); - final var component = components.schemas() - .get("test-container-childs_root-container-unique_nested-container-unique"); - assertNotNull(component); - assertNotNull(component.properties()); - final var property = component.properties().get("mandatory-list-unique"); - assertNotNull(property); - final var example = property.example(); - assertNotNull(example); - assertTrue(checkUniqueExample(example, "id")); - assertTrue(checkUniqueExample(example, "name") || checkUniqueExample(example, "address")); - } - - private static boolean checkUniqueExample(final Object examples, final String key) { - assertEquals(ArrayList.class, examples.getClass()); - final var exampleValues = new HashSet<>(); - - for (final Map example : (ArrayList>)examples) { - exampleValues.add(example.get(key)); - } - return (exampleValues.size() == ((ArrayList) examples).size()); - } - - /** - * Test that number of elements in payload is correct. - */ - @SuppressWarnings("unchecked") - @Test - public void testLeafListWithMinElementsPayload() { - final var doc = generator.getApiDeclaration(MANDATORY_TEST, null, uriInfo); - assertNotNull(doc); - final var paths = doc.paths(); - final var path = paths.get("/rests/data/mandatory-test:root-container/mandatory-container"); - assertNotNull(path); - final var requestBody = path.put().requestBody().content(); - assertNotNull(requestBody); - final var jsonRef = requestBody.get("application/json").schema().properties() - .get("mandatory-test:mandatory-container").ref(); - assertNotNull(jsonRef); - final var xmlRef = requestBody.get("application/xml").schema().ref(); - assertNotNull(xmlRef); - final var schema = doc.components().schemas().get("mandatory-test_root-container_mandatory-container"); - assertNotNull(schema); - final var minItems = schema.properties().get("leaf-list-with-min-elements").minItems(); - assertNotNull(minItems); - final var listOfExamples = ((List) schema.properties().get("leaf-list-with-min-elements").example()); - assertNotNull(listOfExamples); - assertEquals(jsonRef, xmlRef); - assertEquals(listOfExamples.size(), minItems.intValue()); - } - - private static void verifyRequestRef(final Operation operation, final String expectedRef, final String nodeType) { - final Map postContent; - if (operation.requestBody() != null) { - postContent = operation.requestBody().content(); - } else { - postContent = operation.responses().get("200").content(); - } - assertNotNull(postContent); - final String postJsonRef; - if (nodeType.equals(CONTAINER)) { - postJsonRef = postContent.get("application/json").schema().properties().values().iterator().next().ref(); - } else { - postJsonRef = postContent.get("application/json").schema().properties().values().iterator().next().items() - .ref(); - } - assertNotNull(postJsonRef); - assertEquals(expectedRef, postJsonRef); - final var postXmlRef = postContent.get("application/xml").schema().ref(); - assertNotNull(postXmlRef); - assertEquals(expectedRef, postXmlRef); - } - - private static void verifyThatOthersNodeDoesNotHaveRequiredField(final List expected, - final Map schemas) { - for (final var schema : schemas.entrySet()) { - if (expected.contains(schema.getKey())) { - continue; - } - assertNull("Json node " + schema.getKey() + " should not have 'required' field in body", - schema.getValue().required()); - } - } - - private static void verifyRequiredField(final Schema rootContainer, final List expected) { - assertNotNull(rootContainer); - final var required = rootContainer.required(); - assertNotNull(required); - assertEquals(expected, required); - } - - private static Set extractSchemaRefFromPath(final Path path) { - if (path == null) { - return Set.of(); - } - final var references = new HashSet(); - final var get = path.get(); - if (get != null) { - references.addAll(schemaRefFromContent(get.responses().get("200").content())); - } - final var post = path.post(); - if (post != null) { - references.addAll(schemaRefFromContent(post.requestBody().content())); - } - final var put = path.put(); - if (put != null) { - references.addAll(schemaRefFromContent(put.requestBody().content())); - } - final var patch = path.patch(); - if (patch != null) { - references.addAll(schemaRefFromContent(patch.requestBody().content())); - } - return references; - } - - /** - * The schema node does not have 1 specific structure and the "$ref" child is not always the first child after - * schema. Possible schema structures include: - *

    - *
  • schema/$ref/{reference}
  • - *
  • schema/properties/{nodeName}/$ref/{reference}
  • - *
  • schema/properties/{nodeName}/items/$ref/{reference}
  • - *
- * @param content the element identified with key "content" - * @return the set of referenced schemas - */ - private static Set schemaRefFromContent(final Map content) { - final HashSet refs = new HashSet<>(); - content.values().forEach(mediaType -> { - final var schema = mediaType.schema(); - final var props = mediaType.schema().properties(); - final String ref; - if (props == null) { - // either there is no node with the key "properties", try to find immediate child of schema - ref = schema.ref(); - } else if (props.values().iterator().next().items() == null) { - // or the "properties" is defined and under that we didn't find the "items" node - // try to get "$ref" as immediate child under properties - ref = props.values().iterator().next().ref(); - } else { - // or the "items" node is defined, in which case we try to get the "$ref" from this node - ref = props.values().iterator().next().items().ref(); - } - - if (ref != null) { - refs.add(ref.replaceFirst(COMPONENTS_PREFIX, "")); - } - }); - return refs; - } -} diff --git a/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/impl/OpenApiServiceImplTest.java b/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/impl/OpenApiServiceImplTest.java deleted file mode 100644 index 75e8dc4b84..0000000000 --- a/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/impl/OpenApiServiceImplTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2018 ZTE Corporation and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.restconf.openapi.impl; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.util.List; -import java.util.Optional; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.opendaylight.mdsal.dom.api.DOMMountPoint; -import org.opendaylight.mdsal.dom.api.DOMMountPointService; -import org.opendaylight.mdsal.dom.api.DOMSchemaService; -import org.opendaylight.restconf.openapi.DocGenTestHelper; -import org.opendaylight.restconf.openapi.api.OpenApiService; -import org.opendaylight.restconf.openapi.model.MountPointInstance; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; -import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; - -public final class OpenApiServiceImplTest { - private static final String HTTP_URL = "http://localhost/path"; - private static final YangInstanceIdentifier INSTANCE_ID = YangInstanceIdentifier.builder() - .node(QName.create("", "nodes")) - .node(QName.create("", "node")) - .nodeWithKey(QName.create("", "node"), QName.create("", "id"), "123").build(); - - private static EffectiveModelContext context; - private static DOMSchemaService schemaService; - - private OpenApiService openApiService; - - @BeforeClass - public static void beforeClass() { - schemaService = mock(DOMSchemaService.class); - context = YangParserTestUtils.parseYangResourceDirectory("/yang"); - when(schemaService.getGlobalContext()).thenReturn(context); - } - - @Before - public void before() { - final DOMMountPoint mountPoint = mock(DOMMountPoint.class); - when(mountPoint.getService(DOMSchemaService.class)).thenReturn(Optional.of(schemaService)); - - final DOMMountPointService service = mock(DOMMountPointService.class); - when(service.getMountPoint(INSTANCE_ID)).thenReturn(Optional.of(mountPoint)); - final MountPointOpenApiGeneratorRFC8040 mountPointRFC8040 = - new MountPointOpenApiGeneratorRFC8040(schemaService, service); - final OpenApiGeneratorRFC8040 openApiGeneratorRFC8040 = new OpenApiGeneratorRFC8040(schemaService); - mountPointRFC8040.getMountPointOpenApi().onMountPointCreated(INSTANCE_ID); - openApiService = new OpenApiServiceImpl(mountPointRFC8040, openApiGeneratorRFC8040); - } - - @Test - public void getListOfMounts() throws Exception { - final var mockInfo = DocGenTestHelper.createMockUriInfo(HTTP_URL); - final var entity = ((List) openApiService.getListOfMounts(mockInfo).getEntity()); - final var instance = entity.get(0); - assertEquals("/nodes/node=123/", instance.instance()); - assertEquals(Long.valueOf(1), instance.id()); - } -} diff --git a/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/impl/OpenApiXmlNamespaceTest.java b/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/impl/OpenApiXmlNamespaceTest.java deleted file mode 100644 index 8ea5ec5a51..0000000000 --- a/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/impl/OpenApiXmlNamespaceTest.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright (c) 2023 PANTHEON.tech, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.restconf.openapi.impl; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.util.Map; -import org.junit.BeforeClass; -import org.junit.Test; -import org.opendaylight.mdsal.dom.api.DOMSchemaService; -import org.opendaylight.restconf.openapi.DocGenTestHelper; -import org.opendaylight.restconf.openapi.model.Schema; -import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; - -/** - * Test if "xml" nodes are added with correct namespace. - * - *

- * We only want to see namespace when it's different from parent's namespace. XML namespace is also in every - * container and list node. The container and list nodes have namespaces because they refer to other schema objects - * that can be invoked independently. - */ -public class OpenApiXmlNamespaceTest { - private static final String TEST_AUGMENTATION_NAMESPACE = "urn:ietf:params:xml:ns:yang:test:augmentation"; - private static final String TEST_MODULE_NAMESPACE = "urn:ietf:params:xml:ns:yang:test:module"; - private static final String MODULE = """ - module module { - yang-version 1.1; - namespace "urn:ietf:params:xml:ns:yang:test:module"; - prefix "mod"; - container root { - container simple-root { - leaf leaf-a { - type string; - } - leaf leaf-b { - type string; - } - } - list top-list { - key "key-1 key-2"; - - leaf key-1 { - type string; - } - leaf key-2 { - type string; - } - } - } - } - """; - private static final String AUG_MODULE = """ - module augmentation { - yang-version 1.1; - namespace "urn:ietf:params:xml:ns:yang:test:augmentation"; - prefix "aug"; - import module { - prefix mod; - } - - grouping data-1 { - list list-1 { - key "leaf-x"; - leaf leaf-x { - type string; - } - } - } - - grouping data-2 { - container abc { - leaf leaf-abc { - type boolean; - } - } - } - - augment "/mod:root/mod:simple-root" { - uses data-1; - } - augment "/mod:root/mod:simple-root" { - uses data-2; - } - augment "/mod:root/mod:simple-root" { - leaf leaf-y { - type string; - } - } - - augment "/mod:root/mod:top-list" { - uses data-1; - } - augment "/mod:root/mod:top-list" { - uses data-2; - } - augment "/mod:root/mod:top-list" { - leaf leaf-y { - type string; - } - } - } - """; - - private static Map schemas; - - @BeforeClass - public static void startUp() throws Exception { - final var context1036 = YangParserTestUtils.parseYang(MODULE, AUG_MODULE); - final var mockSchemaService = mock(DOMSchemaService.class); - when(mockSchemaService.getGlobalContext()).thenReturn(context1036); - final var generatorRFC8040 = new OpenApiGeneratorRFC8040(mockSchemaService); - final var uriInfo = DocGenTestHelper.createMockUriInfo("http://localhost/path"); - final var doc = generatorRFC8040.getApiDeclaration("module", null, uriInfo); - assertNotNull(doc); - schemas = doc.components().schemas(); - } - - @Test - public void testAugmentedListInContainer() { - final var simpleList1 = schemas.get("module_root_simple-root_list-1"); - assertEquals(TEST_AUGMENTATION_NAMESPACE, simpleList1.xml().namespace()); - assertNull(simpleList1.properties().get("leaf-x").xml()); - } - - @Test - public void testAugmentedContainerInContainer() { - final var simpleAbc = schemas.get("module_root_simple-root_abc"); - assertEquals(TEST_AUGMENTATION_NAMESPACE, simpleAbc.xml().namespace()); - assertNull(simpleAbc.properties().get("leaf-abc").xml()); - } - - @Test - public void testAugmentedLeafInContainer() { - final var simple = schemas.get("module_root_simple-root"); - assertEquals(TEST_MODULE_NAMESPACE, simple.xml().namespace()); - assertEquals(TEST_AUGMENTATION_NAMESPACE, simple.properties().get("leaf-y").xml().namespace()); - assertNull(simple.properties().get("leaf-a").xml()); - } - - @Test - public void testAugmentedListInList() { - final var topList1 = schemas.get("module_root_top-list_list-1"); - assertEquals(TEST_AUGMENTATION_NAMESPACE, topList1.xml().namespace()); - assertNull(topList1.properties().get("leaf-x").xml()); - } - - @Test - public void testAugmentedContainerInList() { - final var topAbc = schemas.get("module_root_top-list_abc"); - assertEquals(TEST_AUGMENTATION_NAMESPACE, topAbc.xml().namespace()); - assertNull(topAbc.properties().get("leaf-abc").xml()); - } - - @Test - public void testAugmentedLeafInList() { - final var top = schemas.get("module_root_top-list"); - assertEquals(TEST_MODULE_NAMESPACE, top.xml().namespace()); - assertEquals(TEST_AUGMENTATION_NAMESPACE, top.properties().get("leaf-y").xml().namespace()); - assertNull(top.properties().get("key-1").xml()); - } -} diff --git a/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/impl/PostPayloadTest.java b/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/impl/PostPayloadTest.java deleted file mode 100644 index e2d5fd3f56..0000000000 --- a/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/impl/PostPayloadTest.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright (c) 2023 PANTHEON.tech, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.restconf.openapi.impl; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.opendaylight.mdsal.dom.api.DOMSchemaService; -import org.opendaylight.restconf.openapi.DocGenTestHelper; -import org.opendaylight.restconf.openapi.model.OpenApiObject; -import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; - -/** - * These tests are designed to verify that the specified path contains corresponding references in post requests - * which contains lists and containers. - * - *

- * The purpose of this test is to ensure that the specified path in the document contains the necessary references - * in its post requests for both JSON and XML content types. It verifies that the expected structure is in place, - * and the application can successfully retrieve the corresponding references for further processing. - */ -public class PostPayloadTest { - - private static final String CONTAINER_TEST = """ - module container-test { - namespace "urn:opendaylight:params:xml:ns:yang:netconf:monitoring:cont-test"; - prefix "ctest"; - revision 2023-07-31 { - description "Test model."; - } - container cont { - container cont1 { - list list4 { - key "key4"; - leaf key4 { - type string; - } - leaf value4 { - type string; - } - container cont2 { - leaf value7 { - type string; - } - list list5 { - key "key5"; - leaf key5 { - type string; - } - leaf value5 { - type string; - } - } - } - } - } - } - }"""; - private static final String LIST_TEST = """ - module list-test { - namespace "urn:opendaylight:params:xml:ns:yang:netconf:monitoring:list-test"; - prefix "ltest"; - revision 2023-07-31 { - description "Test model."; - } - container cont { - list list1 { - key "key1"; - leaf key1 { - type string; - } - leaf value1 { - type string; - } - } - list list2 { - key "key2"; - leaf key2 { - type string; - } - leaf value2 { - type string; - } - list list3 { - key "key3"; - leaf key3 { - type string; - } - leaf value3 { - type string; - } - } - } - } - }"""; - - private static OpenApiObject containerDoc; - private static OpenApiObject listDoc; - - @BeforeClass - public static void startUp() throws Exception { - final var context = YangParserTestUtils.parseYang(CONTAINER_TEST, LIST_TEST); - final var schemaService = mock(DOMSchemaService.class); - when(schemaService.getGlobalContext()).thenReturn(context); - final var generator = new OpenApiGeneratorRFC8040(schemaService); - final var uriInfo = DocGenTestHelper.createMockUriInfo("http://localhost/path"); - containerDoc = generator.getApiDeclaration("container-test", "2023-07-31", uriInfo); - assertNotNull(containerDoc); - listDoc = generator.getApiDeclaration("list-test", "2023-07-31", uriInfo); - assertNotNull(listDoc); - } - - @Test - public void testContainersPostPayloads() { - final var path1 = "/rests/data/container-test:cont"; - assertTrue(containerDoc.paths().containsKey(path1)); - final var jsonRef1 = getJsonRef(containerDoc, path1); - assertEquals("#/components/schemas/container-test_cont_cont1", jsonRef1); - final var xmlRef1 = getXmlRef(containerDoc, path1); - assertEquals("#/components/schemas/container-test_cont_cont1", xmlRef1); - - final var path2 = "/rests/data/container-test:cont/cont1"; - assertTrue(containerDoc.paths().containsKey(path2)); - final var jsonRef2 = getJsonRef(containerDoc, path2); - assertEquals("#/components/schemas/container-test_cont_cont1_list4", jsonRef2); - final var xmlRef2 = getXmlRef(containerDoc, path2); - assertEquals("#/components/schemas/container-test_cont_cont1_list4", xmlRef2); - - final var path4 = "/rests/data/container-test:cont/cont1/list4={key4}/cont2"; - assertTrue(containerDoc.paths().containsKey(path4)); - final var jsonRef4 = getJsonRef(containerDoc, path4); - assertEquals("#/components/schemas/container-test_cont_cont1_list4_cont2_list5", jsonRef4); - final var xmlRef4 = getXmlRef(containerDoc, path4); - assertEquals("#/components/schemas/container-test_cont_cont1_list4_cont2_list5", xmlRef4); - } - - @Test - public void testListsPostPayloads() { - final var path1 = "/rests/data/list-test:cont"; - assertTrue(listDoc.paths().containsKey(path1)); - final var jsonRef1 = getJsonRef(listDoc, path1); - assertEquals("#/components/schemas/list-test_cont_list1", jsonRef1); - final var xmlRef1 = getXmlRef(listDoc, path1); - assertEquals("#/components/schemas/list-test_cont_list1", xmlRef1); - } - - private static String getJsonRef(final OpenApiObject openApiObject, final String path) { - final var property = openApiObject.paths().get(path).post().requestBody().content().get("application/json") - .schema().properties().values().iterator().next(); - if (property.type().equals("object")) { - return property.ref(); - } else { - return property.items().ref(); - } - } - - private static String getXmlRef(final OpenApiObject openApiObject, final String path) { - return openApiObject.paths().get(path).post().requestBody().content().get( - "application/xml").schema().ref(); - } -} diff --git a/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/mountpoints/CustomOpenApiBasePathTest.java b/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/mountpoints/CustomOpenApiBasePathTest.java deleted file mode 100644 index 31430a83e0..0000000000 --- a/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/mountpoints/CustomOpenApiBasePathTest.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (c) 2023 PANTHEON.tech, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.restconf.openapi.mountpoints; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.util.Collection; -import java.util.List; -import java.util.Optional; -import java.util.Set; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; -import org.opendaylight.mdsal.dom.api.DOMMountPoint; -import org.opendaylight.mdsal.dom.api.DOMMountPointService; -import org.opendaylight.mdsal.dom.api.DOMSchemaService; -import org.opendaylight.restconf.openapi.DocGenTestHelper; -import org.opendaylight.restconf.openapi.impl.MountPointOpenApiGeneratorRFC8040; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; - -@RunWith(Parameterized.class) -public final class CustomOpenApiBasePathTest { - private static final YangInstanceIdentifier INSTANCE_ID = YangInstanceIdentifier.builder() - .node(QName.create("", "nodes")) - .node(QName.create("", "node")) - .nodeWithKey(QName.create("", "node"), QName.create("", "id"), "123").build(); - - private MountPointOpenApi openApi; - - @Parameter - public static String basePath; - - @Parameters(name = "{0}") - public static Collection data() { - return List.of("rests", "restconf"); - } - - @Before - public void before() { - final var schemaService = mock(DOMSchemaService.class); - final var context = YangParserTestUtils.parseYang(""" - module custom-base-path-test { - yang-version 1.1; - namespace urn:opendaylight:action-path-test; - prefix "path-test"; - - revision "2023-05-30" { - description - "Initial revision."; - } - - rpc rpc-call { - input { - leaf rpc-call-input { - type string; - } - } - output { - leaf rpc-call-output { - type string; - } - } - } - - container foo { - list foo-list { - key "fooListKey"; - leaf fooListKey { - type string; - } - } - action foo-action { - input { - leaf foo-action-input { - type string; - } - } - output { - leaf foo-action-output { - type string; - } - } - } - } - } - """); - - when(schemaService.getGlobalContext()).thenReturn(context); - final var mountPoint = mock(DOMMountPoint.class); - when(mountPoint.getService(DOMSchemaService.class)).thenReturn(Optional.of(schemaService)); - final var mountPointService = mock(DOMMountPointService.class); - when(mountPointService.getMountPoint(INSTANCE_ID)).thenReturn(Optional.of(mountPoint)); - final var generator = new MountPointOpenApiGeneratorRFC8040(schemaService, mountPointService, basePath); - openApi = generator.getMountPointOpenApi(); - openApi.onMountPointCreated(INSTANCE_ID); - } - - @Test - public void testCustomOpenApiBasePath() throws Exception { - final var mockInfo = DocGenTestHelper.createMockUriInfo("http://localhost/path"); - final var mountPointApi = openApi.getMountPointApi(mockInfo, 1L, "custom-base-path-test", "2023-05-30"); - assertNotNull("Failed to find Datastore API", mountPointApi); - - final var containerOperationRoot = "/" + basePath + "/operations/nodes/node=123/yang-ext:mount"; - final var containerDataRoot = "/" + basePath + "/data/nodes/node=123/yang-ext:mount"; - final var expectedPaths = Set.of( - containerOperationRoot + "/custom-base-path-test:rpc-call", - containerOperationRoot + "/custom-base-path-test:foo/foo-action", - containerDataRoot + "/custom-base-path-test:foo/foo-list={fooListKey}", - containerDataRoot + "/custom-base-path-test:foo", - containerDataRoot); - - assertEquals("Unexpected paths", expectedPaths, mountPointApi.paths().keySet()); - } -} diff --git a/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/mountpoints/MountPointOpenApiTest.java b/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/mountpoints/MountPointOpenApiTest.java deleted file mode 100644 index 6a641950cc..0000000000 --- a/restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/mountpoints/MountPointOpenApiTest.java +++ /dev/null @@ -1,443 +0,0 @@ -/* - * Copyright (c) 2014 Brocade Communications Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.restconf.openapi.mountpoints; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -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.getPathGetParameters; -import static org.opendaylight.restconf.openapi.OpenApiTestUtils.getPathPostParameters; -import static org.opendaylight.restconf.openapi.impl.BaseYangOpenApiGenerator.BASIC_AUTH_NAME; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import java.util.TreeSet; -import java.util.stream.Collectors; -import javax.ws.rs.core.UriInfo; -import org.glassfish.jersey.internal.util.collection.ImmutableMultivaluedMap; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.opendaylight.mdsal.dom.api.DOMMountPoint; -import org.opendaylight.mdsal.dom.api.DOMMountPointService; -import org.opendaylight.mdsal.dom.api.DOMSchemaService; -import org.opendaylight.restconf.openapi.DocGenTestHelper; -import org.opendaylight.restconf.openapi.impl.MountPointOpenApiGeneratorRFC8040; -import org.opendaylight.restconf.openapi.model.OpenApiObject; -import org.opendaylight.restconf.openapi.model.Operation; -import org.opendaylight.restconf.openapi.model.Path; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; -import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; - -public final class MountPointOpenApiTest { - private static final String TOASTER = "toaster"; - private static final String TOASTER_REVISION = "2009-11-20"; - private static final Long DEVICE_ID = 1L; - private static final String DEVICE_NAME = "123"; - private static final String TOASTER_NODE_PATH = "/rests/data/nodes/node=123/yang-ext:mount/toaster:toaster"; - private static final String TOASTER_NODE_GET_SUMMARY = "GET - " + DEVICE_NAME + " - toaster - toaster"; - private static final String GET_ALL = "http://localhost:8181/openapi/api/v3/mounts/" + DEVICE_ID; - private static final String GET_TOASTER = "http://localhost:8181/openapi/api/v3/mounts/%s/%s(%s)".formatted( - DEVICE_ID, TOASTER, TOASTER_REVISION); - private static final String HTTP_URL = "http://localhost/path"; - private static final YangInstanceIdentifier INSTANCE_ID = YangInstanceIdentifier.builder() - .node(QName.create("", "nodes")) - .node(QName.create("", "node")) - .nodeWithKey(QName.create("", "node"), QName.create("", "id"), DEVICE_NAME).build(); - private static final String INSTANCE_URL = "/nodes/node=123/"; - - private static EffectiveModelContext context; - private static DOMSchemaService schemaService; - - private MountPointOpenApi openApi; - private UriInfo uriDeviceAll; - private UriInfo uriDeviceToaster; - - @BeforeClass - public static void beforeClass() { - schemaService = mock(DOMSchemaService.class); - context = YangParserTestUtils.parseYangResourceDirectory("/yang"); - when(schemaService.getGlobalContext()).thenReturn(context); - } - - @Before - public void before() throws Exception { - // We are sharing the global schema service and the mount schema service - // in our test. - // OK for testing - real thing would have separate instances. - final DOMMountPoint mountPoint = mock(DOMMountPoint.class); - when(mountPoint.getService(DOMSchemaService.class)).thenReturn(Optional.of(schemaService)); - - final DOMMountPointService service = mock(DOMMountPointService.class); - when(service.getMountPoint(INSTANCE_ID)).thenReturn(Optional.of(mountPoint)); - - openApi = new MountPointOpenApiGeneratorRFC8040(schemaService, service).getMountPointOpenApi(); - - uriDeviceAll = DocGenTestHelper.createMockUriInfo(GET_ALL); - when(uriDeviceAll.getQueryParameters()).thenReturn(ImmutableMultivaluedMap.empty()); - uriDeviceToaster = DocGenTestHelper.createMockUriInfo(GET_TOASTER); - when(uriDeviceToaster.getQueryParameters()).thenReturn(ImmutableMultivaluedMap.empty()); - } - - @Test() - public void getInstanceIdentifiers() { - assertEquals(0, openApi.getInstanceIdentifiers().size()); - openApi.onMountPointCreated(INSTANCE_ID); // add this ID into the list of mount points - assertEquals(1, openApi.getInstanceIdentifiers().size()); - assertEquals((Long) 1L, openApi.getInstanceIdentifiers().entrySet().iterator().next() - .getValue()); - assertEquals(INSTANCE_URL, openApi.getInstanceIdentifiers().entrySet().iterator().next() - .getKey()); - openApi.onMountPointRemoved(INSTANCE_ID); // remove ID from list of mount points - assertEquals(0, openApi.getInstanceIdentifiers().size()); - } - - @Test - public void testGetDataStoreApi() throws Exception { - final UriInfo mockInfo = DocGenTestHelper.createMockUriInfo(HTTP_URL); - openApi.onMountPointCreated(INSTANCE_ID); // add this ID into the list of mount points - - final OpenApiObject mountPointApi = openApi.getMountPointApi(mockInfo, 1L, "Datastores", "-"); - assertNotNull("Failed to find Datastore API", mountPointApi); - - final Map paths = mountPointApi.paths(); - assertNotNull(paths); - - assertEquals("Unexpected api list size", 2, paths.size()); - - final Set actualUrls = new TreeSet<>(); - - for (final Map.Entry path : paths.entrySet()) { - actualUrls.add(path.getKey()); - final Operation getOperation = path.getValue().get(); - assertNotNull("Unexpected operation method on " + path, getOperation); - assertNotNull("Expected non-null desc on " + path, getOperation.description()); - } - - assertEquals(Set.of("/rests/data" + INSTANCE_URL + "yang-ext:mount", - "/rests/operations" + INSTANCE_URL + "yang-ext:mount"), actualUrls); - } - - /** - * Test that creates mount point api with all models from yang folder and checks operation paths for these models. - */ - @Test - public void testGetMountPointApi() throws Exception { - final UriInfo mockInfo = DocGenTestHelper.createMockUriInfo(HTTP_URL); - openApi.onMountPointCreated(INSTANCE_ID); - - final OpenApiObject mountPointApi = openApi.getMountPointApi(mockInfo, 1L, null); - assertNotNull("Failed to find Datastore API", mountPointApi); - - final Map paths = mountPointApi.paths(); - assertNotNull(paths); - - assertEquals("Unexpected api list size", 78, paths.size()); - - final List getOperations = new ArrayList<>(); - final List postOperations = new ArrayList<>(); - final List putOperations = new ArrayList<>(); - final List patchOperations = new ArrayList<>(); - final List deleteOperations = new ArrayList<>(); - - for (final Map.Entry path : paths.entrySet()) { - Optional.ofNullable(path.getValue().get()).ifPresent(getOperations::add); - Optional.ofNullable(path.getValue().post()).ifPresent(postOperations::add); - Optional.ofNullable(path.getValue().put()).ifPresent(putOperations::add); - Optional.ofNullable(path.getValue().patch()).ifPresent(patchOperations::add); - Optional.ofNullable(path.getValue().delete()).ifPresent(deleteOperations::add); - } - - assertEquals("Unexpected GET paths size", 70, getOperations.size()); - assertEquals("Unexpected POST paths size", 21, postOperations.size()); - assertEquals("Unexpected PUT paths size", 68, putOperations.size()); - assertEquals("Unexpected PATCH paths size", 68, patchOperations.size()); - assertEquals("Unexpected DELETE paths size", 68, deleteOperations.size()); - } - - /** - * Test that checks for correct amount of parameters in requests. - */ - @Test - @SuppressWarnings("checkstyle:lineLength") - public void testMountPointRecursiveParameters() throws Exception { - final var configPaths = Map.of("/rests/data/nodes/node=123/yang-ext:mount/recursive:container-root", 0, - "/rests/data/nodes/node=123/yang-ext:mount/recursive:container-root/root-list={name}", 1, - "/rests/data/nodes/node=123/yang-ext:mount/recursive:container-root/root-list={name}/nested-list={name1}", 2, - "/rests/data/nodes/node=123/yang-ext:mount/recursive:container-root/root-list={name}/nested-list={name1}/super-nested-list={name2}", 3); - - final var mockInfo = DocGenTestHelper.createMockUriInfo(HTTP_URL); - openApi.onMountPointCreated(INSTANCE_ID); - - final var mountPointApi = openApi.getMountPointApi(mockInfo, 1L, "recursive", "2023-05-22"); - assertNotNull("Failed to find Datastore API", mountPointApi); - - final var paths = mountPointApi.paths(); - assertEquals(5, paths.size()); - - for (final var expectedPath : configPaths.entrySet()) { - assertTrue(paths.containsKey(expectedPath.getKey())); - final int expectedSize = expectedPath.getValue(); - - final var path = paths.get(expectedPath.getKey()); - - final var get = path.get(); - assertNotNull(get); - assertEquals(expectedSize + 1, get.parameters().size()); - - final var put = path.put(); - assertNotNull(put); - assertEquals(expectedSize, put.parameters().size()); - - final var delete = path.delete(); - assertNotNull(delete); - assertEquals(expectedSize, delete.parameters().size()); - - final var patch = path.patch(); - assertNotNull(patch); - assertEquals(expectedSize, patch.parameters().size()); - } - - // POST request exists only for containers - final var post = paths.get("/rests/data/nodes/node=123/yang-ext:mount/recursive:container-root").post(); - assertNotNull(post); - final int expectedSize = configPaths.get("/rests/data/nodes/node=123/yang-ext:mount/recursive:container-root"); - assertEquals(expectedSize, post.parameters().size()); - } - - /** - * Test that request parameters are correctly numbered. - * - *

- * It means we should have name and name1, etc. when we have the same parameter in path multiple times. - */ - @Test - public void testParametersNumberingForMountPointApi() throws Exception { - final UriInfo mockInfo = DocGenTestHelper.createMockUriInfo(HTTP_URL); - openApi.onMountPointCreated(INSTANCE_ID); - - final OpenApiObject mountPointApi = openApi.getMountPointApi(mockInfo, 1L, null); - assertNotNull("Failed to find Datastore API", mountPointApi); - - 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"), 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"), 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"), 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"), 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"), getPathGetParameters(mountPointApi.paths(), pathToList5)); - } - - /** - * Test that request parameters are correctly typed. - */ - @Test - public void testParametersTypesForMountPointApi() throws Exception { - final var mockInfo = DocGenTestHelper.createMockUriInfo(HTTP_URL); - openApi.onMountPointCreated(INSTANCE_ID); - final var doc = openApi.getMountPointApi(mockInfo, 1L, null); - final var pathToContainer = "/rests/data/nodes/node=123/yang-ext:mount/typed-params:typed/"; - final var integerTypes = List.of("uint64", "uint32", "uint16", "uint8", "int64", "int32", "int16", "int8"); - for (final var type: integerTypes) { - final var typeKey = type + "-key"; - final var path = pathToContainer + type + "={" + typeKey + "}"; - assertTrue(doc.paths().containsKey(path)); - assertEquals("integer", doc.paths().get(path).get().parameters().get(0).schema().type()); - } - } - - /** - * Test that request for actions is correct and has parameters. - */ - @Test - public void testActionPathsParamsForMountPointApi() throws Exception { - final var mockInfo = DocGenTestHelper.createMockUriInfo(HTTP_URL); - openApi.onMountPointCreated(INSTANCE_ID); - - final var mountPointApi = openApi.getMountPointApi(mockInfo, 1L, null); - assertNotNull("Failed to find Datastore API", mountPointApi); - - 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"), 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(), getPathPostParameters(mountPointApi.paths(), pathWithoutParameters)); - } - - /** - * Test that checks if securitySchemes and security elements are present. - */ - @Test - public void testAuthenticationFeature() throws Exception { - final var mockInfo = DocGenTestHelper.createMockUriInfo(HTTP_URL); - openApi.onMountPointCreated(INSTANCE_ID); - final var mountPointApi = openApi.getMountPointApi(mockInfo, 1L, null); - - assertEquals("[{basicAuth=[]}]", mountPointApi.security().toString()); - assertEquals("Http[type=http, scheme=basic, description=null, bearerFormat=null]", - mountPointApi.components().securitySchemes().get(BASIC_AUTH_NAME).toString()); - } - - @Test - public void testSummaryForAllModules() { - openApi.onMountPointCreated(INSTANCE_ID); - // get OpenApiObject for the device (all modules) - final OpenApiObject openApiAll = openApi.getMountPointApi(uriDeviceAll, DEVICE_ID, null); - final String getToasterSummary = openApiAll.paths() - .get(TOASTER_NODE_PATH) - .get() - .summary(); - assertEquals(TOASTER_NODE_GET_SUMMARY, getToasterSummary); - } - - @Test - public void testSummaryForSingleModule() { - openApi.onMountPointCreated(INSTANCE_ID); - // get OpenApiObject for a specific module (toaster) associated with the mounted device - final OpenApiObject openApiToaster = openApi.getMountPointApi(uriDeviceToaster, DEVICE_ID, TOASTER, - TOASTER_REVISION); - final String getToasterSummary = openApiToaster.paths() - .get(TOASTER_NODE_PATH) - .get() - .summary(); - assertEquals(TOASTER_NODE_GET_SUMMARY, getToasterSummary); - } - - @Test - public void testPathsForSpecificModuleOfMounted() { - openApi.onMountPointCreated(INSTANCE_ID); - - // get OpenApiObject for the device (all modules) - final OpenApiObject openApiAll = openApi.getMountPointApi(uriDeviceAll, DEVICE_ID, null); - // get OpenApiObject for a specific module (toaster(2009-11-20)) - final OpenApiObject openApiToaster = openApi.getMountPointApi(uriDeviceToaster, DEVICE_ID, TOASTER, - TOASTER_REVISION); - - /* - filter paths from openapi for all modules down to only those that are present in openapi for toaster. - The Path object for the path, that in this case ends with "yang-ext:mount" is constructed in a different way - when requesting OpenApiObject for a single module compared to requesting it for all modules. - We do not want to include it in this particular comparison, so filter it out - */ - final Set> toasterPathsFromAll = openApiAll.paths().entrySet() - .stream() - .filter(e -> openApiToaster.paths().containsKey(e.getKey()) && !e.getKey().endsWith("yang-ext:mount")) - .collect(Collectors.toSet()); - - final Set> toasterPathsFromToaster = openApiToaster.paths().entrySet() - .stream() - .filter(e -> !e.getKey().endsWith("yang-ext:mount")) - .collect(Collectors.toSet()); - - // verify that the filtered set (from openapi for all modules) is the same as the set from openapi for toaster - assertEquals(toasterPathsFromToaster, toasterPathsFromAll); - } - - /** - * Test that checks if namespace for rpc is present. - */ - @Test - public void testRpcNamespace() throws Exception { - final var mockInfo = DocGenTestHelper.createMockUriInfo(HTTP_URL); - openApi.onMountPointCreated(INSTANCE_ID); - - final var mountPointApi = openApi.getMountPointApi(mockInfo, 1L, null); - assertNotNull("Failed to find Datastore API", mountPointApi); - final var paths = mountPointApi.paths(); - final var path = paths.get("/rests/operations/nodes/node=123/yang-ext:mount/toaster:cancel-toast"); - assertNotNull(path); - final var content = path.post().requestBody().content().get("application/xml"); - assertNotNull(content); - final var schema = content.schema(); - assertNotNull(schema); - final var xml = schema.xml(); - assertNotNull(xml); - final var namespace = xml.namespace(); - assertNotNull(namespace); - assertEquals("http://netconfcentral.org/ns/toaster", namespace); - } - - /** - * Test that checks if namespace for actions is present. - */ - @Test - public void testActionsNamespace() throws Exception { - final var mockInfo = DocGenTestHelper.createMockUriInfo(HTTP_URL); - openApi.onMountPointCreated(INSTANCE_ID); - final var mountPointApi = openApi.getMountPointApi(mockInfo, 1L, null); - assertNotNull("Failed to find Datastore API", mountPointApi); - final var paths = mountPointApi.paths(); - final var path = paths.get( - "/rests/operations/nodes/node=123/yang-ext:mount/action-types:multi-container/inner-container/action"); - assertNotNull(path); - final var content = path.post().requestBody().content().get("application/xml"); - assertNotNull(content); - final var schema = content.schema(); - assertNotNull(schema); - final var xml = schema.xml(); - assertNotNull(xml); - final var namespace = xml.namespace(); - assertNotNull(namespace); - assertEquals("urn:ietf:params:xml:ns:yang:test:action:types", namespace); - } - - /** - * Test that number of elements in payload is correct. - */ - @SuppressWarnings("unchecked") - @Test - public void testLeafListWithMinElementsPayloadOnMountPoint() throws Exception { - final var mockInfo = DocGenTestHelper.createMockUriInfo(HTTP_URL); - openApi.onMountPointCreated(INSTANCE_ID); - final var mountPointApi = openApi.getMountPointApi(mockInfo, 1L, null); - assertNotNull(mountPointApi); - final var paths = mountPointApi.paths(); - final var path = - paths.get("/rests/data/nodes/node=123/yang-ext:mount/mandatory-test:root-container/mandatory-container"); - assertNotNull(path); - final var requestBody = path.put().requestBody().content(); - assertNotNull(requestBody); - final var jsonRef = requestBody.get("application/json").schema().properties() - .get("mandatory-test:mandatory-container").ref(); - assertNotNull(jsonRef); - final var xmlRef = requestBody.get("application/xml").schema().ref(); - assertNotNull(xmlRef); - final var schema = - mountPointApi.components().schemas().get("mandatory-test_root-container_mandatory-container"); - assertNotNull(schema); - final var minItems = schema.properties().get("leaf-list-with-min-elements").minItems(); - assertNotNull(minItems); - final var listOfExamples = ((List) schema.properties().get("leaf-list-with-min-elements").example()); - assertNotNull(listOfExamples); - assertEquals(jsonRef, xmlRef); - assertEquals(listOfExamples.size(), minItems.intValue()); - } -} diff --git a/restconf/restconf-openapi/src/test/resources/operational-document/controller-action-types.json b/restconf/restconf-openapi/src/test/resources/operational-document/controller-action-types.json index 782f40edc7..9c4acbfecd 100644 --- a/restconf/restconf-openapi/src/test/resources/operational-document/controller-action-types.json +++ b/restconf/restconf-openapi/src/test/resources/operational-document/controller-action-types.json @@ -3,7 +3,7 @@ "info": { "version": "1.0.0", "title": "action-types", - "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That’s because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." + "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That is because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." }, "servers": [ { diff --git a/restconf/restconf-openapi/src/test/resources/operational-document/controller-all.json b/restconf/restconf-openapi/src/test/resources/operational-document/controller-all.json index 2aa4934aaa..1fcbdd7c5a 100644 --- a/restconf/restconf-openapi/src/test/resources/operational-document/controller-all.json +++ b/restconf/restconf-openapi/src/test/resources/operational-document/controller-all.json @@ -3,7 +3,7 @@ "info": { "version": "1.0.0", "title": "Controller modules of RESTCONF", - "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That’s because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." + "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That is because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." }, "servers": [ { diff --git a/restconf/restconf-openapi/src/test/resources/operational-document/controller-operational.json b/restconf/restconf-openapi/src/test/resources/operational-document/controller-operational.json index 0e6d7547ad..005dc76ccc 100644 --- a/restconf/restconf-openapi/src/test/resources/operational-document/controller-operational.json +++ b/restconf/restconf-openapi/src/test/resources/operational-document/controller-operational.json @@ -3,7 +3,7 @@ "info": { "version": "1.0.0", "title": "operational", - "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That’s because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." + "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That is because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." }, "servers": [ { diff --git a/restconf/restconf-openapi/src/test/resources/operational-document/device-action-types.json b/restconf/restconf-openapi/src/test/resources/operational-document/device-action-types.json index d65ed46185..1c4540f0f3 100644 --- a/restconf/restconf-openapi/src/test/resources/operational-document/device-action-types.json +++ b/restconf/restconf-openapi/src/test/resources/operational-document/device-action-types.json @@ -3,7 +3,7 @@ "info": { "version": "1.0.0", "title": "action-types", - "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That’s because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." + "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That is because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." }, "servers": [ { diff --git a/restconf/restconf-openapi/src/test/resources/operational-document/device-all.json b/restconf/restconf-openapi/src/test/resources/operational-document/device-all.json index ee5daa236e..c49e62647b 100644 --- a/restconf/restconf-openapi/src/test/resources/operational-document/device-all.json +++ b/restconf/restconf-openapi/src/test/resources/operational-document/device-all.json @@ -3,7 +3,7 @@ "info": { "version": "1.0.0", "title": "123 modules of RESTCONF", - "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That’s because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." + "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That is because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." }, "servers": [ { diff --git a/restconf/restconf-openapi/src/test/resources/operational-document/device-operational.json b/restconf/restconf-openapi/src/test/resources/operational-document/device-operational.json index fab4fc05df..9240611765 100644 --- a/restconf/restconf-openapi/src/test/resources/operational-document/device-operational.json +++ b/restconf/restconf-openapi/src/test/resources/operational-document/device-operational.json @@ -3,7 +3,7 @@ "info": { "version": "1.0.0", "title": "operational", - "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That’s because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." + "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That is because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." }, "servers": [ { diff --git a/restconf/restconf-openapi/src/test/resources/sample-swagger-spec.json b/restconf/restconf-openapi/src/test/resources/sample-swagger-spec.json deleted file mode 100644 index 2d1b09a0f8..0000000000 --- a/restconf/restconf-openapi/src/test/resources/sample-swagger-spec.json +++ /dev/null @@ -1,440 +0,0 @@ -{ - "apiVersion": "1.0.0", - "swaggerVersion": "1.2", - "basePath": "/api", - "resourcePath": "/pet", - "produces": [ - "application/json", - "application/xml", - "text/plain", - "text/html" - ], - "authorizations": { - "oauth2": [ - { - "scope": "write:pets", - "description": "modify pets in your account" - }, - { - "scope": "read:pets", - "description": "read your pets" - } - ] - }, - "apis": [ - { - "path": "/pet", - "operations": [ - { - "method": "POST", - "summary": "Add a new pet to the store", - "notes": "", - "type": "void", - "nickname": "addPet", - "consumes": [ - "application/json", - "application/xml" - ], - "authorizations": { - "oauth2": [ - { - "scope": "write:pets", - "description": "modify pets in your account" - } - ] - }, - "parameters": [ - { - "name": "body", - "description": "Pet object that needs to be added to the store", - "required": true, - "type": "Pet", - "paramType": "body" - } - ], - "responseMessages": [ - { - "code": 405, - "message": "Invalid input" - } - ] - }, - { - "method": "PUT", - "summary": "Update an existing pet", - "notes": "", - "type": "void", - "nickname": "updatePet", - "authorizations": {}, - "parameters": [ - { - "name": "body", - "description": "Pet object that needs to be updated in the store", - "required": true, - "type": "Pet", - "paramType": "body" - } - ], - "responseMessages": [ - { - "code": 400, - "message": "Invalid ID supplied" - }, - { - "code": 404, - "message": "Pet not found" - }, - { - "code": 405, - "message": "Validation exception" - } - ] - } - ] - }, - { - "path": "/pet/findByStatus", - "operations": [ - { - "method": "GET", - "summary": "Finds Pets by status", - "notes": "Multiple status values can be provided with comma seperated strings", - "type": "array", - "items": { - "$ref": "Pet" - }, - "nickname": "testNodeType", - "authorizations": {}, - "parameters": [ - { - "name": "nodeTypez", - "description": "Status values that need to be considered for filter", - "defaultValue": "available", - "required": true, - "type": "string", - "paramType": "query", - "enum": [ - "available", - "pending", - "sold" - ] - } - ], - "responseMessages": [ - { - "code": 400, - "message": "Invalid status value" - } - ] - } - ] - }, - { - "path": "/pet/findByTags", - "operations": [ - { - "method": "GET", - "summary": "Finds Pets by tags", - "notes": "Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.", - "type": "array", - "items": { - "$ref": "Pet" - }, - "nickname": "findPetsByTags", - "authorizations": {}, - "parameters": [ - { - "name": "tags", - "description": "Tags to filter by", - "required": true, - "type": "string", - "paramType": "query" - } - ], - "responseMessages": [ - { - "code": 400, - "message": "Invalid tag value" - } - ], - "deprecated": "true" - } - ] - }, - { - "path": "/pet/{petId}", - "operations": [ - { - "method": "PATCH", - "summary": "partial updates to a pet", - "notes": "", - "type": "array", - "items": { - "$ref": "Pet" - }, - "nickname": "partialUpdate", - "produces": [ - "application/json", - "application/xml" - ], - "consumes": [ - "application/json", - "application/xml" - ], - "authorizations": { - "oauth2": [ - { - "scope": "write:pets", - "description": "modify pets in your account" - } - ] - }, - "parameters": [ - { - "name": "petId", - "description": "ID of pet that needs to be fetched", - "required": true, - "type": "string", - "paramType": "path" - }, - { - "name": "body", - "description": "Pet object that needs to be added to the store", - "required": true, - "type": "Pet", - "paramType": "body" - } - ], - "responseMessages": [ - { - "code": 400, - "message": "Invalid tag value" - } - ] - }, - { - "method": "POST", - "summary": "Updates a pet in the store with form data", - "notes": "", - "type": "void", - "nickname": "updatePetWithForm", - "consumes": [ - "application/x-www-form-urlencoded" - ], - "authorizations": { - "oauth2": [ - { - "scope": "write:pets", - "description": "modify pets in your account" - } - ] - }, - "parameters": [ - { - "name": "petId", - "description": "ID of pet that needs to be updated", - "required": true, - "type": "string", - "paramType": "path" - }, - { - "name": "name", - "description": "Updated name of the pet", - "required": false, - "type": "string", - "paramType": "form" - }, - { - "name": "status", - "description": "Updated status of the pet", - "required": false, - "type": "string", - "paramType": "form" - } - ], - "responseMessages": [ - { - "code": 405, - "message": "Invalid input" - } - ] - }, - { - "method": "DELETE", - "summary": "Deletes a pet", - "notes": "", - "type": "void", - "nickname": "deletePet", - "authorizations": { - "oauth2": [ - { - "scope": "write:pets", - "description": "modify pets in your account" - } - ] - }, - "parameters": [ - { - "name": "petId", - "description": "Pet id to delete", - "required": true, - "type": "string", - "paramType": "path" - } - ], - "responseMessages": [ - { - "code": 400, - "message": "Invalid pet value" - } - ] - }, - { - "method": "GET", - "summary": "Find pet by ID", - "notes": "Returns a pet based on ID", - "type": "Pet", - "nickname": "getPetById", - "authorizations": {}, - "parameters": [ - { - "name": "petId", - "description": "ID of pet that needs to be fetched", - "required": true, - "type": "integer", - "format": "int64", - "paramType": "path", - "minimum": "1.0", - "maximum": "100000.0" - } - ], - "responseMessages": [ - { - "code": 400, - "message": "Invalid ID supplied" - }, - { - "code": 404, - "message": "Pet not found" - } - ] - } - ] - }, - { - "path": "/pet/uploadImage", - "operations": [ - { - "method": "POST", - "summary": "uploads an image", - "notes": "", - "type": "void", - "nickname": "uploadFile", - "consumes": [ - "multipart/form-data" - ], - "authorizations": { - "oauth2": [ - { - "scope": "write:pets", - "description": "modify pets in your account" - }, - { - "scope": "read:pets", - "description": "read your pets" - } - ] - }, - "parameters": [ - { - "name": "additionalMetadata", - "description": "Additional data to pass to server", - "required": false, - "type": "string", - "paramType": "form" - }, - { - "name": "file", - "description": "file to upload", - "required": false, - "type": "File", - "paramType": "body" - } - ] - } - ] - } - ], - "models": { - "Tag": { - "id": "Tag", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - } - } - }, - "Pet": { - "id": "Pet", - "required": [ - "id", - "name" - ], - "properties": { - "id": { - "type": "integer", - "format": "int64", - "description": "unique identifier for the pet", - "minimum": "0.0", - "maximum": "100.0" - }, - "category": { - "$ref": "Category" - }, - "name": { - "type": "string" - }, - "photoUrls": { - "type": "array", - "items": { - "type": "string" - } - }, - "tags": { - "type": "array", - "items": { - "$ref": "Tag" - } - }, - "status": { - "type": "string", - "description": "pet status in the store", - "enum": [ - "available", - "pending", - "sold" - ] - } - } - }, - "Category": { - "id": "Category", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "pet": { - "$ref": "Pet" - } - } - } - } -} diff --git a/restconf/restconf-openapi/src/test/resources/toaster-document/controller-all.json b/restconf/restconf-openapi/src/test/resources/toaster-document/controller-all.json index a9ed89d1bb..93eeb9ea2e 100644 --- a/restconf/restconf-openapi/src/test/resources/toaster-document/controller-all.json +++ b/restconf/restconf-openapi/src/test/resources/toaster-document/controller-all.json @@ -3,7 +3,7 @@ "info": { "version": "1.0.0", "title": "Controller modules of RESTCONF", - "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That’s because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." + "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That is because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." }, "servers": [ { diff --git a/restconf/restconf-openapi/src/test/resources/toaster-document/controller-toaster.json b/restconf/restconf-openapi/src/test/resources/toaster-document/controller-toaster.json index 4268396ccc..ccd5b680e0 100644 --- a/restconf/restconf-openapi/src/test/resources/toaster-document/controller-toaster.json +++ b/restconf/restconf-openapi/src/test/resources/toaster-document/controller-toaster.json @@ -3,7 +3,7 @@ "info": { "version": "1.0.0", "title": "toaster", - "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That’s because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." + "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That is because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." }, "servers": [ { diff --git a/restconf/restconf-openapi/src/test/resources/toaster-document/device-all.json b/restconf/restconf-openapi/src/test/resources/toaster-document/device-all.json index f8a2834ebd..fd068d46f8 100644 --- a/restconf/restconf-openapi/src/test/resources/toaster-document/device-all.json +++ b/restconf/restconf-openapi/src/test/resources/toaster-document/device-all.json @@ -3,7 +3,7 @@ "info": { "version": "1.0.0", "title": "123 modules of RESTCONF", - "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That’s because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." + "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That is because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." }, "servers": [ { diff --git a/restconf/restconf-openapi/src/test/resources/toaster-document/device-toaster.json b/restconf/restconf-openapi/src/test/resources/toaster-document/device-toaster.json index 011d7bfc6d..162ce26390 100644 --- a/restconf/restconf-openapi/src/test/resources/toaster-document/device-toaster.json +++ b/restconf/restconf-openapi/src/test/resources/toaster-document/device-toaster.json @@ -3,7 +3,7 @@ "info": { "version": "1.0.0", "title": "toaster", - "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That’s because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." + "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That is because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." }, "servers": [ { diff --git a/restconf/restconf-openapi/src/test/resources/toaster.json b/restconf/restconf-openapi/src/test/resources/toaster.json deleted file mode 100644 index 8af246254d..0000000000 --- a/restconf/restconf-openapi/src/test/resources/toaster.json +++ /dev/null @@ -1,167 +0,0 @@ -{ - "apiVersion": "1.0.0", - "swaggerVersion": "1.2", - "basePath": "/api", - "resourcePath": "/toaster", - "produces": [ - "application/json", - "application/xml", - "text/plain", - "text/html" - ], - "apis": [ - { - "path": "/toaster", - "operations": [ - { - "method": "POST", - "summary": "Add a new toaster", - "notes": "", - "type": "void", - "nickname": "add toaster", - "consumes": [ - "application/json", - "application/xml" - ], - "parameters": [ - { - "name": "body", - "description": "Pet object that needs to be added to the store", - "required": true, - "type": "Toaster", - "paramType": "body" - } - ], - "responseMessages": [ - { - "code": 405, - "message": "Invalid input" - } - ] - } - ] - }, - { - "path": "/toaster", - "operations": [ - { - "method": "GET", - "summary": "Add a new toaster", - "notes": "", - "type": "Toaster", - "nickname": "Get toaster", - "consumes": [ - "application/json", - "application/xml" - ], - "responseMessages": [ - { - "code": 405, - "message": "Invalid input" - } - ] - } - ] - }, - { - "path" : "operations/toaster/cancel-toast", - "operations" : [ { - "method" : "POST", - "summary" : null, - "notes" : "Stop making toast, if any is being made.\n A 'resource-denied' error will be returned \n if the toaster service is disabled.", - "type" : null, - "nickname" : "cancel-toast", - "consumes" : null, - "parameters" : null, - "responseMessages" : null - } ] - }, { - "path" : "operations/toaster/make-toast", - "operations" : [ { - "method" : "POST", - "summary" : null, - "notes" : "Make some toast.\n The toastDone notification will be sent when \n the toast is finished.\n An 'in-use' error will be returned if toast\n is already being made.\n A 'resource-denied' error will be returned \n if the toaster service is disabled.", - "type" : null, - "nickname" : "make-toast", - "consumes" : null, - "parameters" : null, - "responseMessages" : null - } ] - } - ], - "models": { - "Toaster": { - "id":"Toaster", - "$schema": "http://json-schema.org/draft-04/schema", - "description": "Top-level container for all toaster database objects.", - "properties": { - "allow-user": { - "description": "A list of user name patterns to allow", - "items": {"type": "string"}, - "required": false, - "type": "array" - }, - "how": { - "oneOf": [ - { - "manual": {"manual": { - "required": false, - "type": "string" - }}, - "type": "object" - }, - { - "interval": {"interval": { - "required": false, - "type": "integer" - }}, - "type": "object" - }, - { - "daily": { - "daily": { - "required": false, - "type": "string" - }, - "time-of-day": { - "required": false, - "type": "string" - } - }, - "type": "object" - } - ], - "type": "object" - }, - "testToasterBits": { - "enum": [ - "testbit1", - "testbit2" - ], - "minItems": 0, - "required": false, - "type": "String", - "uniqueItems": true - }, - "toasterManufacturer": { - "description": "The name of the toaster's manufacturer. For instance, \n Microsoft Toaster.", - "required": true, - "type": "string" - }, - "toasterModelNumber": { - "description": "The name of the toaster's model. For instance,\n Radiant Automatic.", - "required": true, - "type": "string" - }, - "toasterStatus": { - "description": "This variable indicates the current state of \n the toaster.", - "enum": [ - "up", - "down" - ], - "required": true - } - } - } - } -} diff --git a/restconf/restconf-openapi/src/test/resources/topology-good.json b/restconf/restconf-openapi/src/test/resources/topology-good.json deleted file mode 100644 index 4017829110..0000000000 --- a/restconf/restconf-openapi/src/test/resources/topology-good.json +++ /dev/null @@ -1,106 +0,0 @@ -{ - "apiVersion": "1.0.0", - "swaggerVersion": "1.2", - "basePath": "/api", - "resourcePath": "/config", - "produces": [ "application/json", "application/xml" ], - "apis": [ - { - "path": "/network-topology:network-topology/network-topology", - "operations": [ - { - "method": "GET", - "summary": "Test", - "notes": "", - "type": "Toaster", - "nickname": "something", - "consumes": [ - "application/json", - "application/xml" - ], - "responseMessages": [ - { - "code": 405, - "message": "Invalid input" - } - ] - } - ] - } - ], - "models": { - "Toaster": { - "id":"Toaster", - "$schema": "http://json-schema.org/draft-04/schema", - "description": "Top-level container for all toaster database objects.", - "properties": { - "allow-user": { - "description": "A list of user name patterns to allow", - "items": {"type": "string"}, - "required": false, - "type": "array" - }, - "how": { - "oneOf": [ - { - "manual": {"manual": { - "required": false, - "type": "string" - }}, - "type": "object" - }, - { - "interval": {"interval": { - "required": false, - "type": "integer" - }}, - "type": "object" - }, - { - "daily": { - "daily": { - "required": false, - "type": "string" - }, - "time-of-day": { - "required": false, - "type": "string" - } - }, - "type": "object" - } - ], - "type": "object" - }, - "testToasterBits": { - "enum": [ - "testbit1", - "testbit2" - ], - "minItems": 0, - "required": false, - "type": "String", - "uniqueItems": true - }, - "toasterManufacturer": { - "description": "The name of the toaster's manufacturer. For instance, \n Microsoft Toaster.", - "required": true, - "type": "string" - }, - "toasterModelNumber": { - "description": "The name of the toaster's model. For instance,\n Radiant Automatic.", - "required": true, - "type": "string" - }, - "toasterStatus": { - "description": "This variable indicates the current state of \n the toaster.", - "enum": [ - "up", - "down" - ], - "required": true - } - } - } - } -} \ No newline at end of file diff --git a/restconf/restconf-openapi/src/test/resources/topology-new.json b/restconf/restconf-openapi/src/test/resources/topology-new.json deleted file mode 100644 index c34fd8f5a8..0000000000 --- a/restconf/restconf-openapi/src/test/resources/topology-new.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "apiVersion": "1.0.0", - "swaggerVersion": "1.2", - "basePath": "/restconf", - "resourcePath": "/config", - "produces": [ "application/json", "application/xml" ], - "apis": [ - { - "path": "/network-topology:network-topology/network-topology", - "operations": [ - { - "method": "GET", - "summary": "Test", - "notes": null, - "type": "support", - "nickname": "test", - "consumes": null, - "responseMessages": null - } - ] - } - ], - "models": { - "supporting-link": { - "id":"supporting-link", - "$schema": "http://json-schema.org/draft-04/schema", - "properties": { - "link-ref": { - "required": false - } - }, - "type": "object" - } - } -} \ No newline at end of file diff --git a/restconf/restconf-openapi/src/test/resources/topology.json b/restconf/restconf-openapi/src/test/resources/topology.json deleted file mode 100644 index 8a1a131d95..0000000000 --- a/restconf/restconf-openapi/src/test/resources/topology.json +++ /dev/null @@ -1,730 +0,0 @@ -{ - "apiVersion" : "1.0.0", - "swaggerVersion" : "1.2", - "basePath" : "http://10.195.128.107:8080/restconf", - "resourcePath" : null, - "produces" : [ "application/json", "application/xml" ], - "apis" : [ { - "path" : "/operational/network-topology:network-topology", - "operations" : [ { - "method" : "GET", - "summary" : null, - "notes" : null, - "type" : "network-topology", - "nickname" : "GET-network-topology", - "consumes" : null, - "parameters" : [ ], - "responseMessages" : null - } ] - }, { - "path" : "/operational/network-topology:network-topology/topology/{topology-id}", - "operations" : [ { - "method" : "GET", - "summary" : null, - "notes" : "\n This is the model of an abstract topology.\n A topology contins nodes and links. \n Each topology MUST be identified by\n unique topology-id for reason that a network could contain many\n topologies.\n ", - "type" : "topology", - "nickname" : "GET-topology", - "consumes" : null, - "parameters" : [ { - "name" : "topology-id", - "description" : "\n It is presumed that a datastore will contain many topologies. To\n distinguish between topologies it is vital to have UNIQUE\n topology identifiers.\n ", - "required" : false, - "type" : "string", - "paramType" : "path" - } ], - "responseMessages" : null - } ] - }, { - "path" : "/operational/network-topology:network-topology/topology/{topology-id}/link/{link-id}", - "operations" : [ { - "method" : "GET", - "summary" : null, - "notes" : "\n A Network Link connects a by Local (Source) node and\n a Remote (Destination) Network Nodes via a set of the \n nodes' termination points. \n As it is possible to have several links between the same\n source and destination nodes, and as a link could potentially\n be re-homed between termination points, to ensure that we \n would always know to distinguish between links, every link \n is identified by a dedicated link identifier. \n Note that a link models a point-to-point link, not a multipoint\n link. \n Layering dependencies on links in underlay topologies are\n not represented as the layering information of nodes and of \n termination points is sufficient. \n ", - "type" : "link", - "nickname" : "GET-link", - "consumes" : null, - "parameters" : [ { - "name" : "topology-id", - "description" : "\n It is presumed that a datastore will contain many topologies. To\n distinguish between topologies it is vital to have UNIQUE\n topology identifiers.\n ", - "required" : false, - "type" : "string", - "paramType" : "path" - }, { - "name" : "link-id", - "description" : "The identifier of a link in the topology. \n A link is specific to a topology to which it belongs.", - "required" : false, - "type" : "string", - "paramType" : "path" - } ], - "responseMessages" : null - } ] - }, { - "path" : "/operational/network-topology:network-topology/topology/{topology-id}/link/{link-id}/destination", - "operations" : [ { - "method" : "GET", - "summary" : null, - "notes" : null, - "type" : "destination", - "nickname" : "GET-destination", - "consumes" : null, - "parameters" : [ { - "name" : "topology-id", - "description" : "\n It is presumed that a datastore will contain many topologies. To\n distinguish between topologies it is vital to have UNIQUE\n topology identifiers.\n ", - "required" : false, - "type" : "string", - "paramType" : "path" - }, { - "name" : "link-id", - "description" : "The identifier of a link in the topology. \n A link is specific to a topology to which it belongs.", - "required" : false, - "type" : "string", - "paramType" : "path" - } ], - "responseMessages" : null - } ] - }, { - "path" : "/operational/network-topology:network-topology/topology/{topology-id}/link/{link-id}/destination/dest-node", - "operations" : [ { - "method" : "GET", - "summary" : null, - "notes" : "Destination node identifier, must be in same topology.", - "type" : "dest-node", - "nickname" : "GET-dest-node", - "consumes" : null, - "parameters" : [ { - "name" : "topology-id", - "description" : "\n It is presumed that a datastore will contain many topologies. To\n distinguish between topologies it is vital to have UNIQUE\n topology identifiers.\n ", - "required" : false, - "type" : "string", - "paramType" : "path" - }, { - "name" : "link-id", - "description" : "The identifier of a link in the topology. \n A link is specific to a topology to which it belongs.", - "required" : false, - "type" : "string", - "paramType" : "path" - } ], - "responseMessages" : null - } ] - }, { - "path" : "/operational/network-topology:network-topology/topology/{topology-id}/link/{link-id}/destination/dest-tp", - "operations" : [ { - "method" : "GET", - "summary" : null, - "notes" : "Termination point within destination node that terminates the link.", - "type" : "dest-tp", - "nickname" : "GET-dest-tp", - "consumes" : null, - "parameters" : [ { - "name" : "topology-id", - "description" : "\n It is presumed that a datastore will contain many topologies. To\n distinguish between topologies it is vital to have UNIQUE\n topology identifiers.\n ", - "required" : false, - "type" : "string", - "paramType" : "path" - }, { - "name" : "link-id", - "description" : "The identifier of a link in the topology. \n A link is specific to a topology to which it belongs.", - "required" : false, - "type" : "string", - "paramType" : "path" - } ], - "responseMessages" : null - } ] - }, { - "path" : "/operational/network-topology:network-topology/topology/{topology-id}/link/{link-id}/link-id", - "operations" : [ { - "method" : "GET", - "summary" : null, - "notes" : "The identifier of a link in the topology. \n A link is specific to a topology to which it belongs.", - "type" : "link-id", - "nickname" : "GET-link-id", - "consumes" : null, - "parameters" : [ { - "name" : "topology-id", - "description" : "\n It is presumed that a datastore will contain many topologies. To\n distinguish between topologies it is vital to have UNIQUE\n topology identifiers.\n ", - "required" : false, - "type" : "string", - "paramType" : "path" - }, { - "name" : "link-id", - "description" : "The identifier of a link in the topology. \n A link is specific to a topology to which it belongs.", - "required" : false, - "type" : "string", - "paramType" : "path" - } ], - "responseMessages" : null - } ] - }, { - "path" : "/operational/network-topology:network-topology/topology/{topology-id}/link/{link-id}/source", - "operations" : [ { - "method" : "GET", - "summary" : null, - "notes" : null, - "type" : "source", - "nickname" : "GET-source", - "consumes" : null, - "parameters" : [ { - "name" : "topology-id", - "description" : "\n It is presumed that a datastore will contain many topologies. To\n distinguish between topologies it is vital to have UNIQUE\n topology identifiers.\n ", - "required" : false, - "type" : "string", - "paramType" : "path" - }, { - "name" : "link-id", - "description" : "The identifier of a link in the topology. \n A link is specific to a topology to which it belongs.", - "required" : false, - "type" : "string", - "paramType" : "path" - } ], - "responseMessages" : null - } ] - }, { - "path" : "/operational/network-topology:network-topology/topology/{topology-id}/link/{link-id}/source/source-node", - "operations" : [ { - "method" : "GET", - "summary" : null, - "notes" : "Source node identifier, must be in same topology.", - "type" : "source-node", - "nickname" : "GET-source-node", - "consumes" : null, - "parameters" : [ { - "name" : "topology-id", - "description" : "\n It is presumed that a datastore will contain many topologies. To\n distinguish between topologies it is vital to have UNIQUE\n topology identifiers.\n ", - "required" : false, - "type" : "string", - "paramType" : "path" - }, { - "name" : "link-id", - "description" : "The identifier of a link in the topology. \n A link is specific to a topology to which it belongs.", - "required" : false, - "type" : "string", - "paramType" : "path" - } ], - "responseMessages" : null - } ] - }, { - "path" : "/operational/network-topology:network-topology/topology/{topology-id}/link/{link-id}/source/source-tp", - "operations" : [ { - "method" : "GET", - "summary" : null, - "notes" : "Termination point within source node that terminates the link.", - "type" : "source-tp", - "nickname" : "GET-source-tp", - "consumes" : null, - "parameters" : [ { - "name" : "topology-id", - "description" : "\n It is presumed that a datastore will contain many topologies. To\n distinguish between topologies it is vital to have UNIQUE\n topology identifiers.\n ", - "required" : false, - "type" : "string", - "paramType" : "path" - }, { - "name" : "link-id", - "description" : "The identifier of a link in the topology. \n A link is specific to a topology to which it belongs.", - "required" : false, - "type" : "string", - "paramType" : "path" - } ], - "responseMessages" : null - } ] - }, { - "path" : "/operational/network-topology:network-topology/topology/{topology-id}/link/{link-id}/supporting-link/{link-ref}", - "operations" : [ { - "method" : "GET", - "summary" : null, - "notes" : null, - "type" : "supporting-link", - "nickname" : "GET-supporting-link", - "consumes" : null, - "parameters" : [ { - "name" : "topology-id", - "description" : "\n It is presumed that a datastore will contain many topologies. To\n distinguish between topologies it is vital to have UNIQUE\n topology identifiers.\n ", - "required" : false, - "type" : "string", - "paramType" : "path" - }, { - "name" : "link-id", - "description" : "The identifier of a link in the topology. \n A link is specific to a topology to which it belongs.", - "required" : false, - "type" : "string", - "paramType" : "path" - }, { - "name" : "link-ref", - "description" : null, - "required" : false, - "type" : "string", - "paramType" : "path" - } ], - "responseMessages" : null - } ] - }, { - "path" : "/operational/network-topology:network-topology/topology/{topology-id}/link/{link-id}/supporting-link/{link-ref}/link-ref", - "operations" : [ { - "method" : "GET", - "summary" : null, - "notes" : null, - "type" : "link-ref", - "nickname" : "GET-link-ref", - "consumes" : null, - "parameters" : [ { - "name" : "topology-id", - "description" : "\n It is presumed that a datastore will contain many topologies. To\n distinguish between topologies it is vital to have UNIQUE\n topology identifiers.\n ", - "required" : false, - "type" : "string", - "paramType" : "path" - }, { - "name" : "link-id", - "description" : "The identifier of a link in the topology. \n A link is specific to a topology to which it belongs.", - "required" : false, - "type" : "string", - "paramType" : "path" - }, { - "name" : "link-ref", - "description" : null, - "required" : false, - "type" : "string", - "paramType" : "path" - } ], - "responseMessages" : null - } ] - }, { - "path" : "/operational/network-topology:network-topology/topology/{topology-id}/node/{node-id}", - "operations" : [ { - "method" : "GET", - "summary" : null, - "notes" : "The list of network nodes defined for the topology.", - "type" : "node", - "nickname" : "GET-node", - "consumes" : null, - "parameters" : [ { - "name" : "topology-id", - "description" : "\n It is presumed that a datastore will contain many topologies. To\n distinguish between topologies it is vital to have UNIQUE\n topology identifiers.\n ", - "required" : false, - "type" : "string", - "paramType" : "path" - }, { - "name" : "node-id", - "description" : "The identifier of a node in the topology. \n A node is specific to a topology to which it belongs.", - "required" : false, - "type" : "string", - "paramType" : "path" - } ], - "responseMessages" : null - } ] - }, { - "path" : "/operational/network-topology:network-topology/topology/{topology-id}/node/{node-id}/node-id", - "operations" : [ { - "method" : "GET", - "summary" : null, - "notes" : "The identifier of a node in the topology. \n A node is specific to a topology to which it belongs.", - "type" : "node-id", - "nickname" : "GET-node-id", - "consumes" : null, - "parameters" : [ { - "name" : "topology-id", - "description" : "\n It is presumed that a datastore will contain many topologies. To\n distinguish between topologies it is vital to have UNIQUE\n topology identifiers.\n ", - "required" : false, - "type" : "string", - "paramType" : "path" - }, { - "name" : "node-id", - "description" : "The identifier of a node in the topology. \n A node is specific to a topology to which it belongs.", - "required" : false, - "type" : "string", - "paramType" : "path" - } ], - "responseMessages" : null - } ] - }, { - "path" : "/operational/network-topology:network-topology/topology/{topology-id}/node/{node-id}/supporting-node/{node-ref}", - "operations" : [ { - "method" : "GET", - "summary" : null, - "notes" : "This list defines vertical layering information for nodes. \n It allows to capture for any given node, which node (or nodes)\n in the corresponding underlay topology it maps onto. \n A node can map to zero, one, or more nodes below it;\n accordingly there can be zero, one, or more elements in the list.\n If there are specific layering requirements, for example\n specific to a particular type of topology that only allows\n for certain layering relationships, the choice\n below can be augmented with additional cases.\n A list has been chosen rather than a leaf-list in order \n to provide room for augmentations, e.g. for \n statistics or priorization information associated with \n supporting nodes.", - "type" : "supporting-node", - "nickname" : "GET-supporting-node", - "consumes" : null, - "parameters" : [ { - "name" : "topology-id", - "description" : "\n It is presumed that a datastore will contain many topologies. To\n distinguish between topologies it is vital to have UNIQUE\n topology identifiers.\n ", - "required" : false, - "type" : "string", - "paramType" : "path" - }, { - "name" : "node-id", - "description" : "The identifier of a node in the topology. \n A node is specific to a topology to which it belongs.", - "required" : false, - "type" : "string", - "paramType" : "path" - }, { - "name" : "node-ref", - "description" : null, - "required" : false, - "type" : "string", - "paramType" : "path" - } ], - "responseMessages" : null - } ] - }, { - "path" : "/operational/network-topology:network-topology/topology/{topology-id}/node/{node-id}/supporting-node/{node-ref}/node-ref", - "operations" : [ { - "method" : "GET", - "summary" : null, - "notes" : null, - "type" : "node-ref", - "nickname" : "GET-node-ref", - "consumes" : null, - "parameters" : [ { - "name" : "topology-id", - "description" : "\n It is presumed that a datastore will contain many topologies. To\n distinguish between topologies it is vital to have UNIQUE\n topology identifiers.\n ", - "required" : false, - "type" : "string", - "paramType" : "path" - }, { - "name" : "node-id", - "description" : "The identifier of a node in the topology. \n A node is specific to a topology to which it belongs.", - "required" : false, - "type" : "string", - "paramType" : "path" - }, { - "name" : "node-ref", - "description" : null, - "required" : false, - "type" : "string", - "paramType" : "path" - } ], - "responseMessages" : null - } ] - }, { - "path" : "/operational/network-topology:network-topology/topology/{topology-id}/node/{node-id}/termination-point/{tp-id}", - "operations" : [ { - "method" : "GET", - "summary" : null, - "notes" : "A termination point can terminate a link. \n Depending on the type of topology, a termination point could, \n for example, refer to a port or an interface.", - "type" : "termination-point", - "nickname" : "GET-termination-point", - "consumes" : null, - "parameters" : [ { - "name" : "topology-id", - "description" : "\n It is presumed that a datastore will contain many topologies. To\n distinguish between topologies it is vital to have UNIQUE\n topology identifiers.\n ", - "required" : false, - "type" : "string", - "paramType" : "path" - }, { - "name" : "node-id", - "description" : "The identifier of a node in the topology. \n A node is specific to a topology to which it belongs.", - "required" : false, - "type" : "string", - "paramType" : "path" - }, { - "name" : "tp-id", - "description" : null, - "required" : false, - "type" : "string", - "paramType" : "path" - } ], - "responseMessages" : null - } ] - }, { - "path" : "/operational/network-topology:network-topology/topology/{topology-id}/node/{node-id}/termination-point/{tp-id}/tp-id", - "operations" : [ { - "method" : "GET", - "summary" : null, - "notes" : null, - "type" : "tp-id", - "nickname" : "GET-tp-id", - "consumes" : null, - "parameters" : [ { - "name" : "topology-id", - "description" : "\n It is presumed that a datastore will contain many topologies. To\n distinguish between topologies it is vital to have UNIQUE\n topology identifiers.\n ", - "required" : false, - "type" : "string", - "paramType" : "path" - }, { - "name" : "node-id", - "description" : "The identifier of a node in the topology. \n A node is specific to a topology to which it belongs.", - "required" : false, - "type" : "string", - "paramType" : "path" - }, { - "name" : "tp-id", - "description" : null, - "required" : false, - "type" : "string", - "paramType" : "path" - } ], - "responseMessages" : null - } ] - }, { - "path" : "/operational/network-topology:network-topology/topology/{topology-id}/node/{node-id}/termination-point/{tp-id}/tp-ref", - "operations" : [ { - "method" : "GET", - "summary" : null, - "notes" : "The leaf list identifies any termination points that the \n termination point is dependent on, or maps onto. \n Those termination points will themselves be contained \n in a supporting node. \n This dependency information can be inferred from \n the dependencies between links. For this reason, \n this item is not separately configurable. Hence no\n corresponding constraint needs to be articulated. \n The corresponding information is simply provided by the\n implementing system.", - "type" : "tp-ref", - "nickname" : "GET-tp-ref", - "consumes" : null, - "parameters" : [ { - "name" : "topology-id", - "description" : "\n It is presumed that a datastore will contain many topologies. To\n distinguish between topologies it is vital to have UNIQUE\n topology identifiers.\n ", - "required" : false, - "type" : "string", - "paramType" : "path" - }, { - "name" : "node-id", - "description" : "The identifier of a node in the topology. \n A node is specific to a topology to which it belongs.", - "required" : false, - "type" : "string", - "paramType" : "path" - }, { - "name" : "tp-id", - "description" : null, - "required" : false, - "type" : "string", - "paramType" : "path" - } ], - "responseMessages" : null - } ] - }, { - "path" : "/operational/network-topology:network-topology/topology/{topology-id}/topology-id", - "operations" : [ { - "method" : "GET", - "summary" : null, - "notes" : "\n It is presumed that a datastore will contain many topologies. To\n distinguish between topologies it is vital to have UNIQUE\n topology identifiers.\n ", - "type" : "topology-id", - "nickname" : "GET-topology-id", - "consumes" : null, - "parameters" : [ { - "name" : "topology-id", - "description" : "\n It is presumed that a datastore will contain many topologies. To\n distinguish between topologies it is vital to have UNIQUE\n topology identifiers.\n ", - "required" : false, - "type" : "string", - "paramType" : "path" - } ], - "responseMessages" : null - } ] - }, { - "path" : "/operational/network-topology:network-topology/topology/{topology-id}/topology-types", - "operations" : [ { - "method" : "GET", - "summary" : null, - "notes" : "This container is used to identify the type, or types \n (as a topology can support several types simultaneously), \n of the topology. \n Topology types are the subject of several integrity constraints \n that an implementing server can validate in order to \n maintain integrity of the datastore. \n Topology types are indicated through separate data nodes; \n the set of topology types is expected to increase over time.\n To add support for a new topology, an augmenting module\n needs to augment this container with a new empty optional \n container to indicate the new topology type. \n The use of a container allows to indicate a subcategorization\n of topology types. \n The container SHALL NOT be augmented with any data nodes \n that serve a purpose other than identifying a particular \n topology type. \n ", - "type" : "topology-types", - "nickname" : "GET-topology-types", - "consumes" : null, - "parameters" : [ { - "name" : "topology-id", - "description" : "\n It is presumed that a datastore will contain many topologies. To\n distinguish between topologies it is vital to have UNIQUE\n topology identifiers.\n ", - "required" : false, - "type" : "string", - "paramType" : "path" - } ], - "responseMessages" : null - } ] - }, { - "path" : "/operational/network-topology:network-topology/topology/{topology-id}/underlay-topology/{topology-ref}", - "operations" : [ { - "method" : "GET", - "summary" : null, - "notes" : "Identifies the topology, or topologies, that this topology\n is dependent on.", - "type" : "underlay-topology", - "nickname" : "GET-underlay-topology", - "consumes" : null, - "parameters" : [ { - "name" : "topology-id", - "description" : "\n It is presumed that a datastore will contain many topologies. To\n distinguish between topologies it is vital to have UNIQUE\n topology identifiers.\n ", - "required" : false, - "type" : "string", - "paramType" : "path" - }, { - "name" : "topology-ref", - "description" : null, - "required" : false, - "type" : "string", - "paramType" : "path" - } ], - "responseMessages" : null - } ] - }, { - "path" : "/operational/network-topology:network-topology/topology/{topology-id}/underlay-topology/{topology-ref}/topology-ref", - "operations" : [ { - "method" : "GET", - "summary" : null, - "notes" : null, - "type" : "topology-ref", - "nickname" : "GET-topology-ref", - "consumes" : null, - "parameters" : [ { - "name" : "topology-id", - "description" : "\n It is presumed that a datastore will contain many topologies. To\n distinguish between topologies it is vital to have UNIQUE\n topology identifiers.\n ", - "required" : false, - "type" : "string", - "paramType" : "path" - }, { - "name" : "topology-ref", - "description" : null, - "required" : false, - "type" : "string", - "paramType" : "path" - } ], - "responseMessages" : null - } ] - } ], - "models" : { - "underlay-topology" : { - "id" : "underlay-topology", - "$schema" : "http://json-schema.org/draft-04/schema", - "properties" : { - "topology-ref" : { - "required" : false - } - }, - "type" : "object" - }, - "network-topology" : "{\n \"id\": \"network-topology\",\n \"$schema\": \"http://json-schema.org/draft-04/schema\",\n \"properties\": {\"topology\": {\n \"items\": {\"$ref\": \"topology\"},\n \"description\": \"\\n This is the model of an abstract topology.\\n A topology contins nodes and links. \\n Each topology MUST be identified by\\n unique topology-id for reason that a network could contain many\\n topologies.\\n \",\n \"type\": \"array\"\n }},\n \"type\": \"object\"\n}", - "node" : { - "id" : "node", - "$schema" : "http://json-schema.org/draft-04/schema", - "properties" : { - "supporting-node" : { - "items" : { - "$ref" : "supporting-node" - }, - "description" : "This list defines vertical layering information for nodes. \n It allows to capture for any given node, which node (or nodes)\n in the corresponding underlay topology it maps onto. \n A node can map to zero, one, or more nodes below it;\n accordingly there can be zero, one, or more elements in the list.\n If there are specific layering requirements, for example\n specific to a particular type of topology that only allows\n for certain layering relationships, the choice\n below can be augmented with additional cases.\n A list has been chosen rather than a leaf-list in order \n to provide room for augmentations, e.g. for \n statistics or priorization information associated with \n supporting nodes.", - "type" : "array" - }, - "termination-point" : { - "items" : { - "$ref" : "termination-point" - }, - "description" : "A termination point can terminate a link. \n Depending on the type of topology, a termination point could, \n for example, refer to a port or an interface.", - "type" : "array" - }, - "node-id" : { - "description" : "The identifier of a node in the topology. \n A node is specific to a topology to which it belongs.", - "type" : "string", - "required" : false - } - }, - "type" : "object" - }, - "supporting-node" : { - "id" : "supporting-node", - "$schema" : "http://json-schema.org/draft-04/schema", - "properties" : { - "node-ref" : { - "required" : false - } - }, - "type" : "object" - }, - "link" : { - "id" : "link", - "$schema" : "http://json-schema.org/draft-04/schema", - "properties" : { - "source" : { - "properties" : { - "source-node" : { - "description" : "Source node identifier, must be in same topology.", - "required" : true - }, - "source-tp" : { - "description" : "Termination point within source node that terminates the link.", - "required" : false - } - }, - "type" : "object" - }, - "supporting-link" : { - "items" : { - "$ref" : "supporting-link" - }, - "type" : "array" - }, - "link-id" : { - "description" : "The identifier of a link in the topology. \n A link is specific to a topology to which it belongs.", - "type" : "string", - "required" : false - }, - "destination" : { - "properties" : { - "dest-node" : { - "description" : "Destination node identifier, must be in same topology.", - "required" : true - }, - "dest-tp" : { - "description" : "Termination point within destination node that terminates the link.", - "required" : false - } - }, - "type" : "object" - } - }, - "type" : "object" - }, - "termination-point" : { - "id" : "termination-point", - "$schema" : "http://json-schema.org/draft-04/schema", - "properties" : { - "tp-ref" : { - "items" : { }, - "description" : "The leaf list identifies any termination points that the \n termination point is dependent on, or maps onto. \n Those termination points will themselves be contained \n in a supporting node. \n This dependency information can be inferred from \n the dependencies between links. For this reason, \n this item is not separately configurable. Hence no\n corresponding constraint needs to be articulated. \n The corresponding information is simply provided by the\n implementing system.", - "required" : false, - "type" : "array" - }, - "tp-id" : { - "type" : "string", - "required" : false - } - }, - "type" : "object" - }, - "topology" : { - "id" : "topology", - "$schema" : "http://json-schema.org/draft-04/schema", - "properties" : { - "underlay-topology" : { - "items" : { - "$ref" : "underlay-topology" - }, - "description" : "Identifies the topology, or topologies, that this topology\n is dependent on.", - "type" : "array" - }, - "node" : { - "items" : { - "$ref" : "node" - }, - "description" : "The list of network nodes defined for the topology.", - "type" : "array" - }, - "topology-types" : { - "description" : "This container is used to identify the type, or types \n (as a topology can support several types simultaneously), \n of the topology. \n Topology types are the subject of several integrity constraints \n that an implementing server can validate in order to \n maintain integrity of the datastore. \n Topology types are indicated through separate data nodes; \n the set of topology types is expected to increase over time.\n To add support for a new topology, an augmenting module\n needs to augment this container with a new empty optional \n container to indicate the new topology type. \n The use of a container allows to indicate a subcategorization\n of topology types. \n The container SHALL NOT be augmented with any data nodes \n that serve a purpose other than identifying a particular \n topology type. \n ", - "properties" : { }, - "type" : "object" - }, - "topology-id" : { - "description" : "\n It is presumed that a datastore will contain many topologies. To\n distinguish between topologies it is vital to have UNIQUE\n topology identifiers.\n ", - "type" : "string", - "required" : false - }, - "link" : { - "items" : { - "$ref" : "link" - }, - "description" : "\n A Network Link connects a by Local (Source) node and\n a Remote (Destination) Network Nodes via a set of the \n nodes' termination points. \n As it is possible to have several links between the same\n source and destination nodes, and as a link could potentially\n be re-homed between termination points, to ensure that we \n would always know to distinguish between links, every link \n is identified by a dedicated link identifier. \n Note that a link models a point-to-point link, not a multipoint\n link. \n Layering dependencies on links in underlay topologies are\n not represented as the layering information of nodes and of \n termination points is sufficient. \n ", - "type" : "array" - } - }, - "type" : "object" - }, - "supporting-link" : { - "id" : "supporting-link", - "$schema" : "http://json-schema.org/draft-04/schema", - "properties" : { - "link-ref" : { - "required" : false - } - }, - "type" : "object" - } - } -} diff --git a/restconf/restconf-openapi/src/test/resources/wadl.xml b/restconf/restconf-openapi/src/test/resources/wadl.xml deleted file mode 100644 index 7c3488f620..0000000000 --- a/restconf/restconf-openapi/src/test/resources/wadl.xml +++ /dev/null @@ -1,142 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/restconf/restconf-openapi/src/test/resources/yang-document/controller-action-types.json b/restconf/restconf-openapi/src/test/resources/yang-document/controller-action-types.json index ac74c976ed..8a763831b6 100644 --- a/restconf/restconf-openapi/src/test/resources/yang-document/controller-action-types.json +++ b/restconf/restconf-openapi/src/test/resources/yang-document/controller-action-types.json @@ -3,7 +3,7 @@ "info": { "version": "1.0.0", "title": "action-types", - "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That’s because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." + "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That is because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." }, "servers": [ { diff --git a/restconf/restconf-openapi/src/test/resources/yang-document/controller-all.json b/restconf/restconf-openapi/src/test/resources/yang-document/controller-all.json index bc8af19059..18db81428c 100644 --- a/restconf/restconf-openapi/src/test/resources/yang-document/controller-all.json +++ b/restconf/restconf-openapi/src/test/resources/yang-document/controller-all.json @@ -3,7 +3,7 @@ "info": { "version": "1.0.0", "title": "Controller modules of RESTCONF", - "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That’s because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." + "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That is because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." }, "servers": [ { diff --git a/restconf/restconf-openapi/src/test/resources/yang-document/controller-choice-test.json b/restconf/restconf-openapi/src/test/resources/yang-document/controller-choice-test.json index 4c28ff9234..9b52fb1e21 100644 --- a/restconf/restconf-openapi/src/test/resources/yang-document/controller-choice-test.json +++ b/restconf/restconf-openapi/src/test/resources/yang-document/controller-choice-test.json @@ -3,7 +3,7 @@ "info": { "version": "1.0.0", "title": "choice-test", - "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That’s because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." + "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That is because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." }, "servers": [ { diff --git a/restconf/restconf-openapi/src/test/resources/yang-document/controller-definition-test.json b/restconf/restconf-openapi/src/test/resources/yang-document/controller-definition-test.json index d16cd6dd59..9157d85a22 100644 --- a/restconf/restconf-openapi/src/test/resources/yang-document/controller-definition-test.json +++ b/restconf/restconf-openapi/src/test/resources/yang-document/controller-definition-test.json @@ -3,7 +3,7 @@ "info": { "version": "1.0.0", "title": "definition-test", - "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That’s because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." + "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That is because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." }, "servers": [ { diff --git a/restconf/restconf-openapi/src/test/resources/yang-document/controller-mandatory-test.json b/restconf/restconf-openapi/src/test/resources/yang-document/controller-mandatory-test.json index 2ec31b4ae3..852fb2acc8 100644 --- a/restconf/restconf-openapi/src/test/resources/yang-document/controller-mandatory-test.json +++ b/restconf/restconf-openapi/src/test/resources/yang-document/controller-mandatory-test.json @@ -3,7 +3,7 @@ "info": { "version": "1.0.0", "title": "mandatory-test", - "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That’s because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." + "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That is because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." }, "servers": [ { diff --git a/restconf/restconf-openapi/src/test/resources/yang-document/controller-my-yang.json b/restconf/restconf-openapi/src/test/resources/yang-document/controller-my-yang.json index d067e2611b..6be3930cd8 100644 --- a/restconf/restconf-openapi/src/test/resources/yang-document/controller-my-yang.json +++ b/restconf/restconf-openapi/src/test/resources/yang-document/controller-my-yang.json @@ -3,7 +3,7 @@ "info": { "version": "1.0.0", "title": "my-yang", - "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That’s because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." + "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That is because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." }, "servers": [ { diff --git a/restconf/restconf-openapi/src/test/resources/yang-document/controller-opflex.json b/restconf/restconf-openapi/src/test/resources/yang-document/controller-opflex.json index 492bc77bd4..a2c579275c 100644 --- a/restconf/restconf-openapi/src/test/resources/yang-document/controller-opflex.json +++ b/restconf/restconf-openapi/src/test/resources/yang-document/controller-opflex.json @@ -3,7 +3,7 @@ "info": { "version": "1.0.0", "title": "opflex", - "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That’s because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." + "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That is because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." }, "servers": [ { diff --git a/restconf/restconf-openapi/src/test/resources/yang-document/controller-path-params-test.json b/restconf/restconf-openapi/src/test/resources/yang-document/controller-path-params-test.json index a6a868231d..17be0d5336 100644 --- a/restconf/restconf-openapi/src/test/resources/yang-document/controller-path-params-test.json +++ b/restconf/restconf-openapi/src/test/resources/yang-document/controller-path-params-test.json @@ -3,7 +3,7 @@ "info": { "version": "1.0.0", "title": "path-params-test", - "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That’s because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." + "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That is because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." }, "servers": [ { diff --git a/restconf/restconf-openapi/src/test/resources/yang-document/controller-recursive.json b/restconf/restconf-openapi/src/test/resources/yang-document/controller-recursive.json index 93b66f7f55..80e77f989e 100644 --- a/restconf/restconf-openapi/src/test/resources/yang-document/controller-recursive.json +++ b/restconf/restconf-openapi/src/test/resources/yang-document/controller-recursive.json @@ -3,7 +3,7 @@ "info": { "version": "1.0.0", "title": "recursive", - "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That’s because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." + "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That is because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." }, "servers": [ { diff --git a/restconf/restconf-openapi/src/test/resources/yang-document/controller-string-from-regex.json b/restconf/restconf-openapi/src/test/resources/yang-document/controller-string-from-regex.json index 9572222ae2..35f76cb3ed 100644 --- a/restconf/restconf-openapi/src/test/resources/yang-document/controller-string-from-regex.json +++ b/restconf/restconf-openapi/src/test/resources/yang-document/controller-string-from-regex.json @@ -3,7 +3,7 @@ "info": { "version": "1.0.0", "title": "strings-from-regex", - "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That’s because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." + "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That is because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." }, "servers": [ { diff --git a/restconf/restconf-openapi/src/test/resources/yang-document/controller-string-types.json b/restconf/restconf-openapi/src/test/resources/yang-document/controller-string-types.json index 6561565c50..9cc2303e52 100644 --- a/restconf/restconf-openapi/src/test/resources/yang-document/controller-string-types.json +++ b/restconf/restconf-openapi/src/test/resources/yang-document/controller-string-types.json @@ -3,7 +3,7 @@ "info": { "version": "1.0.0", "title": "string-types", - "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That’s because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." + "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That is because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." }, "servers": [ { diff --git a/restconf/restconf-openapi/src/test/resources/yang-document/controller-test-container-childs.json b/restconf/restconf-openapi/src/test/resources/yang-document/controller-test-container-childs.json index 398a18fab4..15647d847f 100644 --- a/restconf/restconf-openapi/src/test/resources/yang-document/controller-test-container-childs.json +++ b/restconf/restconf-openapi/src/test/resources/yang-document/controller-test-container-childs.json @@ -3,7 +3,7 @@ "info": { "version": "1.0.0", "title": "test-container-childs", - "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That’s because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." + "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That is because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." }, "servers": [ { diff --git a/restconf/restconf-openapi/src/test/resources/yang-document/controller-toaster-augmented.json b/restconf/restconf-openapi/src/test/resources/yang-document/controller-toaster-augmented.json index 4cf79d6487..d4b8bf7b90 100644 --- a/restconf/restconf-openapi/src/test/resources/yang-document/controller-toaster-augmented.json +++ b/restconf/restconf-openapi/src/test/resources/yang-document/controller-toaster-augmented.json @@ -3,7 +3,7 @@ "info": { "version": "1.0.0", "title": "toaster-augmented", - "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That’s because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." + "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That is because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." }, "servers": [ { diff --git a/restconf/restconf-openapi/src/test/resources/yang-document/controller-toaster.json b/restconf/restconf-openapi/src/test/resources/yang-document/controller-toaster.json index a025d7cd81..23f1ebf3e5 100644 --- a/restconf/restconf-openapi/src/test/resources/yang-document/controller-toaster.json +++ b/restconf/restconf-openapi/src/test/resources/yang-document/controller-toaster.json @@ -3,7 +3,7 @@ "info": { "version": "1.0.0", "title": "toaster", - "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That’s because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." + "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That is because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." }, "servers": [ { diff --git a/restconf/restconf-openapi/src/test/resources/yang-document/controller-toaster2.json b/restconf/restconf-openapi/src/test/resources/yang-document/controller-toaster2.json index d88f17008d..ce1ce929c7 100644 --- a/restconf/restconf-openapi/src/test/resources/yang-document/controller-toaster2.json +++ b/restconf/restconf-openapi/src/test/resources/yang-document/controller-toaster2.json @@ -3,7 +3,7 @@ "info": { "version": "1.0.0", "title": "toaster2", - "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That’s because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." + "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That is because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." }, "servers": [ { diff --git a/restconf/restconf-openapi/src/test/resources/yang-document/controller-typed-params.json b/restconf/restconf-openapi/src/test/resources/yang-document/controller-typed-params.json index 7f1d2d57c0..18023ed251 100644 --- a/restconf/restconf-openapi/src/test/resources/yang-document/controller-typed-params.json +++ b/restconf/restconf-openapi/src/test/resources/yang-document/controller-typed-params.json @@ -3,7 +3,7 @@ "info": { "version": "1.0.0", "title": "typed-params", - "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That’s because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." + "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That is because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." }, "servers": [ { diff --git a/restconf/restconf-openapi/src/test/resources/yang-document/device-action-types.json b/restconf/restconf-openapi/src/test/resources/yang-document/device-action-types.json index 2e1b3bef9a..6a1430c259 100644 --- a/restconf/restconf-openapi/src/test/resources/yang-document/device-action-types.json +++ b/restconf/restconf-openapi/src/test/resources/yang-document/device-action-types.json @@ -3,7 +3,7 @@ "info": { "version": "1.0.0", "title": "action-types", - "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That’s because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." + "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That is because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." }, "servers": [ { diff --git a/restconf/restconf-openapi/src/test/resources/yang-document/device-all.json b/restconf/restconf-openapi/src/test/resources/yang-document/device-all.json index 8c3d50ef22..172138ef1e 100644 --- a/restconf/restconf-openapi/src/test/resources/yang-document/device-all.json +++ b/restconf/restconf-openapi/src/test/resources/yang-document/device-all.json @@ -3,7 +3,7 @@ "info": { "version": "1.0.0", "title": "123 modules of RESTCONF", - "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That’s because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." + "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That is because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." }, "servers": [ { diff --git a/restconf/restconf-openapi/src/test/resources/yang-document/device-choice-test.json b/restconf/restconf-openapi/src/test/resources/yang-document/device-choice-test.json index 51f2c2a543..57116b0eec 100644 --- a/restconf/restconf-openapi/src/test/resources/yang-document/device-choice-test.json +++ b/restconf/restconf-openapi/src/test/resources/yang-document/device-choice-test.json @@ -3,7 +3,7 @@ "info": { "version": "1.0.0", "title": "choice-test", - "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That’s because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." + "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That is because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." }, "servers": [ { diff --git a/restconf/restconf-openapi/src/test/resources/yang-document/device-definition-test.json b/restconf/restconf-openapi/src/test/resources/yang-document/device-definition-test.json index 5d59dc6252..8c7acfc6a9 100644 --- a/restconf/restconf-openapi/src/test/resources/yang-document/device-definition-test.json +++ b/restconf/restconf-openapi/src/test/resources/yang-document/device-definition-test.json @@ -3,7 +3,7 @@ "info": { "version": "1.0.0", "title": "definition-test", - "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That’s because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." + "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That is because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." }, "servers": [ { diff --git a/restconf/restconf-openapi/src/test/resources/yang-document/device-mandatory-test.json b/restconf/restconf-openapi/src/test/resources/yang-document/device-mandatory-test.json index 3a788f7d20..63664f2d6d 100644 --- a/restconf/restconf-openapi/src/test/resources/yang-document/device-mandatory-test.json +++ b/restconf/restconf-openapi/src/test/resources/yang-document/device-mandatory-test.json @@ -3,7 +3,7 @@ "info": { "version": "1.0.0", "title": "mandatory-test", - "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That’s because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." + "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That is because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." }, "servers": [ { diff --git a/restconf/restconf-openapi/src/test/resources/yang-document/device-my-yang.json b/restconf/restconf-openapi/src/test/resources/yang-document/device-my-yang.json index 47cb8f87d8..d5e1462575 100644 --- a/restconf/restconf-openapi/src/test/resources/yang-document/device-my-yang.json +++ b/restconf/restconf-openapi/src/test/resources/yang-document/device-my-yang.json @@ -3,7 +3,7 @@ "info": { "version": "1.0.0", "title": "my-yang", - "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That’s because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." + "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That is because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." }, "servers": [ { diff --git a/restconf/restconf-openapi/src/test/resources/yang-document/device-opflex.json b/restconf/restconf-openapi/src/test/resources/yang-document/device-opflex.json index 492bc77bd4..a2c579275c 100644 --- a/restconf/restconf-openapi/src/test/resources/yang-document/device-opflex.json +++ b/restconf/restconf-openapi/src/test/resources/yang-document/device-opflex.json @@ -3,7 +3,7 @@ "info": { "version": "1.0.0", "title": "opflex", - "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That’s because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." + "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That is because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." }, "servers": [ { diff --git a/restconf/restconf-openapi/src/test/resources/yang-document/device-path-params-test.json b/restconf/restconf-openapi/src/test/resources/yang-document/device-path-params-test.json index f6fc795d5b..e814441e0e 100644 --- a/restconf/restconf-openapi/src/test/resources/yang-document/device-path-params-test.json +++ b/restconf/restconf-openapi/src/test/resources/yang-document/device-path-params-test.json @@ -3,7 +3,7 @@ "info": { "version": "1.0.0", "title": "path-params-test", - "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That’s because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." + "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That is because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." }, "servers": [ { diff --git a/restconf/restconf-openapi/src/test/resources/yang-document/device-recursive.json b/restconf/restconf-openapi/src/test/resources/yang-document/device-recursive.json index 943f948d43..e133f06d35 100644 --- a/restconf/restconf-openapi/src/test/resources/yang-document/device-recursive.json +++ b/restconf/restconf-openapi/src/test/resources/yang-document/device-recursive.json @@ -3,7 +3,7 @@ "info": { "version": "1.0.0", "title": "recursive", - "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That’s because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." + "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That is because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." }, "servers": [ { diff --git a/restconf/restconf-openapi/src/test/resources/yang-document/device-string-from-regex.json b/restconf/restconf-openapi/src/test/resources/yang-document/device-string-from-regex.json index 6df0a4ca7e..0214953dfe 100644 --- a/restconf/restconf-openapi/src/test/resources/yang-document/device-string-from-regex.json +++ b/restconf/restconf-openapi/src/test/resources/yang-document/device-string-from-regex.json @@ -3,7 +3,7 @@ "info": { "version": "1.0.0", "title": "strings-from-regex", - "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That’s because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." + "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That is because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." }, "servers": [ { diff --git a/restconf/restconf-openapi/src/test/resources/yang-document/device-string-types.json b/restconf/restconf-openapi/src/test/resources/yang-document/device-string-types.json index e965dc09ec..feeb544e80 100644 --- a/restconf/restconf-openapi/src/test/resources/yang-document/device-string-types.json +++ b/restconf/restconf-openapi/src/test/resources/yang-document/device-string-types.json @@ -3,7 +3,7 @@ "info": { "version": "1.0.0", "title": "string-types", - "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That’s because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." + "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That is because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." }, "servers": [ { diff --git a/restconf/restconf-openapi/src/test/resources/yang-document/device-test-container-childs.json b/restconf/restconf-openapi/src/test/resources/yang-document/device-test-container-childs.json index 793b8fb15c..009de986e9 100644 --- a/restconf/restconf-openapi/src/test/resources/yang-document/device-test-container-childs.json +++ b/restconf/restconf-openapi/src/test/resources/yang-document/device-test-container-childs.json @@ -3,7 +3,7 @@ "info": { "version": "1.0.0", "title": "test-container-childs", - "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That’s because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." + "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That is because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." }, "servers": [ { diff --git a/restconf/restconf-openapi/src/test/resources/yang-document/device-toaster-augmented.json b/restconf/restconf-openapi/src/test/resources/yang-document/device-toaster-augmented.json index 4cf79d6487..d4b8bf7b90 100644 --- a/restconf/restconf-openapi/src/test/resources/yang-document/device-toaster-augmented.json +++ b/restconf/restconf-openapi/src/test/resources/yang-document/device-toaster-augmented.json @@ -3,7 +3,7 @@ "info": { "version": "1.0.0", "title": "toaster-augmented", - "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That’s because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." + "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That is because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." }, "servers": [ { diff --git a/restconf/restconf-openapi/src/test/resources/yang-document/device-toaster.json b/restconf/restconf-openapi/src/test/resources/yang-document/device-toaster.json index 678ae379e8..545251d3f0 100644 --- a/restconf/restconf-openapi/src/test/resources/yang-document/device-toaster.json +++ b/restconf/restconf-openapi/src/test/resources/yang-document/device-toaster.json @@ -3,7 +3,7 @@ "info": { "version": "1.0.0", "title": "toaster", - "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That’s because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." + "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That is because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." }, "servers": [ { diff --git a/restconf/restconf-openapi/src/test/resources/yang-document/device-toaster2.json b/restconf/restconf-openapi/src/test/resources/yang-document/device-toaster2.json index 1b95255a03..d5afc361e1 100644 --- a/restconf/restconf-openapi/src/test/resources/yang-document/device-toaster2.json +++ b/restconf/restconf-openapi/src/test/resources/yang-document/device-toaster2.json @@ -3,7 +3,7 @@ "info": { "version": "1.0.0", "title": "toaster2", - "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That’s because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." + "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That is because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." }, "servers": [ { diff --git a/restconf/restconf-openapi/src/test/resources/yang-document/device-typed-params.json b/restconf/restconf-openapi/src/test/resources/yang-document/device-typed-params.json index 63f4019493..77ff3b4ef8 100644 --- a/restconf/restconf-openapi/src/test/resources/yang-document/device-typed-params.json +++ b/restconf/restconf-openapi/src/test/resources/yang-document/device-typed-params.json @@ -3,7 +3,7 @@ "info": { "version": "1.0.0", "title": "typed-params", - "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That’s because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." + "description": "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That is because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it." }, "servers": [ { -- 2.36.6