Skip to content

Commit 388218b

Browse files
[kotlin][spring] Fix ApiUtil compilation (#6084)
1 parent dc9a898 commit 388218b

File tree

3 files changed

+9
-9
lines changed
  • modules/openapi-generator/src/main/resources/kotlin-spring
  • samples/server/petstore
    • kotlin-springboot/src/main/kotlin/org/openapitools/api
    • kotlin-springboot-modelMutable/src/main/kotlin/org/openapitools/api

3 files changed

+9
-9
lines changed

modules/openapi-generator/src/main/resources/kotlin-spring/apiUtil.mustache

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ object ApiUtil {
1212
fun setExampleResponse(req: NativeWebRequest, contentType: String, example: String) {
1313
try {
1414
val res = req.getNativeResponse(HttpServletResponse::class.java)
15-
res.setCharacterEncoding("UTF-8")
16-
res.addHeader("Content-Type", contentType)
17-
res.getWriter().print(example)
15+
res?.characterEncoding = "UTF-8"
16+
res?.addHeader("Content-Type", contentType)
17+
res?.writer?.print(example)
1818
} catch (e: IOException) {
1919
throw RuntimeException(e)
2020
}

samples/server/petstore/kotlin-springboot-modelMutable/src/main/kotlin/org/openapitools/api/ApiUtil.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ object ApiUtil {
99
fun setExampleResponse(req: NativeWebRequest, contentType: String, example: String) {
1010
try {
1111
val res = req.getNativeResponse(HttpServletResponse::class.java)
12-
res.setCharacterEncoding("UTF-8")
13-
res.addHeader("Content-Type", contentType)
14-
res.getWriter().print(example)
12+
res?.characterEncoding = "UTF-8"
13+
res?.addHeader("Content-Type", contentType)
14+
res?.writer?.print(example)
1515
} catch (e: IOException) {
1616
throw RuntimeException(e)
1717
}

samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/ApiUtil.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ object ApiUtil {
99
fun setExampleResponse(req: NativeWebRequest, contentType: String, example: String) {
1010
try {
1111
val res = req.getNativeResponse(HttpServletResponse::class.java)
12-
res.setCharacterEncoding("UTF-8")
13-
res.addHeader("Content-Type", contentType)
14-
res.getWriter().print(example)
12+
res?.characterEncoding = "UTF-8"
13+
res?.addHeader("Content-Type", contentType)
14+
res?.writer?.print(example)
1515
} catch (e: IOException) {
1616
throw RuntimeException(e)
1717
}

0 commit comments

Comments
 (0)