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

Use logger.warn for promo banner to enable silencing #19602

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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 @@ -232,6 +232,33 @@ class GenerateTaskDslTest : TestBase() {
)
}

@Test
fun `promo banner should not be shown when run as quiet`() {
// Arrange
val projectFiles = mapOf(
"spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0.yaml")
)
withProject(defaultBuildGradle, projectFiles)

// Act
val result = GradleRunner.create()
.withProjectDir(temp)
.withArguments("openApiGenerate")
.withPluginClasspath()
.build()

// Assert
assertFalse (
result.output.contains("# Thanks for using OpenAPI Generator."),
"Promo banner is shown even when run with --quiet."
)

assertEquals(
TaskOutcome.SUCCESS, result.task(":openApiGenerate")?.outcome,
"Expected a successful run, but found ${result.task(":openApiGenerate")?.outcome}"
)
}

@Test
fun `openApiGenerate should cleanup outputDir`() {
// Arrange
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -945,11 +945,11 @@ public void setOpenAPI(OpenAPI openAPI) {
@Override
@SuppressWarnings("static-method")
public void postProcess() {
System.out.println("################################################################################");
System.out.println("# Thanks for using OpenAPI Generator. #");
System.out.println("# Please consider donation to help us maintain this project \uD83D\uDE4F #");
System.out.println("# https://opencollective.com/openapi_generator/donate #");
System.out.println("################################################################################");
LOGGER.warn("################################################################################");
LOGGER.warn("# Thanks for using OpenAPI Generator. #");
LOGGER.warn("# Please consider donation to help us maintain this project \uD83D\uDE4F #");
LOGGER.warn("# https://opencollective.com/openapi_generator/donate #");
LOGGER.warn("################################################################################");
}

// override with any special post-processing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -941,17 +941,17 @@ public void postProcessFile(File file, String fileType) {

@Override
public void postProcess() {
System.out.println("################################################################################");
System.out.println("# Thanks for using OpenAPI Generator. #");
System.out.println("# Please consider donation to help us maintain this project \uD83D\uDE4F #");
System.out.println("# https://opencollective.com/openapi_generator/donate #");
System.out.println("# #");
System.out.println("# This generator is contributed by Hemant Zope (https://github.com/zhemant) #");
System.out.println("# and Niklas Werner (https://github.com/PowerOfCreation). #");
System.out.println("# Please support their work directly \uD83D\uDE4F #");
System.out.println("# > Hemant Zope - https://www.patreon.com/zhemant #");
System.out.println("# > Niklas Werner - https://paypal.me/wernerdevelopment #");
System.out.println("################################################################################");
LOGGER.warn("################################################################################");
LOGGER.warn("# Thanks for using OpenAPI Generator. #");
LOGGER.warn("# Please consider donation to help us maintain this project \uD83D\uDE4F #");
LOGGER.warn("# https://opencollective.com/openapi_generator/donate #");
LOGGER.warn("# #");
LOGGER.warn("# This generator is contributed by Hemant Zope (https://github.com/zhemant) #");
LOGGER.warn("# and Niklas Werner (https://github.com/PowerOfCreation). #");
LOGGER.warn("# Please support their work directly \uD83D\uDE4F #");
LOGGER.warn("# > Hemant Zope - https://www.patreon.com/zhemant #");
LOGGER.warn("# > Niklas Werner - https://paypal.me/wernerdevelopment #");
LOGGER.warn("################################################################################");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1676,14 +1676,14 @@ protected boolean isValueType(CodegenProperty var) {

@Override
public void postProcess() {
System.out.println("################################################################################");
System.out.println("# Thanks for using OpenAPI Generator. #");
System.out.println("# Please consider donation to help us maintain this project \uD83D\uDE4F #");
System.out.println("# https://opencollective.com/openapi_generator/donate #");
System.out.println("# #");
System.out.println("# This generator's contributed by Jim Schubert (https://github.com/jimschubert)#");
System.out.println("# Please support his work directly via https://patreon.com/jimschubert \uD83D\uDE4F #");
System.out.println("################################################################################");
LOGGER.warn("################################################################################");
LOGGER.warn("# Thanks for using OpenAPI Generator. #");
LOGGER.warn("# Please consider donation to help us maintain this project \uD83D\uDE4F #");
LOGGER.warn("# https://opencollective.com/openapi_generator/donate #");
LOGGER.warn("# #");
LOGGER.warn("# This generator's contributed by Jim Schubert (https://github.com/jimschubert)#");
LOGGER.warn("# Please support his work directly via https://patreon.com/jimschubert \uD83D\uDE4F #");
LOGGER.warn("################################################################################");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1097,14 +1097,14 @@ public ModelsMap postProcessModels(ModelsMap objs) {

@Override
public void postProcess() {
System.out.println("################################################################################");
System.out.println("# Thanks for using OpenAPI Generator. #");
System.out.println("# Please consider donation to help us maintain this project \uD83D\uDE4F #");
System.out.println("# https://opencollective.com/openapi_generator/donate #");
System.out.println("# #");
System.out.println("# This generator's contributed by Jim Schubert (https://github.com/jimschubert)#");
System.out.println("# Please support his work directly via https://patreon.com/jimschubert \uD83D\uDE4F #");
System.out.println("################################################################################");
LOGGER.warn("################################################################################");
LOGGER.warn("# Thanks for using OpenAPI Generator. #");
LOGGER.warn("# Please consider donation to help us maintain this project \uD83D\uDE4F #");
LOGGER.warn("# https://opencollective.com/openapi_generator/donate #");
LOGGER.warn("# #");
LOGGER.warn("# This generator's contributed by Jim Schubert (https://github.com/jimschubert)#");
LOGGER.warn("# Please support his work directly via https://patreon.com/jimschubert \uD83D\uDE4F #");
LOGGER.warn("################################################################################");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,14 +280,14 @@ public String toRegularExpression(String pattern) {

@Override
public void postProcess() {
System.out.println("################################################################################");
System.out.println("# Thanks for using OpenAPI Generator. #");
System.out.println("# Please consider donation to help us maintain this project \uD83D\uDE4F #");
System.out.println("# https://opencollective.com/openapi_generator/donate #");
System.out.println("# #");
System.out.println("# This generator's contributed by Nick Fisher (https://github.com/nmfisher) #");
System.out.println("# Please support his work directly via https://paypal.me/nickfisher1984 \uD83D\uDE4F #");
System.out.println("################################################################################");
LOGGER.warn("################################################################################");
LOGGER.warn("# Thanks for using OpenAPI Generator. #");
LOGGER.warn("# Please consider donation to help us maintain this project \uD83D\uDE4F #");
LOGGER.warn("# https://opencollective.com/openapi_generator/donate #");
LOGGER.warn("# #");
LOGGER.warn("# This generator's contributed by Nick Fisher (https://github.com/nmfisher) #");
LOGGER.warn("# Please support his work directly via https://paypal.me/nickfisher1984 \uD83D\uDE4F #");
LOGGER.warn("################################################################################");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,13 @@ private List<RequestItem> handleCustomVariablesInRequests(List<RequestItem> item

@Override
public void postProcess() {
System.out.println("##########################################################################################");
System.out.println("# Thanks for using OpenAPI Generator. #");
System.out.println("# Please consider donation to help us maintain this project \uD83D\uDE4F #");
System.out.println("# https://opencollective.com/openapi_generator/donate #");
System.out.println("# #");
System.out.println("# This generator was written by Julien Lengrand-Lambert (https://github.com/jlengrand) #");
System.out.println("##########################################################################################");
LOGGER.warn("##########################################################################################");
LOGGER.warn("# Thanks for using OpenAPI Generator. #");
LOGGER.warn("# Please consider donation to help us maintain this project \uD83D\uDE4F #");
LOGGER.warn("# https://opencollective.com/openapi_generator/donate #");
LOGGER.warn("# #");
LOGGER.warn("# This generator was written by Julien Lengrand-Lambert (https://github.com/jlengrand) #");
LOGGER.warn("##########################################################################################");
}

@Getter @Setter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1025,13 +1025,13 @@ private static boolean isMultipartType(List<Map<String, String>> consumes) {

@Override
public void postProcess() {
System.out.println("################################################################################");
System.out.println("# Thanks for using OpenAPI Generator. #");
System.out.println("# Please consider donation to help us maintain this project \uD83D\uDE4F #");
System.out.println("# https://opencollective.com/openapi_generator/donate #");
System.out.println("# #");
System.out.println("# This generator's contributed by Jim Schubert (https://github.com/jimschubert)#");
System.out.println("# Please support his work directly via https://patreon.com/jimschubert \uD83D\uDE4F #");
System.out.println("################################################################################");
LOGGER.warn("################################################################################");
LOGGER.warn("# Thanks for using OpenAPI Generator. #");
LOGGER.warn("# Please consider donation to help us maintain this project \uD83D\uDE4F #");
LOGGER.warn("# https://opencollective.com/openapi_generator/donate #");
LOGGER.warn("# #");
LOGGER.warn("# This generator's contributed by Jim Schubert (https://github.com/jimschubert)#");
LOGGER.warn("# Please support his work directly via https://patreon.com/jimschubert \uD83D\uDE4F #");
LOGGER.warn("################################################################################");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -352,14 +352,14 @@ public static class Constants {

@Override
public void postProcess() {
System.out.println("################################################################################");
System.out.println("# Thanks for using OpenAPI Generator. #");
System.out.println("# Please consider donation to help us maintain this project \uD83D\uDE4F #");
System.out.println("# https://opencollective.com/openapi_generator/donate #");
System.out.println("# #");
System.out.println("# This generator's contributed by Jim Schubert (https://github.com/jimschubert)#");
System.out.println("# Please support his work directly via https://patreon.com/jimschubert \uD83D\uDE4F #");
System.out.println("################################################################################");
LOGGER.warn("################################################################################");
LOGGER.warn("# Thanks for using OpenAPI Generator. #");
LOGGER.warn("# Please consider donation to help us maintain this project \uD83D\uDE4F #");
LOGGER.warn("# https://opencollective.com/openapi_generator/donate #");
LOGGER.warn("# #");
LOGGER.warn("# This generator's contributed by Jim Schubert (https://github.com/jimschubert)#");
LOGGER.warn("# Please support his work directly via https://patreon.com/jimschubert \uD83D\uDE4F #");
LOGGER.warn("################################################################################");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
import java.util.Locale;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class KotlinWiremockServerCodegen extends AbstractKotlinCodegen {
private final Logger LOGGER = LoggerFactory.getLogger(KotlinWiremockServerCodegen.class);

protected static final String VENDOR_EXTENSION_BASE_NAME_LITERAL = "x-base-name-literal";

Expand Down Expand Up @@ -138,13 +141,13 @@ public CodegenResponse fromResponse(String responseCode, ApiResponse response) {

@Override
public void postProcess() {
System.out.println("################################################################################");
System.out.println("# Thanks for using OpenAPI Generator. #");
System.out.println("# Please consider donation to help us maintain this project \uD83D\uDE4F #");
System.out.println("# https://opencollective.com/openapi_generator/donate #");
System.out.println("# #");
System.out.println("# This generator's contributed by Stefan Koppier (https://github.com/stefankoppier)#");
System.out.println("################################################################################");
LOGGER.warn("################################################################################");
LOGGER.warn("# Thanks for using OpenAPI Generator. #");
LOGGER.warn("# Please consider donation to help us maintain this project \uD83D\uDE4F #");
LOGGER.warn("# https://opencollective.com/openapi_generator/donate #");
LOGGER.warn("# #");
LOGGER.warn("# This generator's contributed by Stefan Koppier (https://github.com/stefankoppier)#");
LOGGER.warn("################################################################################");
}

}
Loading