Skip to content

Commit ee05381

Browse files
committed
Do not serialize null properties in the management model
* Ignore null values in JSON output * This may have an impact on existing client, but it is not likely to be substantial because normally absent properties should be treated the same as having `null` values. * This change enables adding new optional fields to the Management API while maintaining backward compatibility in the future: New properties will not be exposed to clients unless a value for them in explicitly set.
1 parent 438d06c commit ee05381

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

api/management-model/build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ openApiGenerate {
5656
additionalProperties.put("apiNamePrefix", "Polaris")
5757
additionalProperties.put("apiNameSuffix", "Api")
5858
additionalProperties.put("metricsPrefix", "polaris")
59+
additionalProperties.put(
60+
"additionalModelTypeAnnotations",
61+
"@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL)",
62+
)
5963
serverVariables = mapOf("basePath" to "api/v1")
6064
}
6165

api/management-model/src/test/java/org/apache/polaris/core/admin/model/CatalogSerializationTest.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,8 @@ public void testJsonFormat() throws JsonProcessingException {
6666
"{\"type\":\"INTERNAL\","
6767
+ "\"name\":\"test-catalog\","
6868
+ "\"properties\":{\"default-base-location\":\"s3://test/\"},"
69-
+ "\"createTimestamp\":null,"
70-
+ "\"lastUpdateTimestamp\":null,"
71-
+ "\"entityVersion\":null,"
7269
+ "\"storageConfigInfo\":{"
7370
+ "\"roleArn\":\"arn:aws:iam::123456789012:role/test-role\","
74-
+ "\"externalId\":null,"
75-
+ "\"userArn\":null,"
76-
+ "\"region\":null,"
7771
+ "\"storageType\":\"S3\","
7872
+ "\"allowedLocations\":[]"
7973
+ "}}");

0 commit comments

Comments
 (0)