From 3097384808a0dca0b960be4c621d12e3c8d449f6 Mon Sep 17 00:00:00 2001 From: Greg Zoller Date: Fri, 13 Dec 2024 15:58:08 -0600 Subject: [PATCH] Simplistic implementation of OpenAPI security block for Auth --- .../scala/zio/http/endpoint/openapi/OpenAPIGen.scala | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/zio-http/shared/src/main/scala/zio/http/endpoint/openapi/OpenAPIGen.scala b/zio-http/shared/src/main/scala/zio/http/endpoint/openapi/OpenAPIGen.scala index 64ba05780..fae192309 100644 --- a/zio-http/shared/src/main/scala/zio/http/endpoint/openapi/OpenAPIGen.scala +++ b/zio-http/shared/src/main/scala/zio/http/endpoint/openapi/OpenAPIGen.scala @@ -19,6 +19,7 @@ import zio.http.codec.HttpCodec.Metadata import zio.http.codec._ import zio.http.endpoint._ import zio.http.endpoint.openapi.JsonSchema.SchemaStyle +import zio.http.endpoint.openapi.OpenAPI.SecurityScheme.SecurityRequirement import zio.http.endpoint.openapi.OpenAPI.{Path, PathItem} object OpenAPIGen { @@ -591,7 +592,15 @@ object OpenAPIGen { requestBody = requestBody, responses = responses, callbacks = Map.empty, - security = Nil, + security = endpoint.authType match { + case AuthType.Basic => + List(SecurityRequirement(Map("BasicAuth" -> Nil))) + case AuthType.Bearer => + List(SecurityRequirement(Map("BearerAuth" -> Nil))) + case AuthType.Digest => + List(SecurityRequirement(Map("DigestAuth" -> Nil))) + case _ => Nil + }, servers = Nil, ) }