Skip to content

Commit

Permalink
configure openapi version
Browse files Browse the repository at this point in the history
  • Loading branch information
cornerman committed Nov 14, 2023
1 parent 91542dd commit 0463cb5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lambdaHttpApiTapir/src/main/scala/helper/DocServer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ case class DocInfo(
security: List[SecurityRequirement] = Nil,
swaggerUIOptions: js.Object = js.Object(),
filterEndpoints: EndpointInfoOps[_] with EndpointMetaOps => Boolean = _ => true,
openApiVersion: Option[String] = None,
)
object DocInfo {
def default = DocInfo(title = "API", version = "latest")
Expand All @@ -45,9 +46,12 @@ object DocServer {
Some(result(html, "text/html"))

case List("openapi.json") =>
val openapi = OpenAPIDocsInterpreter(docInfo.options)
val openapiBase = OpenAPIDocsInterpreter(docInfo.options)
.serverEndpointsToOpenAPI[F](endpoints.filter(docInfo.filterEndpoints), docInfo.info)
.copy(tags = docInfo.tags, webhooks = docInfo.webhooks, servers = docInfo.servers, security = docInfo.security)

val openapi = docInfo.openApiVersion.fold(openapiBase)(version => openapiBase.copy(openapi = version))

val json = openapi.asJson.spaces2SortKeys
Some(result(json, "application/json"))

Expand Down

0 comments on commit 0463cb5

Please sign in to comment.