Skip to content

Commit

Permalink
improve json schema description handling
Browse files Browse the repository at this point in the history
  • Loading branch information
fwbrasil committed Oct 24, 2023
1 parent 227e801 commit 0cf3727
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ object JsonSchema {
def desc(c: Chunk[Any]): Map[String, Json] =
c.collect {
case desc(v) =>
"description" -> Json.Str(v)
"description" -> Json.Str(v.stripMargin)
}.toMap

def convert(schema: Schema[_]): Map[String, Json] =
Expand Down Expand Up @@ -60,7 +60,9 @@ object JsonSchema {

case schema: Schema.Record[_] =>
val properties = schema.fields.foldLeft(Map.empty[String, Json]) { (acc, field) =>
acc + (field.name -> Json.Obj((convert(field.schema) ++ desc(field.annotations)).toSeq: _*))
acc + (field.name -> Json.Obj(
(convert(field.schema) ++ desc(field.annotations)).toSeq: _*
))
}
val requiredFields = schema.fields.collect {
case field if !field.schema.isInstanceOf[Schema.Optional[_]] => Json.Str(field.name)
Expand Down

0 comments on commit 0cf3727

Please sign in to comment.