Skip to content

Commit d5ec8cf

Browse files
docs: clarify forwards compat behavior
1 parent 8b814d5 commit d5ec8cf

97 files changed

Lines changed: 5732 additions & 1 deletion

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,9 @@ In rare cases, the API may return a response that doesn't match the expected typ
961961

962962
By default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitInvalidDataException.kt) only if you directly access the property.
963963

964-
If you would prefer to check that the response is completely well-typed upfront, then either call `validate()`:
964+
Validating the response is _not_ forwards compatible with new types from the API for existing fields.
965+
966+
If you would still prefer to check that the response is completely well-typed upfront, then either call `validate()`:
965967

966968
```java
967969
import io.imagekit.models.files.FileUploadResponse;

image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,9 @@ class ImageKitOkHttpClient private constructor() {
217217
/**
218218
* Whether to call `validate` on every response before returning it.
219219
*
220+
* Setting this to `true` is _not_ forwards compatible with new types from the API for
221+
* existing fields.
222+
*
220223
* Defaults to false, which means the shape of the response will not be validated upfront.
221224
* Instead, validation will only occur for the parts of the response that are accessed.
222225
*/

image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,9 @@ class ImageKitOkHttpClientAsync private constructor() {
217217
/**
218218
* Whether to call `validate` on every response before returning it.
219219
*
220+
* Setting this to `true` is _not_ forwards compatible with new types from the API for
221+
* existing fields.
222+
*
220223
* Defaults to false, which means the shape of the response will not be validated upfront.
221224
* Instead, validation will only occur for the parts of the response that are accessed.
222225
*/

image-kit-java-core/src/main/kotlin/io/imagekit/core/ClientOptions.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ private constructor(
6767
/**
6868
* Whether to call `validate` on every response before returning it.
6969
*
70+
* Setting this to `true` is _not_ forwards compatible with new types from the API for existing
71+
* fields.
72+
*
7073
* Defaults to false, which means the shape of the response will not be validated upfront.
7174
* Instead, validation will only occur for the parts of the response that are accessed.
7275
*/
@@ -257,6 +260,9 @@ private constructor(
257260
/**
258261
* Whether to call `validate` on every response before returning it.
259262
*
263+
* Setting this to `true` is _not_ forwards compatible with new types from the API for
264+
* existing fields.
265+
*
260266
* Defaults to false, which means the shape of the response will not be validated upfront.
261267
* Instead, validation will only occur for the parts of the response that are accessed.
262268
*/

image-kit-java-core/src/main/kotlin/io/imagekit/core/RequestOptions.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ class RequestOptions private constructor(val responseValidation: Boolean?, val t
3333
private var responseValidation: Boolean? = null
3434
private var timeout: Timeout? = null
3535

36+
/**
37+
* Whether to call `validate` on the response before returning it.
38+
*
39+
* Setting this to `true` is _not_ forwards compatible with new types from the API for
40+
* existing fields.
41+
*
42+
* Defaults to false, which means the shape of the response will not be validated upfront.
43+
* Instead, validation will only occur for the parts of the response that are accessed.
44+
*/
3645
fun responseValidation(responseValidation: Boolean) = apply {
3746
this.responseValidation = responseValidation
3847
}

image-kit-java-core/src/main/kotlin/io/imagekit/models/AiTag.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,14 @@ private constructor(
179179

180180
private var validated: Boolean = false
181181

182+
/**
183+
* Validates that the types of all values in this object match their expected types recursively.
184+
*
185+
* This method is _not_ forwards compatible with new types from the API for existing fields.
186+
*
187+
* @throws ImageKitInvalidDataException if any value type in this object doesn't match its
188+
* expected type.
189+
*/
182190
fun validate(): AiTag = apply {
183191
if (validated) {
184192
return@apply

image-kit-java-core/src/main/kotlin/io/imagekit/models/BaseOverlay.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,14 @@ private constructor(
223223

224224
private var validated: Boolean = false
225225

226+
/**
227+
* Validates that the types of all values in this object match their expected types recursively.
228+
*
229+
* This method is _not_ forwards compatible with new types from the API for existing fields.
230+
*
231+
* @throws ImageKitInvalidDataException if any value type in this object doesn't match its
232+
* expected type.
233+
*/
226234
fun validate(): BaseOverlay = apply {
227235
if (validated) {
228236
return@apply
@@ -373,6 +381,15 @@ private constructor(
373381

374382
private var validated: Boolean = false
375383

384+
/**
385+
* Validates that the types of all values in this object match their expected types
386+
* recursively.
387+
*
388+
* This method is _not_ forwards compatible with new types from the API for existing fields.
389+
*
390+
* @throws ImageKitInvalidDataException if any value type in this object doesn't match its
391+
* expected type.
392+
*/
376393
fun validate(): LayerMode = apply {
377394
if (validated) {
378395
return@apply

image-kit-java-core/src/main/kotlin/io/imagekit/models/CustomMetadata.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ private constructor(
6969

7070
private var validated: Boolean = false
7171

72+
/**
73+
* Validates that the types of all values in this object match their expected types recursively.
74+
*
75+
* This method is _not_ forwards compatible with new types from the API for existing fields.
76+
*
77+
* @throws ImageKitInvalidDataException if any value type in this object doesn't match its
78+
* expected type.
79+
*/
7280
fun validate(): CustomMetadata = apply {
7381
if (validated) {
7482
return@apply

image-kit-java-core/src/main/kotlin/io/imagekit/models/EmbeddedMetadata.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,14 @@ private constructor(
7171

7272
private var validated: Boolean = false
7373

74+
/**
75+
* Validates that the types of all values in this object match their expected types recursively.
76+
*
77+
* This method is _not_ forwards compatible with new types from the API for existing fields.
78+
*
79+
* @throws ImageKitInvalidDataException if any value type in this object doesn't match its
80+
* expected type.
81+
*/
7482
fun validate(): EmbeddedMetadata = apply {
7583
if (validated) {
7684
return@apply

0 commit comments

Comments
 (0)