Added support for BigInteger and BigDecimal in responses (#76)
This commit is contained in:
@ -1,5 +1,11 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## [1.5.0] - July 25th, 2021
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Added support for BigInteger and BigDecimal in response types
|
||||||
|
|
||||||
## [1.4.0] - July 22nd, 2021
|
## [1.4.0] - July 22nd, 2021
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# Kompendium
|
# Kompendium
|
||||||
project.version=1.4.0
|
project.version=1.5.0
|
||||||
# Kotlin
|
# Kotlin
|
||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
# Gradle
|
# Gradle
|
||||||
|
@ -23,6 +23,8 @@ import kotlin.reflect.full.memberProperties
|
|||||||
import kotlin.reflect.jvm.javaField
|
import kotlin.reflect.jvm.javaField
|
||||||
import kotlin.reflect.typeOf
|
import kotlin.reflect.typeOf
|
||||||
import org.slf4j.LoggerFactory
|
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.
|
* 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"))
|
String::class -> cache.plus(clazz.simpleName!! to SimpleSchema("string"))
|
||||||
Boolean::class -> cache.plus(clazz.simpleName!! to SimpleSchema("boolean"))
|
Boolean::class -> cache.plus(clazz.simpleName!! to SimpleSchema("boolean"))
|
||||||
UUID::class -> cache.plus(clazz.simpleName!! to FormatSchema("uuid", "string"))
|
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 {
|
else -> when {
|
||||||
clazz.isSubclassOf(Collection::class) -> handleCollectionType(type, clazz, cache)
|
clazz.isSubclassOf(Collection::class) -> handleCollectionType(type, clazz, cache)
|
||||||
clazz.isSubclassOf(Enum::class) -> handleEnumType(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.FormatSchema
|
||||||
import io.bkbn.kompendium.models.oas.ObjectSchema
|
import io.bkbn.kompendium.models.oas.ObjectSchema
|
||||||
import io.bkbn.kompendium.models.oas.ReferencedSchema
|
import io.bkbn.kompendium.models.oas.ReferencedSchema
|
||||||
import io.bkbn.kompendium.util.ComplexRequest
|
import io.bkbn.kompendium.util.*
|
||||||
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
|
|
||||||
|
|
||||||
@ExperimentalStdlibApi
|
@ExperimentalStdlibApi
|
||||||
internal class KontentTest {
|
internal class KontentTest {
|
||||||
@ -45,6 +37,18 @@ internal class KontentTest {
|
|||||||
assertEquals(FormatSchema("int64", "integer"), result["Long"])
|
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
|
@Test
|
||||||
fun `Objects reference their base types in the cache`() {
|
fun `Objects reference their base types in the cache`() {
|
||||||
// do
|
// do
|
||||||
|
@ -4,9 +4,13 @@ import java.util.UUID
|
|||||||
import io.bkbn.kompendium.annotations.KompendiumField
|
import io.bkbn.kompendium.annotations.KompendiumField
|
||||||
import io.bkbn.kompendium.annotations.KompendiumParam
|
import io.bkbn.kompendium.annotations.KompendiumParam
|
||||||
import io.bkbn.kompendium.annotations.ParamType
|
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 TestSimpleModel(val a: String, val b: Int)
|
||||||
|
|
||||||
|
data class TestBigNumberModel(val a: BigDecimal, val b: BigInteger)
|
||||||
|
|
||||||
data class TestNestedModel(val inner: TestSimpleModel)
|
data class TestNestedModel(val inner: TestSimpleModel)
|
||||||
|
|
||||||
data class TestSimpleWithEnums(val a: String, val b: SimpleEnum)
|
data class TestSimpleWithEnums(val a: String, val b: SimpleEnum)
|
||||||
|
Reference in New Issue
Block a user