Added support for ByteArray type (#88)

This commit is contained in:
adrG2
2021-10-17 18:43:46 +02:00
committed by GitHub
parent 1a924058a1
commit 67bd6ad36f
5 changed files with 22 additions and 1 deletions

View File

@ -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

View File

@ -1,5 +1,5 @@
# Kompendium
project.version=1.8.1
project.version=1.9.0
# Kotlin
kotlin.code.style=official
# Gradle

View File

@ -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)

View File

@ -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

View File

@ -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)