kaml
kaml copied to clipboard
Yaml and YamlConfiguration Builders
Describe the problem you'd like to solve
When using other serialization libraries, I got used to the ability to create everything using builders. This is very lacking in this library.
Describe the solution you'd like
According to my ideas, it might look something like this:
fun Yaml(
serializersModule: SerializersModule = EmptySerializersModule,
configuration: YamlConfigurationBuilder.() -> Unit,
): Yaml = Yaml(
serializersModule = serializersModule,
configuration = YamlConfigurationBuilder().apply(configuration).build(),
)
class YamlConfigurationBuilder {
var encodeDefaults: Boolean = true
var strictMode: Boolean = true
var extensionDefinitionPrefix: String? = null
var polymorphismStyle: PolymorphismStyle = PolymorphismStyle.Tag
var polymorphismPropertyName: String = "type"
var encodingIndentationSize: Int = 2
var breakScalarsAt: Int = 80
var sequenceStyle: SequenceStyle = SequenceStyle.Block
var singleLineStringStyle: SingleLineStringStyle = SingleLineStringStyle.DoubleQuoted
var multiLineStringStyle: MultiLineStringStyle = singleLineStringStyle.multiLineStringStyle
fun build() = YamlConfiguration(
encodeDefaults = encodeDefaults,
strictMode = strictMode,
extensionDefinitionPrefix = extensionDefinitionPrefix,
polymorphismStyle = polymorphismStyle,
polymorphismPropertyName = polymorphismPropertyName,
encodingIndentationSize = encodingIndentationSize,
breakScalarsAt = breakScalarsAt,
sequenceStyle = sequenceStyle,
singleLineStringStyle = singleLineStringStyle,
multiLineStringStyle = multiLineStringStyle,
)
}
Describe alternatives you've considered
No response
Additional context
No response
Hi @YuryMikhailuts, this looks good to me. Would you be interested in submitting a PR with this?
Hi @YuryMikhailuts, this looks good to me. Would you be interested in submitting a PR with this?
Unfortunately, I have a lot of work to do right now. Creating this discussion is all I can do right now. It is possible that I will join your project later.
This issue has been automatically marked as stale because it has not had any activity in the last 60 days. It will automatically be closed if no further activity occurs in the next seven days to enable maintainers to focus on the most important issues. If this issue is still affecting you, please comment below within the next seven days. Thank you for your contributions.
This issue has been automatically closed because it has not had any recent activity.