Skip to content

Commit

Permalink
fix: use @casename annotations for openapi enums
Browse files Browse the repository at this point in the history
  • Loading branch information
runtologist committed Dec 5, 2023
1 parent 58e0594 commit 49ca643
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down

0 comments on commit 49ca643

Please sign in to comment.