Bugfix #17149: Asciidoc generator sets not defined example values wrongly to the string value "null" instead of the expected not set value (#20670)

Co-authored-by: Karsten Leonhardt <karsten.leonhardt@commerzbank.com>
This commit is contained in:
Karsten Leonhardt 2025-02-17 14:18:37 +01:00 committed by GitHub
parent a6280d9b58
commit c5863629c0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -16,8 +16,10 @@
package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.media.Schema;
import lombok.Getter;
import lombok.Setter;
import io.swagger.v3.oas.models.media.Schema;
import org.openapitools.codegen.*;
import java.io.File;
@ -326,6 +328,27 @@ public class AsciidocDocumentationCodegen extends DefaultCodegen implements Code
}
}
// override to avoid printing of string "null"
// when no example exists
@Override
public String toExampleValue(Schema schema) {
if (schema.getExample() != null) {
return schema.getExample().toString();
}
return null;
}
// Avoid additional escapes of \ -> \\, " -> \"
// in regular expressions that are
// introduced by the `escapeText` method.
// Note: We don't need this here since we want to print
// the plain regular expression
// Therefore, override this method to skip `escapeText`.
@Override
public String toRegularExpression(String pattern) {
return addRegularExpressionDelimiter(pattern);
}
@Override
public void processOpenAPI(OpenAPI openAPI) {
if (this.includeSpecMarkupLambda != null) {