diff --git a/zio-http/jvm/src/test/scala/zio/http/endpoint/openapi/OpenAPIGenSpec.scala b/zio-http/jvm/src/test/scala/zio/http/endpoint/openapi/OpenAPIGenSpec.scala index f24807a138..7ca59548c8 100644 --- a/zio-http/jvm/src/test/scala/zio/http/endpoint/openapi/OpenAPIGenSpec.scala +++ b/zio-http/jvm/src/test/scala/zio/http/endpoint/openapi/OpenAPIGenSpec.scala @@ -1029,8 +1029,7 @@ object OpenAPIGenSpec extends ZIOSpecDefault { | { | "$ref" : "#/components/schemas/Payload" | } - | ], - | "description" : "" + | ] | } | } | }, 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 cdc38d22d2..d2063c2bc8 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 @@ -55,11 +55,11 @@ private[openapi] case class SerializableJsonSchema( if (nullable && schemaType.isDefined) copy(schemaType = Some(schemaType.get.add("null"))) else if (nullable && oneOf.isDefined) - copy(oneOf = Some(oneOf.get :+ typeNull)) + copy(oneOf = Some((oneOf.get :+ typeNull).distinct)) else if (nullable && allOf.isDefined) - SerializableJsonSchema(allOf = Some(Chunk(this, typeNull))) + SerializableJsonSchema(allOf = Some((allOf.get :+ typeNull).distinct)) else if (nullable && anyOf.isDefined) - copy(anyOf = Some(anyOf.get :+ typeNull)) + copy(anyOf = Some((anyOf.get :+ typeNull).distinct)) else if (nullable && ref.isDefined) SerializableJsonSchema(anyOf = Some(Chunk(typeNull, this))) else diff --git a/zio-http/shared/src/main/scala/zio/http/endpoint/openapi/OpenAPIGen.scala b/zio-http/shared/src/main/scala/zio/http/endpoint/openapi/OpenAPIGen.scala index 201bddb047..19727820ae 100644 --- a/zio-http/shared/src/main/scala/zio/http/endpoint/openapi/OpenAPIGen.scala +++ b/zio-http/shared/src/main/scala/zio/http/endpoint/openapi/OpenAPIGen.scala @@ -984,6 +984,10 @@ object OpenAPIGen { } case t: Transform[_, _, _] => nominal(t.schema, referenceType) + case Schema.Optional(inner, _) => + nominal(inner, referenceType) + case Schema.Lazy(schema0) => + nominal(schema0(), referenceType) case _ => None }