From c9ef7efa55cb3e123568298e322d059377afba2e Mon Sep 17 00:00:00 2001 From: Guillermo Mazzola Date: Mon, 8 Jan 2024 11:17:32 +0100 Subject: [PATCH] Fix crash when `description` contains `%` --- .../com/mparticle/smartype/generator/SmartypeObject.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/smartype-generator/src/main/kotlin/com/mparticle/smartype/generator/SmartypeObject.kt b/smartype-generator/src/main/kotlin/com/mparticle/smartype/generator/SmartypeObject.kt index 5ae7fb4..463fe04 100644 --- a/smartype-generator/src/main/kotlin/com/mparticle/smartype/generator/SmartypeObject.kt +++ b/smartype-generator/src/main/kotlin/com/mparticle/smartype/generator/SmartypeObject.kt @@ -37,7 +37,7 @@ class SmartypeObject(options: GeneratorOptions) { } file = FileSpec.builder(packageName(isWeb), libraryName) - .addComment("CODE GENERATED BY SMARTYPE, DO NOT MODIFY.") + .addComment("%S", "CODE GENERATED BY SMARTYPE, DO NOT MODIFY.") file.addImport("com.mparticle.smartype.api", "Message") file.addImport("kotlinx.serialization.json", "JsonElement") file.addImport("kotlinx.serialization.json", "JsonObject") @@ -157,8 +157,8 @@ class SmartypeObject(options: GeneratorOptions) { val schemaDescription: JsonPrimitive? if (definition.containsKey("description")) { schemaDescription = definition["description"] as JsonPrimitive - if (!schemaDescription.content.isBlank()) { - dpClassPoint.addKdoc(schemaDescription.content) + if (schemaDescription.content.isNotBlank()) { + dpClassPoint.addKdoc("%S", schemaDescription.content) } } @@ -449,8 +449,8 @@ class SmartypeObject(options: GeneratorOptions) { propertyBuilder.addModifiers(KModifier.PUBLIC) - if (description != null && !description.isBlank()) { - propertyBuilder.addKdoc(description) + if (!description.isNullOrBlank()) { + propertyBuilder.addKdoc("%S", description) } dpClassPoint.addProperty(