Skip to content

Commit

Permalink
clean
Browse files Browse the repository at this point in the history
  • Loading branch information
guizmaii committed Aug 26, 2024
1 parent d481836 commit 3d9db63
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -879,18 +879,19 @@ object JsonSchema {
val markedForRemoval = (for {
obj <- objects
otherObj <- objects
notNullableSchemas = obj.withoutAnnotations.asInstanceOf[JsonSchema.Object].properties.collect {
case (name, schema) if !schema.isNullable => name -> schema
}
notNullableSchemas =
obj
.withoutAnnotations
.asInstanceOf[JsonSchema.Object]
.properties
.filterNot { case (_, schema) => schema.isNullable }
if notNullableSchemas == otherObj.withoutAnnotations.asInstanceOf[JsonSchema.Object].properties
} yield otherObj).distinct

val minified = objects.filterNot(markedForRemoval.contains).map { obj =>
val annotations = obj.annotations
val asObject = obj.withoutAnnotations.asInstanceOf[JsonSchema.Object]
val notNullableSchemas = asObject.properties.collect {
case (name, schema) if !schema.isNullable => name -> schema
}
val notNullableSchemas = asObject.properties.filterNot { case (_, schema) => schema.isNullable }
asObject.required(asObject.required.filter(notNullableSchemas.contains)).annotate(annotations)
}
val newAnyOf = minified ++ others
Expand Down

0 comments on commit 3d9db63

Please sign in to comment.