From e981d82e3b250ff7f91a6d935fb677cf8bc2e12d Mon Sep 17 00:00:00 2001 From: Peter Banda Date: Fri, 20 Sep 2024 10:57:01 +0200 Subject: [PATCH] Json String schema - enum optional --- .../main/scala/io/cequence/openaiscala/JsonFormats.scala | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/openai-core/src/main/scala/io/cequence/openaiscala/JsonFormats.scala b/openai-core/src/main/scala/io/cequence/openaiscala/JsonFormats.scala index 10b981fa..2774befe 100644 --- a/openai-core/src/main/scala/io/cequence/openaiscala/JsonFormats.scala +++ b/openai-core/src/main/scala/io/cequence/openaiscala/JsonFormats.scala @@ -1190,7 +1190,11 @@ object JsonFormats { } implicit lazy val jsonSchemaReads: Reads[JsonSchema] = new Reads[JsonSchema] { - implicit val stringReads: Reads[JsonSchema.String] = Json.reads[JsonSchema.String] + implicit val stringReads: Reads[JsonSchema.String] = ( + (__ \ "description").readNullable[String] and + (__ \ "enum").readWithDefault[Seq[String]](Nil) + )(JsonSchema.String _) + implicit val numberReads: Reads[JsonSchema.Number] = Json.reads[JsonSchema.Number] implicit val booleanReads: Reads[JsonSchema.Boolean] = Json.reads[JsonSchema.Boolean] // implicit val nullReads = Json.reads[JsonSchema.Null]