From 49ca6435603069d8d301a7c14db4c036ccf111e6 Mon Sep 17 00:00:00 2001 From: Simon Schenk Date: Tue, 5 Dec 2023 10:19:32 +0100 Subject: [PATCH] fix: use @caseName annotations for openapi enums --- .../main/scala/zio/http/endpoint/openapi/JsonSchema.scala | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/zio-http/src/main/scala/zio/http/endpoint/openapi/JsonSchema.scala b/zio-http/src/main/scala/zio/http/endpoint/openapi/JsonSchema.scala index c7b0b5b201..14917374f7 100644 --- a/zio-http/src/main/scala/zio/http/endpoint/openapi/JsonSchema.scala +++ b/zio-http/src/main/scala/zio/http/endpoint/openapi/JsonSchema.scala @@ -445,7 +445,11 @@ object JsonSchema { case enum0: Schema.Enum[_] if refType != SchemaStyle.Inline && nominal(enum0).isDefined => JsonSchema.RefSchema(nominal(enum0, refType).get) case enum0: Schema.Enum[_] if enum0.cases.forall(_.schema.isInstanceOf[CaseClass0[_]]) => - JsonSchema.Enum(enum0.cases.map(c => EnumValue.Str(c.id))) + JsonSchema.Enum( + enum0.cases.map(c => + EnumValue.Str(c.annotations.collectFirst { case caseName(name) => name }.getOrElse(c.id)), + ), + ) case enum0: Schema.Enum[_] => val noDiscriminator = enum0.annotations.exists(_.isInstanceOf[noDiscriminator]) val discriminatorName0 =