This is an automated email from the ASF dual-hosted git repository.

adamsaghy pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git


The following commit(s) were added to refs/heads/develop by this push:
     new 707fe3d0e5 FINERACT-2169: Apply dto in api and clean up unnecessary 
swagger;
707fe3d0e5 is described below

commit 707fe3d0e5495f7f5389e511ddde350f1e5122e6
Author: viktorpavlenko <[email protected]>
AuthorDate: Wed Mar 12 23:17:52 2025 +0200

    FINERACT-2169: Apply dto in api and clean up unnecessary swagger;
---
 .../infrastructure/cache/api/CacheApiResource.java | 34 +++++-----------------
 .../cache/api/CacheApiResourceSwagger.java         | 24 ---------------
 .../cache/data/request/CacheRequest.java           | 28 ++++++++++++++++++
 3 files changed, 36 insertions(+), 50 deletions(-)

diff --git 
a/fineract-core/src/main/java/org/apache/fineract/infrastructure/cache/api/CacheApiResource.java
 
b/fineract-core/src/main/java/org/apache/fineract/infrastructure/cache/api/CacheApiResource.java
index f47ad93475..800592d5c4 100644
--- 
a/fineract-core/src/main/java/org/apache/fineract/infrastructure/cache/api/CacheApiResource.java
+++ 
b/fineract-core/src/main/java/org/apache/fineract/infrastructure/cache/api/CacheApiResource.java
@@ -20,7 +20,6 @@ package org.apache.fineract.infrastructure.cache.api;
 
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.Parameter;
-import io.swagger.v3.oas.annotations.media.ArraySchema;
 import io.swagger.v3.oas.annotations.media.Content;
 import io.swagger.v3.oas.annotations.media.Schema;
 import io.swagger.v3.oas.annotations.parameters.RequestBody;
@@ -32,22 +31,16 @@ import jakarta.ws.rs.GET;
 import jakarta.ws.rs.PUT;
 import jakarta.ws.rs.Path;
 import jakarta.ws.rs.Produces;
-import jakarta.ws.rs.core.Context;
 import jakarta.ws.rs.core.MediaType;
-import jakarta.ws.rs.core.UriInfo;
 import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
 import lombok.RequiredArgsConstructor;
 import org.apache.fineract.commands.domain.CommandWrapper;
 import org.apache.fineract.commands.service.CommandWrapperBuilder;
 import 
org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService;
 import org.apache.fineract.infrastructure.cache.data.CacheData;
+import org.apache.fineract.infrastructure.cache.data.request.CacheRequest;
 import 
org.apache.fineract.infrastructure.cache.service.RuntimeDelegatingCacheManager;
-import org.apache.fineract.infrastructure.core.api.ApiRequestParameterHelper;
 import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
-import 
org.apache.fineract.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
 import 
org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSerializer;
 import 
org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
 import org.springframework.beans.factory.annotation.Qualifier;
@@ -63,12 +56,10 @@ import org.springframework.stereotype.Component;
 @RequiredArgsConstructor
 public class CacheApiResource {
 
-    private static final Set<String> RESPONSE_DATA_PARAMETERS = new 
HashSet<>(List.of("id"));
     private static final String RESOURCE_NAME_FOR_PERMISSIONS = "CACHE";
 
     private final PlatformSecurityContext context;
     private final DefaultToApiJsonSerializer<CacheData> toApiJsonSerializer;
-    private final ApiRequestParameterHelper apiRequestParameterHelper;
     private final PortfolioCommandSourceWritePlatformService 
commandsSourceWritePlatformService;
     @Qualifier("runtimeDelegatingCacheManager")
     private final RuntimeDelegatingCacheManager cacheService;
@@ -76,29 +67,20 @@ public class CacheApiResource {
     @GET
     @Operation(summary = "Retrieve Cache Types", description = "Returns the 
list of caches.\n" + "\n" + "Example Requests:\n" + "\n"
             + "caches")
-    @ApiResponses({
-            @ApiResponse(responseCode = "200", description = "OK", content = 
@Content(array = @ArraySchema(schema = @Schema(implementation = 
CacheApiResourceSwagger.GetCachesResponse.class)))) })
-    public String retrieveAll(@Context final UriInfo uriInfo) {
-
+    public Collection<CacheData> retrieveAll() {
         
this.context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSIONS);
-
-        final Collection<CacheData> codes = this.cacheService.retrieveAll();
-
-        final ApiRequestJsonSerializationSettings settings = 
this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
-        return this.toApiJsonSerializer.serialize(settings, codes, 
RESPONSE_DATA_PARAMETERS);
+        return cacheService.retrieveAll();
     }
 
     @PUT
     @Operation(summary = "Switch Cache", description = "Switches the cache to 
chosen one.")
-    @RequestBody(required = true, content = @Content(schema = 
@Schema(implementation = CacheApiResourceSwagger.PutCachesRequest.class)))
+    @RequestBody(required = true, content = @Content(schema = 
@Schema(implementation = CacheRequest.class)))
     @ApiResponses({
             @ApiResponse(responseCode = "200", description = "OK", content = 
@Content(schema = @Schema(implementation = 
CacheApiResourceSwagger.PutCachesResponse.class))) })
-    public String switchCache(@Parameter(hidden = true) final String 
apiRequestBodyAsJson) {
-
-        final CommandWrapper commandRequest = new 
CommandWrapperBuilder().updateCache().withJson(apiRequestBodyAsJson).build();
-
-        final CommandProcessingResult result = 
this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
+    public CommandProcessingResult switchCache(@Parameter(hidden = true) 
CacheRequest cacheRequest) {
+        final CommandWrapper commandRequest = new 
CommandWrapperBuilder().updateCache()
+                .withJson(toApiJsonSerializer.serialize(cacheRequest)).build();
 
-        return this.toApiJsonSerializer.serialize(result);
+        return 
this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
     }
 }
diff --git 
a/fineract-core/src/main/java/org/apache/fineract/infrastructure/cache/api/CacheApiResourceSwagger.java
 
b/fineract-core/src/main/java/org/apache/fineract/infrastructure/cache/api/CacheApiResourceSwagger.java
index 8bce43c655..0c200e93f6 100644
--- 
a/fineract-core/src/main/java/org/apache/fineract/infrastructure/cache/api/CacheApiResourceSwagger.java
+++ 
b/fineract-core/src/main/java/org/apache/fineract/infrastructure/cache/api/CacheApiResourceSwagger.java
@@ -19,7 +19,6 @@
 package org.apache.fineract.infrastructure.cache.api;
 
 import io.swagger.v3.oas.annotations.media.Schema;
-import org.apache.fineract.infrastructure.core.data.EnumOptionData;
 
 /**
  * Created by sanyam on 28/7/17.
@@ -30,29 +29,6 @@ final class CacheApiResourceSwagger {
 
     }
 
-    @Schema(description = "GetCachesResponse")
-    public static final class GetCachesResponse {
-
-        private GetCachesResponse() {
-
-        }
-
-        public EnumOptionData cacheType;
-        public boolean enabled;
-    }
-
-    @Schema(description = "PutCachesRequest")
-    public static final class PutCachesRequest {
-
-        private PutCachesRequest() {
-
-        }
-
-        @Schema(example = "2")
-        public Long cacheType;
-
-    }
-
     @Schema(description = "PutCachesResponse")
     public static final class PutCachesResponse {
 
diff --git 
a/fineract-core/src/main/java/org/apache/fineract/infrastructure/cache/data/request/CacheRequest.java
 
b/fineract-core/src/main/java/org/apache/fineract/infrastructure/cache/data/request/CacheRequest.java
new file mode 100644
index 0000000000..6adf680e02
--- /dev/null
+++ 
b/fineract-core/src/main/java/org/apache/fineract/infrastructure/cache/data/request/CacheRequest.java
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fineract.infrastructure.cache.data.request;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+public record CacheRequest(Long cacheType) implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+}

Reply via email to