All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ancientlightstudios.quarkus.kotlin.openapi.emitter.deserialization.Deserialization.kt Maven / Gradle / Ivy

There is a newer version: 0.4.14
Show newest version
package com.ancientlightstudios.quarkus.kotlin.openapi.emitter.deserialization

import com.ancientlightstudios.quarkus.kotlin.openapi.models.kotlin.Kotlin
import com.ancientlightstudios.quarkus.kotlin.openapi.models.kotlin.TypeName
import com.ancientlightstudios.quarkus.kotlin.openapi.models.kotlin.TypeName.GenericTypeName.Companion.of
import com.ancientlightstudios.quarkus.kotlin.openapi.models.kotlin.TypeName.SimpleTypeName.Companion.typeName
import com.ancientlightstudios.quarkus.kotlin.openapi.models.types.CollectionTypeDefinition
import com.ancientlightstudios.quarkus.kotlin.openapi.models.types.TypeUsage

object Deserialization {

    // returns the "unsafe" type for a type in a request parameter or body
    // it's List<?> for collections
    // and String? for everything else
    // TODO: binary types
    fun TypeUsage.getDeserializationSourceType(): TypeName {
        return when (val safeType = this.type) {
            is CollectionTypeDefinition -> Kotlin.ListClass.typeName(true)
                .of(safeType.items.getDeserializationSourceType())

            else -> Kotlin.StringClass.typeName(true)
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy