Added support for ByteArray type (#88)
This commit is contained in:
@ -1,5 +1,12 @@
|
||||
# Changelog
|
||||
|
||||
## [1.9.0] - october 15th, 2021
|
||||
|
||||
### Added
|
||||
|
||||
- ByteArray added to the set of default types
|
||||
|
||||
|
||||
## [1.8.1] - October 4th, 2021
|
||||
|
||||
### Added
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Kompendium
|
||||
project.version=1.8.1
|
||||
project.version=1.9.0
|
||||
# Kotlin
|
||||
kotlin.code.style=official
|
||||
# Gradle
|
||||
|
@ -127,6 +127,7 @@ object Kontent {
|
||||
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"))
|
||||
ByteArray::class -> cache.plus(clazz.simpleName!! to FormatSchema("byte", "string"))
|
||||
else -> when {
|
||||
clazz.isSubclassOf(Collection::class) -> handleCollectionType(type, clazz, cache)
|
||||
clazz.isSubclassOf(Enum::class) -> handleEnumType(clazz, cache)
|
||||
|
@ -49,6 +49,17 @@ internal class KontentTest {
|
||||
assertEquals(FormatSchema("int64", "integer"), result["BigInteger"])
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Object with ByteArray type`() {
|
||||
// do
|
||||
val result = generateKontent<TestByteArrayModel>()
|
||||
|
||||
// expect
|
||||
assertEquals(2, result.count())
|
||||
assertTrue { result.containsKey(TestByteArrayModel::class.simpleName) }
|
||||
assertEquals(FormatSchema("byte", "string"), result["ByteArray"])
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Objects reference their base types in the cache`() {
|
||||
// do
|
||||
|
@ -12,6 +12,8 @@ data class TestSimpleModel(val a: String, val b: Int)
|
||||
|
||||
data class TestBigNumberModel(val a: BigDecimal, val b: BigInteger)
|
||||
|
||||
data class TestByteArrayModel(val a: ByteArray)
|
||||
|
||||
data class TestNestedModel(val inner: TestSimpleModel)
|
||||
|
||||
data class TestSimpleWithEnums(val a: String, val b: SimpleEnum)
|
||||
|
Reference in New Issue
Block a user