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

io.vrap.codegen.languages.bruno.model.Serializers.kt Maven / Gradle / Ivy

Go to download

RAML API client code generators based on the REST Modeling Framework. https://github.com/vrapio/rest-modeling-framework

There is a newer version: 1.0.0-20241120142200
Show newest version
package io.vrap.codegen.languages.bruno.model

import com.fasterxml.jackson.core.JsonGenerator
import com.fasterxml.jackson.databind.SerializerProvider
import com.fasterxml.jackson.databind.ser.std.StdSerializer
import io.vrap.rmf.raml.model.types.Instance
import io.vrap.rmf.raml.model.types.ObjectInstance
import java.io.IOException

class InstanceSerializer @JvmOverloads constructor(t: Class? = null) : StdSerializer(t) {

    @Throws(IOException::class)
    override fun serialize(value: Instance, gen: JsonGenerator, provider: SerializerProvider) {
        gen.writeObject(value.value)
    }
}

class ObjectInstanceSerializer @JvmOverloads constructor(t: Class? = null) : StdSerializer(t) {

    @Throws(IOException::class)
    override fun serialize(value: ObjectInstance, gen: JsonGenerator, provider: SerializerProvider) {
        val properties = value.value
        gen.writeStartObject()
        for (v in properties) {
            gen.writeObjectField(v.name, v.value)
        }
        gen.writeEndObject()
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy