Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve documentation output for REST doc + fix scope calculation #3651

Merged
merged 2 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 <code>null</code>
*/
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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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));

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ SpringRestDocOutput[] wanted() default {
/* @formatter:off */
SpringRestDocOutput.PATH_PARAMETERS,

SpringRestDocOutput.QUERY_PARAMETERS,

SpringRestDocOutput.REQUEST_PARAMETERS,

Expand Down Expand Up @@ -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),
Expand Down
Loading