Added support for BigInteger and BigDecimal in responses (#76)
This commit is contained in:
@ -1,5 +1,11 @@
|
||||
# Changelog
|
||||
|
||||
## [1.5.0] - July 25th, 2021
|
||||
|
||||
### Changed
|
||||
|
||||
- Added support for BigInteger and BigDecimal in response types
|
||||
|
||||
## [1.4.0] - July 22nd, 2021
|
||||
|
||||
### Changed
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Kompendium
|
||||
project.version=1.4.0
|
||||
project.version=1.5.0
|
||||
# Kotlin
|
||||
kotlin.code.style=official
|
||||
# Gradle
|
||||
|
@ -23,6 +23,8 @@ import kotlin.reflect.full.memberProperties
|
||||
import kotlin.reflect.jvm.javaField
|
||||
import kotlin.reflect.typeOf
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.math.BigDecimal
|
||||
import java.math.BigInteger
|
||||
|
||||
/**
|
||||
* Responsible for generating the schema map that is used to power all object references across the API Spec.
|
||||
@ -106,6 +108,8 @@ object Kontent {
|
||||
String::class -> cache.plus(clazz.simpleName!! to SimpleSchema("string"))
|
||||
Boolean::class -> cache.plus(clazz.simpleName!! to SimpleSchema("boolean"))
|
||||
UUID::class -> cache.plus(clazz.simpleName!! to FormatSchema("uuid", "string"))
|
||||
BigDecimal::class -> cache.plus(clazz.simpleName!! to FormatSchema("double", "number"))
|
||||
BigInteger::class -> cache.plus(clazz.simpleName!! to FormatSchema("int64", "integer"))
|
||||
else -> when {
|
||||
clazz.isSubclassOf(Collection::class) -> handleCollectionType(type, clazz, cache)
|
||||
clazz.isSubclassOf(Enum::class) -> handleEnumType(clazz, cache)
|
||||
|
@ -13,15 +13,7 @@ import io.bkbn.kompendium.models.oas.DictionarySchema
|
||||
import io.bkbn.kompendium.models.oas.FormatSchema
|
||||
import io.bkbn.kompendium.models.oas.ObjectSchema
|
||||
import io.bkbn.kompendium.models.oas.ReferencedSchema
|
||||
import io.bkbn.kompendium.util.ComplexRequest
|
||||
import io.bkbn.kompendium.util.TestInvalidMap
|
||||
import io.bkbn.kompendium.util.TestNestedModel
|
||||
import io.bkbn.kompendium.util.TestSimpleModel
|
||||
import io.bkbn.kompendium.util.TestSimpleWithEnumList
|
||||
import io.bkbn.kompendium.util.TestSimpleWithEnums
|
||||
import io.bkbn.kompendium.util.TestSimpleWithList
|
||||
import io.bkbn.kompendium.util.TestSimpleWithMap
|
||||
import io.bkbn.kompendium.util.TestWithUUID
|
||||
import io.bkbn.kompendium.util.*
|
||||
|
||||
@ExperimentalStdlibApi
|
||||
internal class KontentTest {
|
||||
@ -45,6 +37,18 @@ internal class KontentTest {
|
||||
assertEquals(FormatSchema("int64", "integer"), result["Long"])
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Object with BigDecimal and BigInteger types`() {
|
||||
// do
|
||||
val result = generateKontent<TestBigNumberModel>()
|
||||
|
||||
// expect
|
||||
assertEquals(3, result.count())
|
||||
assertTrue { result.containsKey(TestBigNumberModel::class.simpleName) }
|
||||
assertEquals(FormatSchema("double", "number"), result["BigDecimal"])
|
||||
assertEquals(FormatSchema("int64", "integer"), result["BigInteger"])
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Objects reference their base types in the cache`() {
|
||||
// do
|
||||
|
@ -4,9 +4,13 @@ import java.util.UUID
|
||||
import io.bkbn.kompendium.annotations.KompendiumField
|
||||
import io.bkbn.kompendium.annotations.KompendiumParam
|
||||
import io.bkbn.kompendium.annotations.ParamType
|
||||
import java.math.BigDecimal
|
||||
import java.math.BigInteger
|
||||
|
||||
data class TestSimpleModel(val a: String, val b: Int)
|
||||
|
||||
data class TestBigNumberModel(val a: BigDecimal, val b: BigInteger)
|
||||
|
||||
data class TestNestedModel(val inner: TestSimpleModel)
|
||||
|
||||
data class TestSimpleWithEnums(val a: String, val b: SimpleEnum)
|
||||
|
Reference in New Issue
Block a user