diff --git a/CHANGELOG.md b/CHANGELOG.md
index d27137c..f7c334a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,12 @@
# Changelog
+## v0.2.2
+
+### [0.2.2](https://github.com/openfga/java-sdk/compare/v0.2.1...v0.2.2) (2023-10-31)
+
+- fix(client): an empty read request will no longer send an empty tuple
+- fix(client): an unused "user" field, and related methods, was removed from ClientExpandRequest
+
## v0.2.1
### [0.2.1](https://github.com/openfga/java-sdk/compare/v0.2.0...v0.2.1) (2023-10-13)
diff --git a/README.md b/README.md
index 1cee4da..d82e380 100644
--- a/README.md
+++ b/README.md
@@ -74,13 +74,13 @@ It can be used with the following:
* Gradle (Groovy)
```groovy
-implementation 'dev.openfga:openfga-sdk:0.2.1'
+implementation 'dev.openfga:openfga-sdk:0.2.2'
```
* Gradle (Kotlin)
```kotlin
-implementation("dev.openfga:openfga-sdk:0.2.1")
+implementation("dev.openfga:openfga-sdk:0.2.2")
```
* Apache Maven
@@ -89,26 +89,26 @@ implementation("dev.openfga:openfga-sdk:0.2.1")
dev.openfga
openfga-sdk
- 0.2.1
+ 0.2.2
```
* Ivy
```xml
-
+
```
* SBT
```scala
-libraryDependencies += "dev.openfga" % "openfga-sdk" % "0.2.1"
+libraryDependencies += "dev.openfga" % "openfga-sdk" % "0.2.2"
```
* Leiningen
```edn
-[dev.openfga/openfga-sdk "0.2.1"]
+[dev.openfga/openfga-sdk "0.2.2"]
```
diff --git a/build.gradle b/build.gradle
index 89cf930..e24731c 100644
--- a/build.gradle
+++ b/build.gradle
@@ -19,7 +19,7 @@ plugins {
apply from: 'publish.gradle'
group = 'dev.openfga'
-version = '0.2.1'
+version = '0.2.2'
repositories {
mavenCentral()
diff --git a/publish.gradle b/publish.gradle
index 45bc546..a5c39de 100644
--- a/publish.gradle
+++ b/publish.gradle
@@ -6,7 +6,7 @@ publishing {
pom {
group = 'dev.openfga'
name = 'openfga-sdk'
- version = '0.2.1'
+ version = '0.2.2'
description = 'This is an autogenerated Java SDK for OpenFGA. It provides a wrapper around the [OpenFGA API definition](https://openfga.dev/api).'
url = 'https://openfga.dev'
licenses {
diff --git a/src/main/java/dev/openfga/sdk/api/client/ClientExpandRequest.java b/src/main/java/dev/openfga/sdk/api/client/ClientExpandRequest.java
index 9394753..c2bca29 100644
--- a/src/main/java/dev/openfga/sdk/api/client/ClientExpandRequest.java
+++ b/src/main/java/dev/openfga/sdk/api/client/ClientExpandRequest.java
@@ -13,7 +13,6 @@
package dev.openfga.sdk.api.client;
public class ClientExpandRequest {
- private String user;
private String relation;
private String _object;
@@ -42,17 +41,4 @@ public ClientExpandRequest relation(String relation) {
public String getRelation() {
return relation;
}
-
- public ClientExpandRequest user(String user) {
- this.user = user;
- return this;
- }
-
- /**
- * Get user
- * @return user
- **/
- public String getUser() {
- return user;
- }
}
diff --git a/src/main/java/dev/openfga/sdk/api/client/OpenFgaClient.java b/src/main/java/dev/openfga/sdk/api/client/OpenFgaClient.java
index 519f947..9941726 100644
--- a/src/main/java/dev/openfga/sdk/api/client/OpenFgaClient.java
+++ b/src/main/java/dev/openfga/sdk/api/client/OpenFgaClient.java
@@ -238,18 +238,18 @@ public CompletableFuture read(ClientReadRequest request, Cli
String storeId = configuration.getStoreIdChecked();
ReadRequest body = new ReadRequest();
- TupleKey tupleKey = new TupleKey();
- if (request != null) {
+ if (request != null
+ && (request.getUser() != null || request.getRelation() != null || request.getObject() != null)) {
+ TupleKey tupleKey = new TupleKey();
tupleKey.user(request.getUser()).relation(request.getRelation())._object(request.getObject());
+ body.tupleKey(tupleKey);
}
if (options != null) {
body.pageSize(options.getPageSize()).continuationToken(options.getContinuationToken());
}
- body.tupleKey(tupleKey);
-
return call(() -> api.read(storeId, body)).thenApply(ClientReadResponse::new);
}
@@ -408,10 +408,7 @@ public CompletableFuture expand(ClientExpandRequest reques
ExpandRequest body = new ExpandRequest();
if (request != null) {
- body.tupleKey(new TupleKey()
- .user(request.getUser())
- .relation(request.getRelation())
- ._object(request.getObject()));
+ body.tupleKey(new TupleKey().relation(request.getRelation())._object(request.getObject()));
}
if (options != null && !isNullOrWhitespace(options.getAuthorizationModelId())) {
diff --git a/src/main/java/dev/openfga/sdk/api/configuration/Configuration.java b/src/main/java/dev/openfga/sdk/api/configuration/Configuration.java
index fa83359..9c1d27b 100644
--- a/src/main/java/dev/openfga/sdk/api/configuration/Configuration.java
+++ b/src/main/java/dev/openfga/sdk/api/configuration/Configuration.java
@@ -27,10 +27,10 @@
* Configurations for an api client.
*/
public class Configuration implements BaseConfiguration {
- public static final String VERSION = "0.2.1";
+ public static final String VERSION = "0.2.2";
private static final String DEFAULT_API_URL = "http://localhost:8080";
- private static final String DEFAULT_USER_AGENT = "openfga-sdk java/0.2.1";
+ private static final String DEFAULT_USER_AGENT = "openfga-sdk java/0.2.2";
private static final Duration DEFAULT_READ_TIMEOUT = Duration.ofSeconds(10);
private static final Duration DEFAULT_CONNECT_TIMEOUT = Duration.ofSeconds(10);
diff --git a/src/test/java/dev/openfga/sdk/api/client/OpenFgaClientTest.java b/src/test/java/dev/openfga/sdk/api/client/OpenFgaClientTest.java
index d1e9bc9..d0cf513 100644
--- a/src/test/java/dev/openfga/sdk/api/client/OpenFgaClientTest.java
+++ b/src/test/java/dev/openfga/sdk/api/client/OpenFgaClientTest.java
@@ -944,6 +944,21 @@ public void readTest() throws Exception {
assertEquals(DEFAULT_OBJECT, key.getObject());
}
+ @Test
+ public void read_emptyRequestSendsNoTupleKey() throws Exception {
+ // Given
+ String postUrl = String.format("https://localhost/stores/%s/read", DEFAULT_STORE_ID);
+ String expectedBody = "{\"tuple_key\":null,\"page_size\":null,\"continuation_token\":null}";
+ mockHttpClient.onPost(postUrl).withBody(is(expectedBody)).doReturn(200, EMPTY_RESPONSE_BODY);
+ ClientReadRequest request = new ClientReadRequest();
+
+ // When
+ ClientReadResponse response = fga.read(request).get();
+
+ // Then
+ mockHttpClient.verify().post(postUrl).withBody(is(expectedBody)).called(1);
+ }
+
@Test
public void read_storeIdRequired() {
// Given
@@ -1303,16 +1318,14 @@ public void expandTest() throws Exception {
// Given
String postPath = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/expand";
String expectedBody = String.format(
- "{\"tuple_key\":{\"object\":\"%s\",\"relation\":\"%s\",\"user\":\"%s\"},\"authorization_model_id\":\"%s\"}",
- DEFAULT_OBJECT, DEFAULT_RELATION, DEFAULT_USER, DEFAULT_AUTH_MODEL_ID);
+ "{\"tuple_key\":{\"object\":\"%s\",\"relation\":\"%s\",\"user\":null},\"authorization_model_id\":\"%s\"}",
+ DEFAULT_OBJECT, DEFAULT_RELATION, DEFAULT_AUTH_MODEL_ID);
String responseBody = String.format(
"{\"tree\":{\"root\":{\"union\":{\"nodes\":[{\"leaf\":{\"users\":{\"users\":[\"%s\"]}}}]}}}}",
DEFAULT_USER);
mockHttpClient.onPost(postPath).withBody(is(expectedBody)).doReturn(200, responseBody);
- ClientExpandRequest request = new ClientExpandRequest()
- .user(DEFAULT_USER)
- .relation(DEFAULT_RELATION)
- ._object(DEFAULT_OBJECT);
+ ClientExpandRequest request =
+ new ClientExpandRequest().relation(DEFAULT_RELATION)._object(DEFAULT_OBJECT);
ClientExpandOptions options = new ClientExpandOptions().authorizationModelId(DEFAULT_AUTH_MODEL_ID);
// When
diff --git a/src/test/java/dev/openfga/sdk/api/configuration/ConfigurationTest.java b/src/test/java/dev/openfga/sdk/api/configuration/ConfigurationTest.java
index c415ca9..0d93001 100644
--- a/src/test/java/dev/openfga/sdk/api/configuration/ConfigurationTest.java
+++ b/src/test/java/dev/openfga/sdk/api/configuration/ConfigurationTest.java
@@ -20,7 +20,7 @@
class ConfigurationTest {
private static final String DEFAULT_API_URL = "http://localhost:8080";
- private static final String DEFAULT_USER_AGENT = "openfga-sdk java/0.2.1";
+ private static final String DEFAULT_USER_AGENT = "openfga-sdk java/0.2.2";
private static final Duration DEFAULT_READ_TIMEOUT = Duration.ofSeconds(10);
private static final Duration DEFAULT_CONNECT_TIMEOUT = Duration.ofSeconds(10);