From 8ef7933130c63f1d85a5b9b4af3a6905345d3e9e Mon Sep 17 00:00:00 2001 From: deukyun Date: Fri, 20 Dec 2024 07:47:20 +0900 Subject: [PATCH 1/2] use camelCaseObjectMapper in DocsController --- .../com/jakehschwartz/finatra/swagger/DocsController.scala | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/scala/com/jakehschwartz/finatra/swagger/DocsController.scala b/src/main/scala/com/jakehschwartz/finatra/swagger/DocsController.scala index f71162d..88f0771 100644 --- a/src/main/scala/com/jakehschwartz/finatra/swagger/DocsController.scala +++ b/src/main/scala/com/jakehschwartz/finatra/swagger/DocsController.scala @@ -1,5 +1,7 @@ package com.jakehschwartz.finatra.swagger +import com.fasterxml.jackson.datatype.joda.JodaModule + import java.io.BufferedInputStream import java.util.Date import com.twitter.finagle.http.{Message, Request} @@ -17,10 +19,13 @@ import scala.util.{Failure, Success, Try} @Singleton class DocsController @Inject()(openAPI: OpenAPI, - objectMapper: ScalaObjectMapper, @Flag("swagger.docs.endpoint") endpoint: String) extends Controller { + private val objectMapper = ScalaObjectMapper.builder + .camelCaseObjectMapper + .registerModule(new JodaModule()) + get("/swagger.json") { _: Request => response .ok(objectMapper.writeValueAsString(openAPI)) From e113ae9452833029b5a6fece92b4c5716e843ee0 Mon Sep 17 00:00:00 2001 From: deukyun Date: Fri, 20 Dec 2024 07:47:53 +0900 Subject: [PATCH 2/2] add SecuritySchemes in Sample App --- .../finatra/swagger/SampleSwaggerModule.scala | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/examples/hello-world/src/main/scala/com/jakehschwartz/finatra/swagger/SampleSwaggerModule.scala b/examples/hello-world/src/main/scala/com/jakehschwartz/finatra/swagger/SampleSwaggerModule.scala index 5a9b00c..fd2b02b 100644 --- a/examples/hello-world/src/main/scala/com/jakehschwartz/finatra/swagger/SampleSwaggerModule.scala +++ b/examples/hello-world/src/main/scala/com/jakehschwartz/finatra/swagger/SampleSwaggerModule.scala @@ -1,9 +1,9 @@ package com.jakehschwartz.finatra.swagger import com.google.inject.Provides -import io.swagger.v3.oas.models.OpenAPI +import io.swagger.v3.oas.models.{Components, OpenAPI} import io.swagger.v3.oas.models.info.Info -import io.swagger.v3.oas.models.security.SecurityRequirement +import io.swagger.v3.oas.models.security.{SecurityRequirement, SecurityScheme} import javax.inject.Singleton @@ -23,6 +23,11 @@ object SampleSwaggerModule extends SwaggerModule { openAPI .info(info) .addSecurityItem(new SecurityRequirement().addList("sampleBasic", "basic")) + .components( + new Components().addSecuritySchemes( + "sampleBasic", new SecurityScheme().`type`(SecurityScheme.Type.HTTP).scheme("basic") + ) + ) openAPI }