Skip to content

Commit

Permalink
Merge pull request #372 from atlanhq/chris
Browse files Browse the repository at this point in the history
Remove object field spacing from generated custom package JSONs
  • Loading branch information
cmgrote authored Dec 6, 2023
2 parents e685131 + 7d7aca4 commit bab5adb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import com.atlan.pkg.config.widgets.NumericInput
import com.atlan.util.StringUtils
import com.fasterxml.jackson.annotation.JsonIgnore
import com.fasterxml.jackson.annotation.JsonInclude
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter
import com.fasterxml.jackson.core.util.Separators
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator
import com.fasterxml.jackson.dataformat.yaml.YAMLMapper
Expand Down Expand Up @@ -134,7 +136,7 @@ open class CustomPackage(
* @return package.json content
*/
fun packageJSON(): String {
return json.writerWithDefaultPrettyPrinter().writeValueAsString(pkg)
return json.writer(pp).writeValueAsString(pkg)
}

/**
Expand Down Expand Up @@ -233,6 +235,7 @@ open class CustomPackage(
.build()
.registerKotlinModule()
val json: ObjectMapper = jacksonObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL)
val pp: DefaultPrettyPrinter = DefaultPrettyPrinter().withSeparators(Separators.createDefaultInstance().withObjectFieldValueSpacing(Separators.Spacing.AFTER))

fun generate(pkg: CustomPackage, args: Array<String>) {
when (args[0]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Copyright 2023 Atlan Pte. Ltd. */
package com.atlan.pkg.config.model

import com.atlan.pkg.CustomPackage.Companion.pp
import com.atlan.pkg.config.model.ui.UIConfig
import com.fasterxml.jackson.annotation.JsonInclude
import com.fasterxml.jackson.annotation.JsonPropertyOrder
Expand All @@ -18,7 +19,7 @@ class ConfigMap(private val name: String, config: UIConfig) {
val metadata = mapOf("name" to name)
val data: Map<String, String>
init {
data = mapOf("config" to mapper.writerWithDefaultPrettyPrinter().writeValueAsString(config))
data = mapOf("config" to mapper.writer(pp).writeValueAsString(config))
}
companion object {
private val mapper = jacksonObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL)
Expand Down

0 comments on commit bab5adb

Please sign in to comment.