File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
http-generator-nima/src/main/java/io/avaje/http/generator/helidon/nima Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -113,8 +113,12 @@ void writeHandler(boolean requestScoped) {
113113 final var uType = UType .parse (method .returnType ());
114114 writer .append (" result.transferTo(res.outputStream());" , uType .shortName ()).eol ();
115115 } else if (producesJson ()) {
116- final var uType = UType .parse (method .returnType ());
117- writer .append (" %sJsonType.toJson(result, JsonOutput.of(res));" , uType .shortName ()).eol ();
116+ if (returnTypeString ()) {
117+ writer .append (" res.send(result); // send raw JSON" ).eol ();
118+ } else {
119+ final var uType = UType .parse (method .returnType ());
120+ writer .append (" %sJsonType.toJson(result, JsonOutput.of(res));" , uType .shortName ()).eol ();
121+ }
118122 } else {
119123 writer .append (" res.send(result);" ).eol ();
120124 }
@@ -159,6 +163,10 @@ private boolean producesJson() {
159163 && (method .produces () == null || method .produces ().toLowerCase ().contains ("json" ));
160164 }
161165
166+ private boolean returnTypeString () {
167+ return "java.lang.String" .equals (method .returnType ().toString ());
168+ }
169+
162170 private boolean missingServerResponse (List <MethodParam > params ) {
163171 return method .isVoid () && params .stream ().noneMatch (p -> "ServerResponse" .equals (p .shortType ()));
164172 }
You can’t perform that action at this time.
0 commit comments