Skip to content

Commit 0053367

Browse files
docs: clarify forwards compat behavior
1 parent 8396fdd commit 0053367

47 files changed

Lines changed: 1812 additions & 1 deletion

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
@@ -706,7 +706,9 @@ In rare cases, the API may return a response that doesn't match the expected typ
706706

707707
By default, the SDK will not throw an exception in this case. It will throw [`ArcadeInvalidDataException`](arcade-java-core/src/main/kotlin/dev/arcade/errors/ArcadeInvalidDataException.kt) only if you directly access the property.
708708

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

711713
```java
712714
import dev.arcade.models.tools.ExecuteToolResponse;

arcade-java-client-okhttp/src/main/kotlin/dev/arcade/client/okhttp/ArcadeOkHttpClient.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ class ArcadeOkHttpClient 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
*/

arcade-java-client-okhttp/src/main/kotlin/dev/arcade/client/okhttp/ArcadeOkHttpClientAsync.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ class ArcadeOkHttpClientAsync 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
*/

arcade-java-core/src/main/kotlin/dev/arcade/core/ClientOptions.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ private constructor(
8080
/**
8181
* Whether to call `validate` on every response before returning it.
8282
*
83+
* Setting this to `true` is _not_ forwards compatible with new types from the API for existing
84+
* fields.
85+
*
8386
* Defaults to false, which means the shape of the response will not be validated upfront.
8487
* Instead, validation will only occur for the parts of the response that are accessed.
8588
*/
@@ -260,6 +263,9 @@ private constructor(
260263
/**
261264
* Whether to call `validate` on every response before returning it.
262265
*
266+
* Setting this to `true` is _not_ forwards compatible with new types from the API for
267+
* existing fields.
268+
*
263269
* Defaults to false, which means the shape of the response will not be validated upfront.
264270
* Instead, validation will only occur for the parts of the response that are accessed.
265271
*/

arcade-java-core/src/main/kotlin/dev/arcade/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
}

arcade-java-core/src/main/kotlin/dev/arcade/models/AuthorizationContext.kt

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

141141
private var validated: Boolean = false
142142

143+
/**
144+
* Validates that the types of all values in this object match their expected types recursively.
145+
*
146+
* This method is _not_ forwards compatible with new types from the API for existing fields.
147+
*
148+
* @throws ArcadeInvalidDataException if any value type in this object doesn't match its
149+
* expected type.
150+
*/
143151
fun validate(): AuthorizationContext = apply {
144152
if (validated) {
145153
return@apply
@@ -226,6 +234,15 @@ private constructor(
226234

227235
private var validated: Boolean = false
228236

237+
/**
238+
* Validates that the types of all values in this object match their expected types
239+
* recursively.
240+
*
241+
* This method is _not_ forwards compatible with new types from the API for existing fields.
242+
*
243+
* @throws ArcadeInvalidDataException if any value type in this object doesn't match its
244+
* expected type.
245+
*/
229246
fun validate(): UserInfo = apply {
230247
if (validated) {
231248
return@apply

arcade-java-core/src/main/kotlin/dev/arcade/models/AuthorizationResponse.kt

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

309309
private var validated: Boolean = false
310310

311+
/**
312+
* Validates that the types of all values in this object match their expected types recursively.
313+
*
314+
* This method is _not_ forwards compatible with new types from the API for existing fields.
315+
*
316+
* @throws ArcadeInvalidDataException if any value type in this object doesn't match its
317+
* expected type.
318+
*/
311319
fun validate(): AuthorizationResponse = apply {
312320
if (validated) {
313321
return@apply
@@ -445,6 +453,15 @@ private constructor(
445453

446454
private var validated: Boolean = false
447455

456+
/**
457+
* Validates that the types of all values in this object match their expected types
458+
* recursively.
459+
*
460+
* This method is _not_ forwards compatible with new types from the API for existing fields.
461+
*
462+
* @throws ArcadeInvalidDataException if any value type in this object doesn't match its
463+
* expected type.
464+
*/
448465
fun validate(): Status = apply {
449466
if (validated) {
450467
return@apply

arcade-java-core/src/main/kotlin/dev/arcade/models/Error.kt

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

137137
private var validated: Boolean = false
138138

139+
/**
140+
* Validates that the types of all values in this object match their expected types recursively.
141+
*
142+
* This method is _not_ forwards compatible with new types from the API for existing fields.
143+
*
144+
* @throws ArcadeInvalidDataException if any value type in this object doesn't match its
145+
* expected type.
146+
*/
139147
fun validate(): Error = apply {
140148
if (validated) {
141149
return@apply

0 commit comments

Comments
 (0)