Skip to content

Commit 766609c

Browse files
docs: clarify forwards compat behavior
1 parent 7428d26 commit 766609c

112 files changed

Lines changed: 4132 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
@@ -691,7 +691,9 @@ In rare cases, the API may return a response that doesn't match the expected typ
691691

692692
By default, the SDK will not throw an exception in this case. It will throw [`FinchInvalidDataException`](finch-java-core/src/main/kotlin/com/tryfinch/api/errors/FinchInvalidDataException.kt) only if you directly access the property.
693693

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

696698
```java
697699
import com.tryfinch.api.models.CreateAccessTokenResponse;

finch-java-client-okhttp/src/main/kotlin/com/tryfinch/api/client/okhttp/FinchOkHttpClient.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ class FinchOkHttpClient private constructor() {
230230
/**
231231
* Whether to call `validate` on every response before returning it.
232232
*
233+
* Setting this to `true` is _not_ forwards compatible with new types from the API for
234+
* existing fields.
235+
*
233236
* Defaults to false, which means the shape of the response will not be validated upfront.
234237
* Instead, validation will only occur for the parts of the response that are accessed.
235238
*/

finch-java-client-okhttp/src/main/kotlin/com/tryfinch/api/client/okhttp/FinchOkHttpClientAsync.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ class FinchOkHttpClientAsync private constructor() {
230230
/**
231231
* Whether to call `validate` on every response before returning it.
232232
*
233+
* Setting this to `true` is _not_ forwards compatible with new types from the API for
234+
* existing fields.
235+
*
233236
* Defaults to false, which means the shape of the response will not be validated upfront.
234237
* Instead, validation will only occur for the parts of the response that are accessed.
235238
*/

finch-java-core/src/main/kotlin/com/tryfinch/api/core/ClientOptions.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ private constructor(
8181
/**
8282
* Whether to call `validate` on every response before returning it.
8383
*
84+
* Setting this to `true` is _not_ forwards compatible with new types from the API for existing
85+
* fields.
86+
*
8487
* Defaults to false, which means the shape of the response will not be validated upfront.
8588
* Instead, validation will only occur for the parts of the response that are accessed.
8689
*/
@@ -276,6 +279,9 @@ private constructor(
276279
/**
277280
* Whether to call `validate` on every response before returning it.
278281
*
282+
* Setting this to `true` is _not_ forwards compatible with new types from the API for
283+
* existing fields.
284+
*
279285
* Defaults to false, which means the shape of the response will not be validated upfront.
280286
* Instead, validation will only occur for the parts of the response that are accessed.
281287
*/

finch-java-core/src/main/kotlin/com/tryfinch/api/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
}

finch-java-core/src/main/kotlin/com/tryfinch/api/models/AccessTokenCreateParams.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,15 @@ private constructor(
554554

555555
private var validated: Boolean = false
556556

557+
/**
558+
* Validates that the types of all values in this object match their expected types
559+
* recursively.
560+
*
561+
* This method is _not_ forwards compatible with new types from the API for existing fields.
562+
*
563+
* @throws FinchInvalidDataException if any value type in this object doesn't match its
564+
* expected type.
565+
*/
557566
fun validate(): CreateAccessTokenRequest = apply {
558567
if (validated) {
559568
return@apply

finch-java-core/src/main/kotlin/com/tryfinch/api/models/AccountCreateResponse.kt

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

421421
private var validated: Boolean = false
422422

423+
/**
424+
* Validates that the types of all values in this object match their expected types recursively.
425+
*
426+
* This method is _not_ forwards compatible with new types from the API for existing fields.
427+
*
428+
* @throws FinchInvalidDataException if any value type in this object doesn't match its expected
429+
* type.
430+
*/
423431
fun validate(): AccountCreateResponse = apply {
424432
if (validated) {
425433
return@apply
@@ -563,6 +571,15 @@ private constructor(
563571

564572
private var validated: Boolean = false
565573

574+
/**
575+
* Validates that the types of all values in this object match their expected types
576+
* recursively.
577+
*
578+
* This method is _not_ forwards compatible with new types from the API for existing fields.
579+
*
580+
* @throws FinchInvalidDataException if any value type in this object doesn't match its
581+
* expected type.
582+
*/
566583
fun validate(): AuthenticationType = apply {
567584
if (validated) {
568585
return@apply

0 commit comments

Comments
 (0)