Remove private properties from the response whem the value is null 70/141370/5
authorleventecsanyi <levente.csanyi@est.tech>
Tue, 24 Jun 2025 07:33:11 +0000 (08:33 +0100)
committerleventecsanyi <levente.csanyi@est.tech>
Tue, 24 Jun 2025 15:05:56 +0000 (17:05 +0200)
- Fixed openapi and unit test

Issue-ID:CPS-1872
Change-Id: I6c4465fd79249861814a56c6fb02e4d5cf854928
Signed-off-by: ToineSiebelink <toine.siebelink@est.tech>
Signed-off-by: leventecsanyi <levente.csanyi@est.tech>
cps-ncmp-rest/docs/openapi/components.yaml
cps-ncmp-rest/docs/openapi/ncmp-inventory.yml
cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryController.java
cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/util/RestOutputCmHandleMapper.java
cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryControllerSpec.groovy
cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/util/RestOutputCmHandleMapperSpec.groovy
docs/api/swagger/ncmp/openapi-inventory.yaml
docs/api/swagger/ncmp/openapi.yaml

index 835cfc2..25b6575 100644 (file)
@@ -255,12 +255,13 @@ components:
           example: my-cm-handle1
         publicCmHandleProperties:
           type: object
+          nullable: true
           items:
             type: object
             additionalProperties:
               type: string
               example: '3gpp Type'
-        privateCmHandleProperties:
+        cmHandleProperties:
           type: object
           additionalProperties:
             type: string
index 4aa977e..f8013b6 100755 (executable)
@@ -157,9 +157,9 @@ searchCmHandles:
     summary: Query Cm Handles for a requested DMI Service
     operationId: searchCmHandles
     parameters:
-      - name: includePrivatePropertiesInQuery
+      - name: includeCmHandlePropertiesInQuery
         in: query
-        description: Whether to include private properties in the response.
+        description: Whether to include additional properties in the response.
         required: false
         schema:
           type: boolean
index a3b4086..e8cc0b9 100644 (file)
@@ -83,20 +83,20 @@ public class NetworkCmProxyInventoryController implements NetworkCmProxyInventor
      * Execute cm handle query search and return a list of cm handle details. Any number of conditions can be applied.
      *
      * @param cmHandleQueryParameters the cm handle query parameters
-     * @param includeAdditionalProperties boolean value to determine the inclusion of additional properties
+     * @param includeCmHandlePropertiesInQuery boolean value to determine the inclusion of additional properties
      * @return collection of cm handles
      */
     @Override
     public ResponseEntity<List<RestOutputCmHandle>> searchCmHandles(
             final CmHandleQueryParameters cmHandleQueryParameters,
-            final Boolean includeAdditionalProperties) {
+            final Boolean includeCmHandlePropertiesInQuery) {
         final CmHandleQueryApiParameters cmHandleQueryApiParameters =
                 deprecationHelper.mapOldConditionProperties(cmHandleQueryParameters);
-        final boolean includeAdditionalPropertiesParameter = Boolean.TRUE.equals(includeAdditionalProperties);
+        final boolean includeCmHandlePropertiesParameter = Boolean.TRUE.equals(includeCmHandlePropertiesInQuery);
         final List<RestOutputCmHandle> restOutputCmHandles =
                 networkCmProxyInventoryFacade.executeCmHandleInventorySearch(cmHandleQueryApiParameters)
                         .map(handle -> restOutputCmHandleMapper
-                                .toRestOutputCmHandle(handle, includeAdditionalPropertiesParameter))
+                                .toRestOutputCmHandle(handle, includeCmHandlePropertiesParameter))
                         .collectList().block();
         return ResponseEntity.ok(restOutputCmHandles);
     }
index 685b0d5..32d8716 100644 (file)
@@ -47,7 +47,9 @@ public class RestOutputCmHandleMapper {
         restOutputCmHandle.setPublicCmHandleProperties(
                 Collections.singletonList(ncmpServiceCmHandle.getPublicProperties()));
         if (includeAdditionalProperties) {
-            restOutputCmHandle.setPrivateCmHandleProperties(ncmpServiceCmHandle.getAdditionalProperties());
+            restOutputCmHandle.setCmHandleProperties(ncmpServiceCmHandle.getAdditionalProperties());
+        } else {
+            restOutputCmHandle.setCmHandleProperties(null);
         }
         restOutputCmHandle.setState(
                 cmHandleStateMapper.toCmHandleCompositeStateExternalLockReason(
@@ -60,4 +62,4 @@ public class RestOutputCmHandleMapper {
         restOutputCmHandle.setDataProducerIdentifier(ncmpServiceCmHandle.getDataProducerIdentifier());
         return restOutputCmHandle;
     }
-}
\ No newline at end of file
+}
index 8e55bbb..366d1af 100644 (file)
@@ -270,7 +270,7 @@ class NetworkCmProxyInventoryControllerSpec extends Specification {
 
     def 'Get a cm handle by DMI service name.'() {
         given: 'an endpoint for returning cm handles by dmi service name'
-            def postUrl = "$ncmpBasePathV1/ch/searchCmHandles?includePrivatePropertiesInQuery=true"
+            def postUrl = "$ncmpBasePathV1/ch/searchCmHandles?includeCmHandlePropertiesInQuery=true"
             String jsonString = TestUtils.getResourceFileContent('cm-handle-search-by-dmi-service.json')
         and: 'a cm handle is returned'
             def ncmpServiceCmHandle = new NcmpServiceCmHandle(additionalProperties: ['someName': 'my dmi'])
index 0190537..50e2fd4 100644 (file)
@@ -39,7 +39,9 @@ class RestOutputCmHandleMapperSpec extends Specification {
         when: 'the mapper function is called'
             def result = objectUnderTest.toRestOutputCmHandle(ncmpServiceCmHandle, includeAdditionalProperties)
         then: 'result has the expected properties'
-            assert result.privateCmHandleProperties.containsKey('additional property key') == includeAdditionalProperties
+            if (includeAdditionalProperties) {
+                assert result.cmHandleProperties.containsKey('additional property key')
+            }
             if (trustLevel != null) {
                 assert result.trustLevel == trustLevel.toString()
             }
index c00bc8b..7e5b2b1 100644 (file)
@@ -202,9 +202,9 @@ paths:
         this query.
       operationId: searchCmHandles
       parameters:
-      - description: Whether to include private properties in the response.
+      - description: Whether to include additional properties in the response.
         in: query
-        name: includePrivatePropertiesInQuery
+        name: includeCmHandlePropertiesInQuery
         required: false
         schema:
           type: boolean
@@ -616,6 +616,8 @@ components:
         publicCmHandleProperties:
         - key: 3gpp Type
         - key: 3gpp Type
+        cmHandleProperties:
+          key: 3gpp Type
         state:
           dataSyncEnabled: false
           dataSyncState:
@@ -632,8 +634,6 @@ components:
           lastUpdateTime: 2022-12-31T20:30:40.000+0000
         trustLevel: COMPLETE
         moduleSetTag: my-module-set-tag
-        privateCmHandleProperties:
-          key: 3gpp Type
       properties:
         cmHandle:
           example: my-cm-handle1
@@ -644,8 +644,9 @@ components:
               example: 3gpp Type
               type: string
             type: object
+          nullable: true
           type: array
-        privateCmHandleProperties:
+        cmHandleProperties:
           additionalProperties:
             example: 3gpp Type
             type: string
index 61d4e19..0e5cd57 100644 (file)
@@ -1937,6 +1937,8 @@ components:
         publicCmHandleProperties:
         - key: 3gpp Type
         - key: 3gpp Type
+        cmHandleProperties:
+          key: 3gpp Type
         state:
           dataSyncEnabled: false
           dataSyncState:
@@ -1953,8 +1955,6 @@ components:
           lastUpdateTime: 2022-12-31T20:30:40.000+0000
         trustLevel: COMPLETE
         moduleSetTag: my-module-set-tag
-        privateCmHandleProperties:
-          key: 3gpp Type
       properties:
         cmHandle:
           example: my-cm-handle1
@@ -1965,8 +1965,9 @@ components:
               example: 3gpp Type
               type: string
             type: object
+          nullable: true
           type: array
-        privateCmHandleProperties:
+        cmHandleProperties:
           additionalProperties:
             example: 3gpp Type
             type: string