Fix OpenAPI is ignoring restconf settings 86/110186/3
authorlubos-cicut <lubos.cicut@pantheon.tech>
Wed, 7 Feb 2024 22:56:28 +0000 (23:56 +0100)
committerIvan Hrasko <ivan.hrasko@pantheon.tech>
Mon, 12 Feb 2024 13:02:08 +0000 (14:02 +0100)
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 <lubos.cicut@pantheon.tech>
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
restconf/restconf-openapi/pom.xml
restconf/restconf-openapi/src/main/java/org/opendaylight/restconf/openapi/impl/BaseYangOpenApiGeneratorRFC8040.java
restconf/restconf-openapi/src/main/java/org/opendaylight/restconf/openapi/impl/MountPointOpenApiGeneratorRFC8040.java
restconf/restconf-openapi/src/main/java/org/opendaylight/restconf/openapi/impl/OpenApiGeneratorRFC8040.java
restconf/restconf-openapi/src/main/java/org/opendaylight/restconf/openapi/impl/OpenApiServiceImpl.java
restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/impl/AbstractDocumentTest.java

index fe2a954b5792f29f0f4ff756112c03714cefa7b7..ac3a4e703dd261eff078c6697bec998f520f2b56 100644 (file)
       <groupId>org.opendaylight.yangtools</groupId>
       <artifactId>yang-model-util</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.opendaylight.netconf</groupId>
+      <artifactId>restconf-nb</artifactId>
+    </dependency>
 
     <dependency>
       <groupId>com.guicedee.services</groupId>
index 0c7e304ba962739e64b7eec1716c5474282b3ee8..af8fcac9ead14cddb382e7a578a5652d784994c3 100644 (file)
@@ -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);
index 03f9e6c96133d3d9bc1665ae5584f885e8d9e460..28503783690573da7343cccb8e9bd0a60c39b616 100644 (file)
@@ -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);
index 70af502672d15d82e54d4d8020ec562b058c2ec6..5ac5c30232b5c2f1fe854759b37dd009e8350c48 100644 (file)
@@ -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);
     }
index 89eedd623826cfa32fcc258f836c1649c43a3186..91cd8204569a39024d12533c4a0c467d3d56eaea 100644 (file)
@@ -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
index 002897c4348283f97b284c757255fbe803f68f58..62ac46a9a38eed46fc5523b7d6a0f9b9da6763af 100644 (file)
@@ -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);
     }