From 388218bdf99493f8e747aa5864dd23bf0672de3c Mon Sep 17 00:00:00 2001 From: sylvainmoindron <43030050+sylvainmoindron@users.noreply.github.com> Date: Fri, 5 Jun 2020 03:29:40 +0200 Subject: [PATCH] [kotlin][spring] Fix ApiUtil compilation (#6084) --- .../src/main/resources/kotlin-spring/apiUtil.mustache | 6 +++--- .../src/main/kotlin/org/openapitools/api/ApiUtil.kt | 6 +++--- .../src/main/kotlin/org/openapitools/api/ApiUtil.kt | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/apiUtil.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/apiUtil.mustache index 4837075c136..8ae90f20aa7 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/apiUtil.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/apiUtil.mustache @@ -12,9 +12,9 @@ object ApiUtil { fun setExampleResponse(req: NativeWebRequest, contentType: String, example: String) { try { val res = req.getNativeResponse(HttpServletResponse::class.java) - res.setCharacterEncoding("UTF-8") - res.addHeader("Content-Type", contentType) - res.getWriter().print(example) + res?.characterEncoding = "UTF-8" + res?.addHeader("Content-Type", contentType) + res?.writer?.print(example) } catch (e: IOException) { throw RuntimeException(e) } diff --git a/samples/server/petstore/kotlin-springboot-modelMutable/src/main/kotlin/org/openapitools/api/ApiUtil.kt b/samples/server/petstore/kotlin-springboot-modelMutable/src/main/kotlin/org/openapitools/api/ApiUtil.kt index 958a6f3ebfe..88e892d0f49 100644 --- a/samples/server/petstore/kotlin-springboot-modelMutable/src/main/kotlin/org/openapitools/api/ApiUtil.kt +++ b/samples/server/petstore/kotlin-springboot-modelMutable/src/main/kotlin/org/openapitools/api/ApiUtil.kt @@ -9,9 +9,9 @@ object ApiUtil { fun setExampleResponse(req: NativeWebRequest, contentType: String, example: String) { try { val res = req.getNativeResponse(HttpServletResponse::class.java) - res.setCharacterEncoding("UTF-8") - res.addHeader("Content-Type", contentType) - res.getWriter().print(example) + res?.characterEncoding = "UTF-8" + res?.addHeader("Content-Type", contentType) + res?.writer?.print(example) } catch (e: IOException) { throw RuntimeException(e) } diff --git a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/ApiUtil.kt b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/ApiUtil.kt index 958a6f3ebfe..88e892d0f49 100644 --- a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/ApiUtil.kt +++ b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/api/ApiUtil.kt @@ -9,9 +9,9 @@ object ApiUtil { fun setExampleResponse(req: NativeWebRequest, contentType: String, example: String) { try { val res = req.getNativeResponse(HttpServletResponse::class.java) - res.setCharacterEncoding("UTF-8") - res.addHeader("Content-Type", contentType) - res.getWriter().print(example) + res?.characterEncoding = "UTF-8" + res?.addHeader("Content-Type", contentType) + res?.writer?.print(example) } catch (e: IOException) { throw RuntimeException(e) }