Skip to content

Commit

Permalink
Json String schema - enum optional
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbanda committed Sep 20, 2024
1 parent 87fa0ce commit e981d82
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit e981d82

Please sign in to comment.