From 3ce8505aff5142d8ab5f7ffb2cc85cd5fdd56194 Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Thu, 26 Nov 2026 16:01:39 +0900 Subject: [PATCH 1/2] Clarify the use of JAVA_OPTS when invoking java directly Document that the Java properties must be provided directly on the command-line when using java directly and not simply exported via JAVA_OPTS. --- docs/debugging.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/debugging.md b/docs/debugging.md index c693e7fca2d3..1cc3e2ce64df 100644 --- a/docs/debugging.md +++ b/docs/debugging.md @@ -169,11 +169,16 @@ openapi-generator generate -g go \ Or you can add these to your `JAVA_OPTS` environment variable (this applies to every invocation of the tool): ```bash -export JAVA_OPTS="${JAVA_OPTS} --global-property debugModels,debugOperations" +export JAVA_OPTS="${JAVA_OPTS} -Dlog.level=debug --global-property debugModels,debugOperations" ``` > NOTE: Globally available system options like these will apply to all invocations of the generator (CLI and plugins) +> NOTE: If you invoke the tool via Java, you will need to provide the options directly to the `java` and `openapi-generator generate` command-line instead, for example: +``` +java -Dlog.level=debug -jar .../openapi-generator-cli.jar generate --global-property debugModels,debugOperations ... +``` + ## Runtime When you're working with a custom generator, a new generator, or otherwise trying to understand the behavior of the toolset, you may need to attach a remote debugger in order to step through the code. @@ -226,6 +231,11 @@ You can try to enable debugging log with `-Dlog.level=debug` option to the `JAVA export JAVA_OPTS="${JAVA_OPTS} -Dlog.level=debug" ``` +> NOTE: If you invoke the tool via Java directly, you must provide the property directly to its command line, for example: +```bash +java -Dlog.level=debug -jar ... +``` + Set the option then DEBUG logs are printed out: ```bash From 998d8d932e6436975f264b698bcdbd861b1ff7f5 Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Fri, 27 Nov 2026 09:49:02 +0900 Subject: [PATCH 2/2] Log global property-enabled output at info level (#25827) Previously, the output would not be shown as json.prettyPrint logs at debug level via the swagger logger, which level is hard-coded to use the warn level. Fixes: #25827 --- .../java/org/openapitools/codegen/DefaultGenerator.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java index 32e007608571..613e04d4f576 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java @@ -604,7 +604,7 @@ void generateModels(List files, List allModels, List unu } if (GlobalSettings.getProperty("debugModels") != null) { LOGGER.info("############ Model info ############"); - Json.prettyPrint(allModels); + LOGGER.info(Json.pretty(allModels)); } } @@ -841,7 +841,7 @@ void generateApis(List files, List allOperations, List files, List allWebhooks, List buildSupportFileBundle(List allOperations, Li if (GlobalSettings.getProperty("debugSupportingFiles") != null) { LOGGER.info("############ Supporting file info ############"); - Json.prettyPrint(bundle); + LOGGER.info(Json.pretty(bundle)); } return bundle; }