Commit 2790901b authored by Setako's avatar Setako

[Fix] Yaml parser format

parent 7d9089a4
......@@ -3,6 +3,7 @@ package dev.reactant.reactant.extra.parser
import dev.reactant.reactant.core.component.Component
import dev.reactant.reactant.service.spec.parser.YamlParserService
import io.reactivex.rxjava3.core.Single
import org.yaml.snakeyaml.DumperOptions
import org.yaml.snakeyaml.Yaml
import org.yaml.snakeyaml.constructor.CustomClassLoaderConstructor
import org.yaml.snakeyaml.nodes.Tag
......@@ -11,8 +12,14 @@ import kotlin.reflect.KClass
@Component
class SnakeYamlParserService : YamlParserService {
private val representer = Representer()
private val yaml = Yaml(CustomClassLoaderConstructor(this.javaClass.classLoader), representer)
private val options = DumperOptions().apply {
defaultFlowStyle = DumperOptions.FlowStyle.BLOCK
indent = 2
isPrettyFlow = true
}
private val representer = Representer(options)
private val yaml = Yaml(CustomClassLoaderConstructor(this.javaClass.classLoader), representer, options)
override fun encode(obj: Any): Single<String> =
Single.defer {
representer.addClassTag(obj::class.java, Tag.MAP)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment