From 0afa589a7a7e44882c09aba2c34fcf4a69f1bdb3 Mon Sep 17 00:00:00 2001 From: Nabil Abdel-Hafeez <7283535+987Nabil@users.noreply.github.com> Date: Fri, 21 Jun 2024 13:26:37 +0200 Subject: [PATCH] Revert "Ignore non-content codecs when building multipart OpenAPI spec (#2745)" This reverts commit c7f0598dc514d90ad0ed9cba42fde44330cf0bab. --- .../http/endpoint/openapi/OpenAPIGenSpec.scala | 12 ------------ .../zio/http/endpoint/openapi/OpenAPIGen.scala | 17 ++--------------- 2 files changed, 2 insertions(+), 27 deletions(-) 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 1ce4ed605a..fcc06023b6 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 @@ -2442,18 +2442,6 @@ object OpenAPIGenSpec extends ZIOSpecDefault { | "components" : {} |}""".stripMargin)) }, - test("Non content codecs are ignored when building multipart schema") { - // We only test there is no exception when building the schema - val endpoint = - Endpoint(RoutePattern.POST / "post") - .in[Int]("foo") - .in[Boolean]("bar") - .query(QueryCodec.query("q")) - .out[Unit] - - SwaggerUI.routes("docs/openapi", OpenAPIGen.fromEndpoints(endpoint)) - assertCompletes - }, ) } 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 1617020397..e8595f0656 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 @@ -340,20 +340,6 @@ object OpenAPIGen { .nullable(optional(metadata)) .description(description(metadata)) .annotate(annotations) - case (JsonSchema.Object(p, _, r), JsonSchema.Null) => - JsonSchema - .Object(p, Left(false), r) - .deprecated(deprecated(metadata)) - .nullable(optional(metadata)) - .description(description(metadata)) - .annotate(annotations) - case (JsonSchema.Null, JsonSchema.Object(p, _, r)) => - JsonSchema - .Object(p, Left(false), r) - .deprecated(deprecated(metadata)) - .nullable(optional(metadata)) - .description(description(metadata)) - .annotate(annotations) case _ => throw new IllegalArgumentException("Multipart content without name.") } @@ -812,7 +798,8 @@ object OpenAPIGen { ( statusOrDefault, ( - AtomizedMetaCodecs.flatten(codec), + AtomizedMetaCodecs + .flatten(codec), contentAsJsonSchema(codec, referenceType = referenceType) _, ), )