You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Java] Migrate okhttp Gson readers to JsonReader.setStrictness #25853
OpenAPI Generator CLI 7.28.0 emits two deprecated JsonReader.setLenient(true) calls in the Java okhttp-gson client. Its okhttp library emits the same calls when Gson is selected. I reproduced two javac deprecation diagnostics after upgrading the generated Maven project's gson-version from 2.10.1 to 2.15.0. Both templates on the current default branch also call the old setter.
Generate the okhttp-gson client and compile with current Gson and deprecation diagnostics enabled:
java -jar openapi-generator-cli-7.28.0.jar generate \
-i ping.yaml -g java --library okhttp-gson -o out
rg -n 'jsonReader.setLenient\(true\)' out/src/main/java
cd out
mvn -Dgson-version=2.15.0 -Dmaven.compiler.showDeprecation=true -DskipTests compile
The generated JSON.java uses the legacy setter in deserialize(String, Type) and deserialize(InputStream, Type). Both paths are affected even with a spec containing only one operation.
Workaround and suggested upstream change
Router compiles the generated client against Gson 2.15.0 and substitutes this line in the two generated overloads:
The Java probe exercises both overloads with a comment and a single-quoted string. Gson introduced Strictness in 2.11.0. Please update the Gson dependency floor in the Java templates that adopt it, then update both overloads to call setStrictness(Strictness.LENIENT). Gson documents this as the equivalent of setLenient(true).
Activity