From d78f661befcb434bdf5c480b890a4925b4edcee3 Mon Sep 17 00:00:00 2001 From: Fanis Tharropoulos Date: Fri, 8 Nov 2024 12:41:07 +0200 Subject: [PATCH 1/2] fix(keys): fix delete schema response - Add a new interface for response schemas after deletion, as the api only returns the id of the api key instead of the whole object --- src/main/java/org/typesense/api/Key.java | 5 +- .../interfaces/ApiKeyDeleteResponse.java | 57 +++++++++++++++++++ 2 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 src/main/java/org/typesense/interfaces/ApiKeyDeleteResponse.java diff --git a/src/main/java/org/typesense/api/Key.java b/src/main/java/org/typesense/api/Key.java index 4aa035d..8e0e626 100644 --- a/src/main/java/org/typesense/api/Key.java +++ b/src/main/java/org/typesense/api/Key.java @@ -1,5 +1,6 @@ package org.typesense.api; +import org.typesense.interfaces.ApiKeyDeleteResponse; import org.typesense.model.ApiKey; public class Key { @@ -16,8 +17,8 @@ public ApiKey retrieve() throws Exception { return this.apiCall.get(this.getEndpoint(), null, ApiKey.class); } - public ApiKey delete() throws Exception { - return this.apiCall.delete(this.getEndpoint(), null, ApiKey.class); + public ApiKeyDeleteResponse delete() throws Exception { + return this.apiCall.delete(this.getEndpoint(), null, ApiKeyDeleteResponse.class); } private String getEndpoint(){ diff --git a/src/main/java/org/typesense/interfaces/ApiKeyDeleteResponse.java b/src/main/java/org/typesense/interfaces/ApiKeyDeleteResponse.java new file mode 100644 index 0000000..73654bf --- /dev/null +++ b/src/main/java/org/typesense/interfaces/ApiKeyDeleteResponse.java @@ -0,0 +1,57 @@ +package org.typesense.interfaces; + +import java.util.Objects; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import io.swagger.v3.oas.annotations.media.Schema; + +public class ApiKeyDeleteResponse { + @JsonProperty("id") + private Long id = null; + + public ApiKeyDeleteResponse id(Long id) { + this.id = id; + return this; + } + + /** + * The unique identifier of the deleted key + * @return id + **/ + @Schema(required = true, description = "The unique identifier of the deleted key") + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ApiKeyDeleteResponse that = (ApiKeyDeleteResponse) o; + return Objects.equals(this.id, that.id); + } + + @Override + public int hashCode() { + return Objects.hash(id); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ApiKeyDeleteResponse {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + private String toIndentedString(Object o) { + if (o == null) return "null"; + return o.toString().replace("\n", "\n "); + } +} From 49871720aa48d2c294cd59b3fb379b3f99ad923d Mon Sep 17 00:00:00 2001 From: Fanis Tharropoulos Date: Fri, 8 Nov 2024 15:33:40 +0200 Subject: [PATCH 2/2] fix(keys): use newly fixed api key delete response schema from codegen --- src/main/java/org/typesense/api/Key.java | 2 +- .../interfaces/ApiKeyDeleteResponse.java | 57 ------------------- 2 files changed, 1 insertion(+), 58 deletions(-) delete mode 100644 src/main/java/org/typesense/interfaces/ApiKeyDeleteResponse.java diff --git a/src/main/java/org/typesense/api/Key.java b/src/main/java/org/typesense/api/Key.java index 8e0e626..1388072 100644 --- a/src/main/java/org/typesense/api/Key.java +++ b/src/main/java/org/typesense/api/Key.java @@ -1,7 +1,7 @@ package org.typesense.api; -import org.typesense.interfaces.ApiKeyDeleteResponse; import org.typesense.model.ApiKey; +import org.typesense.model.ApiKeyDeleteResponse; public class Key { diff --git a/src/main/java/org/typesense/interfaces/ApiKeyDeleteResponse.java b/src/main/java/org/typesense/interfaces/ApiKeyDeleteResponse.java deleted file mode 100644 index 73654bf..0000000 --- a/src/main/java/org/typesense/interfaces/ApiKeyDeleteResponse.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.typesense.interfaces; - -import java.util.Objects; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import io.swagger.v3.oas.annotations.media.Schema; - -public class ApiKeyDeleteResponse { - @JsonProperty("id") - private Long id = null; - - public ApiKeyDeleteResponse id(Long id) { - this.id = id; - return this; - } - - /** - * The unique identifier of the deleted key - * @return id - **/ - @Schema(required = true, description = "The unique identifier of the deleted key") - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - ApiKeyDeleteResponse that = (ApiKeyDeleteResponse) o; - return Objects.equals(this.id, that.id); - } - - @Override - public int hashCode() { - return Objects.hash(id); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ApiKeyDeleteResponse {\n"); - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - private String toIndentedString(Object o) { - if (o == null) return "null"; - return o.toString().replace("\n", "\n "); - } -}