From ae467ddf7d23fb050f1e1b9da76cad71676cfaad Mon Sep 17 00:00:00 2001 From: Jules Ivanic Date: Sun, 15 Dec 2024 03:15:10 +1100 Subject: [PATCH] Optimise `zio.http.endpoint.openapi.JsonSchema.fromZSchemaMulti` (#3239) Replace `.map(..).getOrElse(..)` with `.fold` Co-authored-by: Nabil Abdel-Hafeez <7283535+987Nabil@users.noreply.github.com> --- .../src/main/scala/zio/http/endpoint/openapi/JsonSchema.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 d2063c2bc8..0dc9d674ce 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 @@ -425,7 +425,7 @@ object JsonSchema { refType, seenWithCurrent, ) - nested.rootRef.map(k => nested.children + (k -> nested.root)).getOrElse(nested.children) + nested.rootRef.fold(ifEmpty = nested.children)(k => nested.children + (k -> nested.root)) } .toMap JsonSchemas(fromZSchema(record, SchemaStyle.Inline), ref, children)