Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.52.0"
".": "0.52.1"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 103
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-36a6db97756e8658369c9af3c0ac532ecacb032e5b8f6211094dcb4052943ff3.yml
openapi_spec_hash: 26886fa8e59fa3674320897e3409e540
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-95a3d7780935a38e0cf076d4ad2d68bd1a5641bced8398d972db2e92751d364a.yml
openapi_spec_hash: 9ebe818c4ad4f2d9c4e473b5192d7544
config_hash: ec4f1e02d3528e3a93a73e33bca17c2a
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## 0.52.1 (2025-03-31)

Full Changelog: [v0.52.0...v0.52.1](https://github.com/orbcorp/orb-java/compare/v0.52.0...v0.52.1)

### Bug Fixes

* **client:** limit json deserialization coercion ([#373](https://github.com/orbcorp/orb-java/issues/373)) ([654e81c](https://github.com/orbcorp/orb-java/commit/654e81cf520631050936ae5cf9397c0e4a9cf02b))


### Chores

* **internal:** codegen related update ([#371](https://github.com/orbcorp/orb-java/issues/371)) ([28dbf0a](https://github.com/orbcorp/orb-java/commit/28dbf0a107b892656275633f3805eb2d3c7f93fa))

## 0.52.0 (2025-03-26)

Full Changelog: [v0.51.0...v0.52.0](https://github.com/orbcorp/orb-java/compare/v0.51.0...v0.52.0)
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<!-- x-release-please-start-version -->

[![Maven Central](https://img.shields.io/maven-central/v/com.withorb.api/orb-java)](https://central.sonatype.com/artifact/com.withorb.api/orb-java/0.52.0)
[![Maven Central](https://img.shields.io/maven-central/v/com.withorb.api/orb-java)](https://central.sonatype.com/artifact/com.withorb.api/orb-java/0.52.1)

<!-- x-release-please-end -->

Expand All @@ -19,7 +19,7 @@ The REST API documentation can be found on [docs.withorb.com](https://docs.witho
### Gradle

```kotlin
implementation("com.withorb.api:orb-java:0.52.0")
implementation("com.withorb.api:orb-java:0.52.1")
```

### Maven
Expand All @@ -28,7 +28,7 @@ implementation("com.withorb.api:orb-java:0.52.0")
<dependency>
<groupId>com.withorb.api</groupId>
<artifactId>orb-java</artifactId>
<version>0.52.0</version>
<version>0.52.1</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
allprojects {
group = "com.withorb.api"
version = "0.52.0" // x-release-please-version
version = "0.52.1" // x-release-please-version
}
1 change: 1 addition & 0 deletions orb-java-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ dependencies {
testImplementation("org.assertj:assertj-core:3.25.3")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3")
testImplementation("org.junit.jupiter:junit-jupiter-params:5.9.3")
testImplementation("org.junit-pioneer:junit-pioneer:1.9.1")
testImplementation("org.mockito:mockito-core:5.14.2")
testImplementation("org.mockito:mockito-junit-jupiter:5.14.2")
testImplementation("org.mockito.kotlin:mockito-kotlin:4.1.0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.fasterxml.jackson.databind.JsonMappingException
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.deser.ContextualDeserializer
import com.fasterxml.jackson.databind.deser.std.StdDeserializer
import com.withorb.api.errors.OrbInvalidDataException
import kotlin.reflect.KClass

abstract class BaseDeserializer<T : Any>(type: KClass<T>) :
Expand All @@ -29,6 +30,13 @@ abstract class BaseDeserializer<T : Any>(type: KClass<T>) :

protected abstract fun ObjectCodec.deserialize(node: JsonNode): T

protected fun <T> ObjectCodec.deserialize(node: JsonNode, type: TypeReference<T>): T =
try {
readValue(treeAsTokens(node), type)
} catch (e: Exception) {
throw OrbInvalidDataException("Error deserializing", e)
}

protected fun <T> ObjectCodec.tryDeserialize(
node: JsonNode,
type: TypeReference<T>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ import com.fasterxml.jackson.databind.DeserializationFeature
import com.fasterxml.jackson.databind.MapperFeature
import com.fasterxml.jackson.databind.SerializationFeature
import com.fasterxml.jackson.databind.SerializerProvider
import com.fasterxml.jackson.databind.cfg.CoercionAction
import com.fasterxml.jackson.databind.cfg.CoercionInputShape
import com.fasterxml.jackson.databind.json.JsonMapper
import com.fasterxml.jackson.databind.module.SimpleModule
import com.fasterxml.jackson.databind.type.LogicalType
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
import com.fasterxml.jackson.module.kotlin.kotlinModule
Expand All @@ -21,6 +24,60 @@ fun jsonMapper(): JsonMapper =
.addModule(Jdk8Module())
.addModule(JavaTimeModule())
.addModule(SimpleModule().addSerializer(InputStreamJsonSerializer))
.withCoercionConfig(LogicalType.Boolean) {
it.setCoercion(CoercionInputShape.Integer, CoercionAction.Fail)
.setCoercion(CoercionInputShape.Float, CoercionAction.Fail)
.setCoercion(CoercionInputShape.String, CoercionAction.Fail)
.setCoercion(CoercionInputShape.Array, CoercionAction.Fail)
.setCoercion(CoercionInputShape.Object, CoercionAction.Fail)
}
.withCoercionConfig(LogicalType.Integer) {
it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail)
.setCoercion(CoercionInputShape.String, CoercionAction.Fail)
.setCoercion(CoercionInputShape.Array, CoercionAction.Fail)
.setCoercion(CoercionInputShape.Object, CoercionAction.Fail)
}
.withCoercionConfig(LogicalType.Float) {
it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail)
.setCoercion(CoercionInputShape.String, CoercionAction.Fail)
.setCoercion(CoercionInputShape.Array, CoercionAction.Fail)
.setCoercion(CoercionInputShape.Object, CoercionAction.Fail)
}
.withCoercionConfig(LogicalType.Textual) {
it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail)
.setCoercion(CoercionInputShape.Integer, CoercionAction.Fail)
.setCoercion(CoercionInputShape.Float, CoercionAction.Fail)
.setCoercion(CoercionInputShape.Array, CoercionAction.Fail)
.setCoercion(CoercionInputShape.Object, CoercionAction.Fail)
}
.withCoercionConfig(LogicalType.Array) {
it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail)
.setCoercion(CoercionInputShape.Integer, CoercionAction.Fail)
.setCoercion(CoercionInputShape.Float, CoercionAction.Fail)
.setCoercion(CoercionInputShape.String, CoercionAction.Fail)
.setCoercion(CoercionInputShape.Object, CoercionAction.Fail)
}
.withCoercionConfig(LogicalType.Collection) {
it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail)
.setCoercion(CoercionInputShape.Integer, CoercionAction.Fail)
.setCoercion(CoercionInputShape.Float, CoercionAction.Fail)
.setCoercion(CoercionInputShape.String, CoercionAction.Fail)
.setCoercion(CoercionInputShape.Object, CoercionAction.Fail)
}
.withCoercionConfig(LogicalType.Map) {
it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail)
.setCoercion(CoercionInputShape.Integer, CoercionAction.Fail)
.setCoercion(CoercionInputShape.Float, CoercionAction.Fail)
.setCoercion(CoercionInputShape.String, CoercionAction.Fail)
.setCoercion(CoercionInputShape.Object, CoercionAction.Fail)
}
.withCoercionConfig(LogicalType.POJO) {
it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail)
.setCoercion(CoercionInputShape.Integer, CoercionAction.Fail)
.setCoercion(CoercionInputShape.Float, CoercionAction.Fail)
.setCoercion(CoercionInputShape.String, CoercionAction.Fail)
.setCoercion(CoercionInputShape.Array, CoercionAction.Fail)
}
.serializationInclusion(JsonInclude.Include.NON_ABSENT)
.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE)
.disable(SerializationFeature.FLUSH_AFTER_WRITE_VALUE)
Expand Down
16 changes: 8 additions & 8 deletions orb-java-core/src/main/kotlin/com/withorb/api/models/Coupon.kt
Original file line number Diff line number Diff line change
Expand Up @@ -563,16 +563,16 @@ private constructor(

when (discountType) {
"percentage" -> {
tryDeserialize(node, jacksonTypeRef<PercentageDiscount>()) { it.validate() }
?.let {
return Discount(percentage = it, _json = json)
}
return Discount(
percentage = deserialize(node, jacksonTypeRef<PercentageDiscount>()),
_json = json,
)
}
"amount" -> {
tryDeserialize(node, jacksonTypeRef<AmountDiscount>()) { it.validate() }
?.let {
return Discount(amount = it, _json = json)
}
return Discount(
amount = deserialize(node, jacksonTypeRef<AmountDiscount>()),
_json = json,
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -875,20 +875,18 @@ private constructor(

when (discountType) {
"percentage" -> {
tryDeserialize(node, jacksonTypeRef<NewCouponPercentageDiscount>()) {
it.validate()
}
?.let {
return Discount(newCouponPercentage = it, _json = json)
}
return Discount(
newCouponPercentage =
deserialize(node, jacksonTypeRef<NewCouponPercentageDiscount>()),
_json = json,
)
}
"amount" -> {
tryDeserialize(node, jacksonTypeRef<NewCouponAmountDiscount>()) {
it.validate()
}
?.let {
return Discount(newCouponAmount = it, _json = json)
}
return Discount(
newCouponAmount =
deserialize(node, jacksonTypeRef<NewCouponAmountDiscount>()),
_json = json,
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4016,20 +4016,17 @@ private constructor(

when (taxProvider) {
"avalara" -> {
tryDeserialize(node, jacksonTypeRef<NewAvalaraTaxConfiguration>()) {
it.validate()
}
?.let {
return TaxConfiguration(newAvalara = it, _json = json)
}
return TaxConfiguration(
newAvalara =
deserialize(node, jacksonTypeRef<NewAvalaraTaxConfiguration>()),
_json = json,
)
}
"taxjar" -> {
tryDeserialize(node, jacksonTypeRef<NewTaxJarConfiguration>()) {
it.validate()
}
?.let {
return TaxConfiguration(newTaxJar = it, _json = json)
}
return TaxConfiguration(
newTaxJar = deserialize(node, jacksonTypeRef<NewTaxJarConfiguration>()),
_json = json,
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -724,74 +724,56 @@ private constructor(

when (entryType) {
"increment" -> {
tryDeserialize(
node,
jacksonTypeRef<AddIncrementCreditLedgerEntryRequestParams>(),
) {
it.validate()
}
?.let {
return Body(
addIncrementCreditLedgerEntryRequestParams = it,
_json = json,
)
}
return Body(
addIncrementCreditLedgerEntryRequestParams =
deserialize(
node,
jacksonTypeRef<AddIncrementCreditLedgerEntryRequestParams>(),
),
_json = json,
)
}
"decrement" -> {
tryDeserialize(
node,
jacksonTypeRef<AddDecrementCreditLedgerEntryRequestParams>(),
) {
it.validate()
}
?.let {
return Body(
addDecrementCreditLedgerEntryRequestParams = it,
_json = json,
)
}
return Body(
addDecrementCreditLedgerEntryRequestParams =
deserialize(
node,
jacksonTypeRef<AddDecrementCreditLedgerEntryRequestParams>(),
),
_json = json,
)
}
"expiration_change" -> {
tryDeserialize(
node,
jacksonTypeRef<AddExpirationChangeCreditLedgerEntryRequestParams>(),
) {
it.validate()
}
?.let {
return Body(
addExpirationChangeCreditLedgerEntryRequestParams = it,
_json = json,
)
}
return Body(
addExpirationChangeCreditLedgerEntryRequestParams =
deserialize(
node,
jacksonTypeRef<
AddExpirationChangeCreditLedgerEntryRequestParams
>(),
),
_json = json,
)
}
"void" -> {
tryDeserialize(
node,
jacksonTypeRef<AddVoidCreditLedgerEntryRequestParams>(),
) {
it.validate()
}
?.let {
return Body(
addVoidCreditLedgerEntryRequestParams = it,
_json = json,
)
}
return Body(
addVoidCreditLedgerEntryRequestParams =
deserialize(
node,
jacksonTypeRef<AddVoidCreditLedgerEntryRequestParams>(),
),
_json = json,
)
}
"amendment" -> {
tryDeserialize(
node,
jacksonTypeRef<AddAmendmentCreditLedgerEntryRequestParams>(),
) {
it.validate()
}
?.let {
return Body(
addAmendmentCreditLedgerEntryRequestParams = it,
_json = json,
)
}
return Body(
addAmendmentCreditLedgerEntryRequestParams =
deserialize(
node,
jacksonTypeRef<AddAmendmentCreditLedgerEntryRequestParams>(),
),
_json = json,
)
}
}

Expand Down
Loading
Loading