From 3d9db63b9e066298ba1ab22cba13b0dbefef7a96 Mon Sep 17 00:00:00 2001 From: Jules Ivanic Date: Mon, 26 Aug 2024 21:25:45 +1000 Subject: [PATCH] clean --- .../zio/http/endpoint/openapi/JsonSchema.scala | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/zio-http/shared/src/main/scala/zio/http/endpoint/openapi/JsonSchema.scala b/zio-http/shared/src/main/scala/zio/http/endpoint/openapi/JsonSchema.scala index 19a1dd5cda..9aca96ba04 100644 --- a/zio-http/shared/src/main/scala/zio/http/endpoint/openapi/JsonSchema.scala +++ b/zio-http/shared/src/main/scala/zio/http/endpoint/openapi/JsonSchema.scala @@ -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