Skip to content

Commit

Permalink
Adding a warning and a bit of context for what's missing
Browse files Browse the repository at this point in the history
  • Loading branch information
blast-hardcheese committed Oct 24, 2022
1 parent cc6d79f commit 2323312
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,23 @@ object ProtocolGenerator {
fromEnum(nestedClassName.last, s, dtoPackage, components).map(Option(_))
)
.orRefine { case m: MapSchema => m } { m =>
// TODO: #1591: What we are emitting here is the inner class `Z` in the expression:
// `foo: Option[Map[String, Z]]`
// Unfortunately, that means that if we wanted to properly parse and incorporate
// those fields, we would need to do something more creative like
// `case class Bar(prop: A, prop2: B, extra: Map[String, Z])`
// so we could do
// `foo: Option[Bar]`
// we would need an extra className for `Bar` (instead of just using nestedClassName),
// as well as to be more choosy about which fields we try to decode with `.as[Z]`,
// since we should intentionally and explicitly skip fields for which we have known
// mappings for, using the `additionalProperties` mapping only for fields we've never seen.
NonEmptyList.fromList(m.downField("properties", _.getProperties).indexedDistribute.toList).foreach { props =>
println(s"""WARNING: Unsupported mixing of properties and additionalProperties.
| See https://github.com/guardrail-dev/guardrail/issues/1591
| Ignored values: ${props.toList.map(_.showHistory).mkString(", ")}
|""".stripMargin)
}
m.downField("additionalProperties", _.getAdditionalProperties)
.indexedDistribute
.flatTraverse(
Expand Down

0 comments on commit 2323312

Please sign in to comment.