From 7fc64dbf203d05acac63ed3d67f765906fa3c9c3 Mon Sep 17 00:00:00 2001 From: Albert Tregnaghi Date: Tue, 26 Nov 2024 15:56:04 +0100 Subject: [PATCH 1/2] Added query parameters to generated documentation output #3647 --- .../sechub/sharedkernel/usecases/UseCaseRestDoc.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sechub-shared-kernel/src/main/java/com/mercedesbenz/sechub/sharedkernel/usecases/UseCaseRestDoc.java b/sechub-shared-kernel/src/main/java/com/mercedesbenz/sechub/sharedkernel/usecases/UseCaseRestDoc.java index 982cf065ba..8190e25757 100644 --- a/sechub-shared-kernel/src/main/java/com/mercedesbenz/sechub/sharedkernel/usecases/UseCaseRestDoc.java +++ b/sechub-shared-kernel/src/main/java/com/mercedesbenz/sechub/sharedkernel/usecases/UseCaseRestDoc.java @@ -50,6 +50,7 @@ SpringRestDocOutput[] wanted() default { /* @formatter:off */ SpringRestDocOutput.PATH_PARAMETERS, + SpringRestDocOutput.QUERY_PARAMETERS, SpringRestDocOutput.REQUEST_PARAMETERS, @@ -91,6 +92,8 @@ public enum SpringRestDocOutput{ PATH_PARAMETERS("path-parameters.adoc",SpringRestDocType.DEFINITION), + QUERY_PARAMETERS("query-parameters.adoc",SpringRestDocType.DEFINITION), + REQUEST_PARAMETERS("request-parameters.adoc",SpringRestDocType.DEFINITION), REQUEST_HEADERS("request-headers.adoc",SpringRestDocType.DEFINITION), From ca830a67ff6a19880b2d490a7df415b1dd18dde5 Mon Sep 17 00:00:00 2001 From: Albert Tregnaghi Date: Tue, 26 Nov 2024 16:45:15 +0100 Subject: [PATCH 2/2] Fix scope calculation #3652 --- .../sechub/docgen/util/DocGeneratorUtil.java | 13 ++++++++++--- .../sechub/docgen/util/DocGenUtilTest.java | 8 ++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/sechub-doc/src/main/java/com/mercedesbenz/sechub/docgen/util/DocGeneratorUtil.java b/sechub-doc/src/main/java/com/mercedesbenz/sechub/docgen/util/DocGeneratorUtil.java index 6e4208fe27..47eaca42dc 100644 --- a/sechub-doc/src/main/java/com/mercedesbenz/sechub/docgen/util/DocGeneratorUtil.java +++ b/sechub-doc/src/main/java/com/mercedesbenz/sechub/docgen/util/DocGeneratorUtil.java @@ -84,21 +84,28 @@ static Class fetchClass(AnnotatedElement element) { /** * Reduces string to second upper cased char - e.g. "NetsparkerInstallSetupImpl" - * would be replaced to "Netsparker" + * would be replaced to "Netsparker". Having multiple upper case letters at the + * beginning will keep all upper cased parts. E.g. "SMTPServerConfiguration" + * will become "SMTPServer" * * @param clazz - * @return + * @return string, never null */ public static String toCamelOne(Class clazz) { StringBuilder sb = new StringBuilder(); String clazzName = clazz.getSimpleName(); boolean first = true; + boolean atLeastOneLowerCaseFound = false; for (char c : clazzName.toCharArray()) { if (first) { first = false; } else { - if (Character.isUpperCase(c)) { + boolean upperCase = Character.isUpperCase(c); + if (!atLeastOneLowerCaseFound) { + atLeastOneLowerCaseFound = !upperCase; + } + if (upperCase && atLeastOneLowerCaseFound) { break; } } diff --git a/sechub-doc/src/test/java/com/mercedesbenz/sechub/docgen/util/DocGenUtilTest.java b/sechub-doc/src/test/java/com/mercedesbenz/sechub/docgen/util/DocGenUtilTest.java index c38ff2d0d8..521403f05c 100644 --- a/sechub-doc/src/test/java/com/mercedesbenz/sechub/docgen/util/DocGenUtilTest.java +++ b/sechub-doc/src/test/java/com/mercedesbenz/sechub/docgen/util/DocGenUtilTest.java @@ -11,6 +11,9 @@ import com.mercedesbenz.sechub.docgen.DocAnnotationData; import com.mercedesbenz.sechub.docgen.spring.SpringValueFilter; +import com.mercedesbenz.sechub.domain.notification.email.SMTPServerConfiguration; +import com.mercedesbenz.sechub.domain.scan.product.checkmarx.SecHubDirectCheckmarxResilienceConfiguration; +import com.mercedesbenz.sechub.domain.scan.product.pds.PDSResilienceConsultant; import com.mercedesbenz.sechub.sharedkernel.MustBeDocumented; public class DocGenUtilTest { @@ -40,6 +43,11 @@ public void toCamelOne_returns_first_part_of_simple_classname_until_second_upper assertEquals("String", DocGeneratorUtil.toCamelOne(String.class)); assertEquals("Class", DocGeneratorUtil.toCamelOne(Class.class)); + assertEquals("Sec", DocGeneratorUtil.toCamelOne(SecHubDirectCheckmarxResilienceConfiguration.class)); + + assertEquals("SMTPServer", DocGeneratorUtil.toCamelOne(SMTPServerConfiguration.class)); + assertEquals("PDSResilience", DocGeneratorUtil.toCamelOne(PDSResilienceConsultant.class)); + } }