Skip to content

Commit

Permalink
Merge pull request #84 from ndy2/master
Browse files Browse the repository at this point in the history
use camelCasedObjectMapper in `DocsController`  for endpoint `/swagger.json`
  • Loading branch information
jakehschwartz authored Dec 20, 2024
2 parents 77d7d47 + e113ae9 commit 570adc9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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}
Expand All @@ -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))
Expand Down

0 comments on commit 570adc9

Please sign in to comment.