Skip to content
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
4 changes: 2 additions & 2 deletions docs/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@ openapi-generator generate -g go \
--global-property debugModels,debugOperations
```

Or you can add these to your `JAVA_OPTS` environment variable (this applies to every invocation of the tool):
Or you can add these to your `JAVA_OPTS` environment variable (this applies to every invocation of the tool). Notice we add a file logger, which makes it easier to consult the verbose model output in the `output.log` file:

```bash
export JAVA_OPTS="${JAVA_OPTS} --global-property debugModels,debugOperations"
export JAVA_OPTS="${JAVA_OPTS} -Dlog.file=output.log --global-property debugModels,debugOperations"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: This example cannot run because --global-property is passed to the JVM through JAVA_OPTS, not to the generator after -jar. Keep only JVM -D properties in JAVA_OPTS, or put the global-property flags on the generator command.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At docs/debugging.md, line 172:

<comment>This example cannot run because `--global-property` is passed to the JVM through `JAVA_OPTS`, not to the generator after `-jar`. Keep only JVM `-D` properties in `JAVA_OPTS`, or put the global-property flags on the generator command.</comment>

<file context>
@@ -166,10 +166,10 @@ openapi-generator generate -g go \
 
 ```bash
-export JAVA_OPTS="${JAVA_OPTS} --global-property debugModels,debugOperations"
+export JAVA_OPTS="${JAVA_OPTS} -Dlog.file=output.log --global-property debugModels,debugOperations"

</file context>


</details>

```suggestion
export JAVA_OPTS="${JAVA_OPTS} -Dlog.file=output.log -DdebugModels=true -DdebugOperations=true"

```

> NOTE: Globally available system options like these will apply to all invocations of the generator (CLI and plugins)
Expand Down
16 changes: 16 additions & 0 deletions modules/openapi-generator-cli/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,29 @@
</filter>
</appender>

<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>${log.file}</file>
<append>true</append>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>[%date] [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
Comment on lines +43 to +49

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: FILE is instantiated even when log.file is absent; the conditional only guards its references. Normal CLI runs can therefore create an unintended log.file_IS_UNDEFINED file. Put the appender declaration itself inside an isDefined("log.file") conditional.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At modules/openapi-generator-cli/src/main/resources/logback.xml, line 43:

<comment>`FILE` is instantiated even when `log.file` is absent; the conditional only guards its references. Normal CLI runs can therefore create an unintended `log.file_IS_UNDEFINED` file. Put the appender declaration itself inside an `isDefined("log.file")` conditional.</comment>

<file context>
@@ -40,13 +40,29 @@
         </filter>
     </appender>
 
+    <appender name="FILE" class="ch.qos.logback.core.FileAppender">
+        <file>${log.file}</file>
+        <append>true</append>
</file context>
Suggested change
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>${log.file}</file>
<append>true</append>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>[%date] [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<condition class="ch.qos.logback.core.boolex.ExpressionPropertyCondition">
<expression>isDefined("log.file")</expression>
</condition>
<if>
<then>
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>${log.file}</file>
<append>true</append>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>[%date] [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
</then>
</if>


<logger name="io.swagger" level="warn">
<appender-ref ref="STDOUT"/>
<appender-ref ref="STDERR"/>
<condition class="ch.qos.logback.core.boolex.ExpressionPropertyCondition">
<expression>isDefined("log.file")</expression>
</condition>
<if><then><appender-ref ref="FILE"/></then></if>
</logger>
<logger name="org.openapitools" level="${log.level:-info}">
<appender-ref ref="STDOUT"/>
<appender-ref ref="STDERR"/>
<condition class="ch.qos.logback.core.boolex.ExpressionPropertyCondition">
<expression>isDefined("log.file")</expression>
</condition>
<if><then><appender-ref ref="FILE"/></then></if>
</logger>
<root level="error">
<appender-ref ref="STDERR"/>
Expand Down
Loading