From: lubos-cicut Date: Wed, 7 Feb 2024 22:56:28 +0000 (+0100) Subject: Fix OpenAPI is ignoring restconf settings X-Git-Tag: v7.0.0~46 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=56cd5cb20451d56cfb04ab88fd9a0a2bd716b36b;p=netconf.git Fix OpenAPI is ignoring restconf settings Restconf OpenAPI is ignoring restconf settings in etc/org.opendaylight.restconf.nb.rfc8040.cfg namely restconf setting to specify the base path which has been introduced in NETCONF-1218. JIRA: NETCONF-1230 Change-Id: I6c658b9feb89aba11a68290073b115c27d98bd13 Signed-off-by: lubos-cicut Signed-off-by: Ivan Hrasko --- diff --git a/restconf/restconf-openapi/pom.xml b/restconf/restconf-openapi/pom.xml index fe2a954b57..ac3a4e703d 100644 --- a/restconf/restconf-openapi/pom.xml +++ b/restconf/restconf-openapi/pom.xml @@ -71,6 +71,10 @@ org.opendaylight.yangtools yang-model-util + + org.opendaylight.netconf + restconf-nb + com.guicedee.services diff --git a/restconf/restconf-openapi/src/main/java/org/opendaylight/restconf/openapi/impl/BaseYangOpenApiGeneratorRFC8040.java b/restconf/restconf-openapi/src/main/java/org/opendaylight/restconf/openapi/impl/BaseYangOpenApiGeneratorRFC8040.java index 0c7e304ba9..af8fcac9ea 100644 --- a/restconf/restconf-openapi/src/main/java/org/opendaylight/restconf/openapi/impl/BaseYangOpenApiGeneratorRFC8040.java +++ b/restconf/restconf-openapi/src/main/java/org/opendaylight/restconf/openapi/impl/BaseYangOpenApiGeneratorRFC8040.java @@ -20,10 +20,6 @@ import org.opendaylight.mdsal.dom.api.DOMSchemaService; public abstract class BaseYangOpenApiGeneratorRFC8040 extends BaseYangOpenApiGenerator { private final String basePath; - protected BaseYangOpenApiGeneratorRFC8040(final @NonNull DOMSchemaService schemaService) { - this(schemaService, "rests"); - } - protected BaseYangOpenApiGeneratorRFC8040(final @NonNull DOMSchemaService schemaService, final @NonNull String basePath) { super(schemaService); diff --git a/restconf/restconf-openapi/src/main/java/org/opendaylight/restconf/openapi/impl/MountPointOpenApiGeneratorRFC8040.java b/restconf/restconf-openapi/src/main/java/org/opendaylight/restconf/openapi/impl/MountPointOpenApiGeneratorRFC8040.java index 03f9e6c961..2850378369 100644 --- a/restconf/restconf-openapi/src/main/java/org/opendaylight/restconf/openapi/impl/MountPointOpenApiGeneratorRFC8040.java +++ b/restconf/restconf-openapi/src/main/java/org/opendaylight/restconf/openapi/impl/MountPointOpenApiGeneratorRFC8040.java @@ -20,13 +20,6 @@ import org.opendaylight.restconf.openapi.mountpoints.MountPointOpenApi; public class MountPointOpenApiGeneratorRFC8040 extends BaseYangOpenApiGeneratorRFC8040 implements AutoCloseable { private final MountPointOpenApi mountPointOpenApi; - public MountPointOpenApiGeneratorRFC8040(final @NonNull DOMSchemaService schemaService, - final @NonNull DOMMountPointService mountService) { - super(schemaService); - mountPointOpenApi = new MountPointOpenApi(schemaService, mountService, this); - mountPointOpenApi.init(); - } - public MountPointOpenApiGeneratorRFC8040(final @NonNull DOMSchemaService schemaService, final @NonNull DOMMountPointService mountService, final @NonNull String basePath) { super(schemaService, basePath); diff --git a/restconf/restconf-openapi/src/main/java/org/opendaylight/restconf/openapi/impl/OpenApiGeneratorRFC8040.java b/restconf/restconf-openapi/src/main/java/org/opendaylight/restconf/openapi/impl/OpenApiGeneratorRFC8040.java index 70af502672..5ac5c30232 100644 --- a/restconf/restconf-openapi/src/main/java/org/opendaylight/restconf/openapi/impl/OpenApiGeneratorRFC8040.java +++ b/restconf/restconf-openapi/src/main/java/org/opendaylight/restconf/openapi/impl/OpenApiGeneratorRFC8040.java @@ -17,10 +17,6 @@ import org.opendaylight.mdsal.dom.api.DOMSchemaService; * @author Thomas Pantelis */ public class OpenApiGeneratorRFC8040 extends BaseYangOpenApiGeneratorRFC8040 { - public OpenApiGeneratorRFC8040(final @NonNull DOMSchemaService schemaService) { - super(schemaService); - } - public OpenApiGeneratorRFC8040(final @NonNull DOMSchemaService schemaService, final @NonNull String basePath) { super(schemaService, basePath); } diff --git a/restconf/restconf-openapi/src/main/java/org/opendaylight/restconf/openapi/impl/OpenApiServiceImpl.java b/restconf/restconf-openapi/src/main/java/org/opendaylight/restconf/openapi/impl/OpenApiServiceImpl.java index 89eedd6238..91cd820456 100644 --- a/restconf/restconf-openapi/src/main/java/org/opendaylight/restconf/openapi/impl/OpenApiServiceImpl.java +++ b/restconf/restconf-openapi/src/main/java/org/opendaylight/restconf/openapi/impl/OpenApiServiceImpl.java @@ -19,6 +19,7 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; import org.opendaylight.mdsal.dom.api.DOMMountPointService; import org.opendaylight.mdsal.dom.api.DOMSchemaService; +import org.opendaylight.restconf.nb.rfc8040.streams.RestconfStreamServletFactory; import org.opendaylight.restconf.openapi.api.OpenApiService; import org.opendaylight.restconf.openapi.model.MountPointInstance; import org.opendaylight.restconf.openapi.mountpoints.MountPointOpenApi; @@ -48,16 +49,10 @@ public final class OpenApiServiceImpl implements OpenApiService { @Inject @Activate public OpenApiServiceImpl(final @Reference DOMSchemaService schemaService, - final @Reference DOMMountPointService mountPointService) { - this(new MountPointOpenApiGeneratorRFC8040(schemaService, mountPointService), - new OpenApiGeneratorRFC8040(schemaService)); - } - - public OpenApiServiceImpl(final DOMSchemaService schemaService, - final DOMMountPointService mountPointService, - final String basePath) { - this(new MountPointOpenApiGeneratorRFC8040(schemaService, mountPointService, basePath), - new OpenApiGeneratorRFC8040(schemaService, basePath)); + final @Reference DOMMountPointService mountPointService, + final @Reference RestconfStreamServletFactory context) { + this(new MountPointOpenApiGeneratorRFC8040(schemaService, mountPointService, context.restconf()), + new OpenApiGeneratorRFC8040(schemaService, context.restconf())); } @VisibleForTesting 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 002897c434..62ac46a9a3 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 @@ -54,8 +54,8 @@ public abstract class AbstractDocumentTest { final var service = mock(DOMMountPointService.class); when(service.getMountPoint(INSTANCE_ID)).thenReturn(Optional.of(mountPoint)); - final var mountPointRFC8040 = new MountPointOpenApiGeneratorRFC8040(schemaService, service); - final var openApiGeneratorRFC8040 = new OpenApiGeneratorRFC8040(schemaService); + final var mountPointRFC8040 = new MountPointOpenApiGeneratorRFC8040(schemaService, service, "rests"); + final var openApiGeneratorRFC8040 = new OpenApiGeneratorRFC8040(schemaService, "rests"); mountPointRFC8040.getMountPointOpenApi().onMountPointCreated(INSTANCE_ID); openApiService = new OpenApiServiceImpl(mountPointRFC8040, openApiGeneratorRFC8040); }