diff --git a/zio-http/src/main/scala/zio/http/endpoint/openapi/OpenAPIGen.scala b/zio-http/src/main/scala/zio/http/endpoint/openapi/OpenAPIGen.scala index 79af47a8f..c38af0a9b 100644 --- a/zio-http/src/main/scala/zio/http/endpoint/openapi/OpenAPIGen.scala +++ b/zio-http/src/main/scala/zio/http/endpoint/openapi/OpenAPIGen.scala @@ -1,19 +1,23 @@ package zio.http.endpoint.openapi import java.util.UUID + import scala.annotation.tailrec import scala.collection.{immutable, mutable} + import zio.Chunk import zio.json.EncoderOps import zio.json.ast.Json + import zio.schema.Schema.Record import zio.schema.codec.JsonCodec import zio.schema.{Schema, TypeId} + import zio.http._ import zio.http.codec.HttpCodec.Metadata import zio.http.codec._ -import zio.http.endpoint.openapi.JsonSchema.SchemaStyle import zio.http.endpoint._ +import zio.http.endpoint.openapi.JsonSchema.SchemaStyle object OpenAPIGen { private val PathWildcard = "pathWildcard" diff --git a/zio-http/src/test/scala/zio/http/endpoint/openapi/OpenAPIGenSpec.scala b/zio-http/src/test/scala/zio/http/endpoint/openapi/OpenAPIGenSpec.scala index af7117533..7344314b0 100644 --- a/zio-http/src/test/scala/zio/http/endpoint/openapi/OpenAPIGenSpec.scala +++ b/zio-http/src/test/scala/zio/http/endpoint/openapi/OpenAPIGenSpec.scala @@ -32,7 +32,7 @@ object OpenAPIGenSpec extends ZIOSpecDefault { private val simpleEndpoint = Endpoint( (GET / "static" / int("id") / uuid("uuid") ?? Doc.p("user id") / string("name")) ?? Doc.p("get path"), - ) + ) .in[SimpleInputBody](Doc.p("input body")) .out[SimpleOutputBody](Doc.p("output body")) .outError[NotFoundError](Status.NotFound, Doc.p("not found")) @@ -49,11 +49,10 @@ object OpenAPIGenSpec extends ZIOSpecDefault { .inCodec( (HttpCodec.content[OtherSimpleInputBody] ?? Doc.p("other input") | HttpCodec .content[SimpleInputBody] ?? Doc.p("simple input")) ?? Doc.p("takes either of the two input bodies"), - ) + ) .out[SimpleOutputBody] .outError[NotFoundError](Status.NotFound) - def minify(str: String): String = Json.encoder.encodeJson(Json.decoder.decodeJson(str).toOption.get, None).toString override def spec: Spec[TestEnvironment with Scope, Any] = @@ -794,21 +793,21 @@ object OpenAPIGenSpec extends ZIOSpecDefault { |}""".stripMargin assertTrue(json == minify(expectedJson)) }, - test("with query parameter, alternative input, alternative output and examples"){ + test("with query parameter, alternative input, alternative output and examples") { val endpoint = Endpoint(GET / "static") .inCodec( HttpCodec .content[OtherSimpleInputBody] ?? Doc.p("other input") | HttpCodec - .content[SimpleInputBody] ?? Doc.p("simple input") + .content[SimpleInputBody] ?? Doc.p("simple input"), ) .query(QueryCodec.paramStr("query")) .outCodec( HttpCodec .content[SimpleOutputBody] ?? Doc.p("simple output") | HttpCodec - .content[NotFoundError] ?? Doc.p("not found") + .content[NotFoundError] ?? Doc.p("not found"), ) val generated = OpenAPIGen.fromEndpoints("Simple Endpoint", "1.0", endpoint) @@ -1104,7 +1103,7 @@ object OpenAPIGenSpec extends ZIOSpecDefault { "1.0", simpleEndpoint, queryParamEndpoint, - alternativeInputEndpoint + alternativeInputEndpoint, ) val json = generated.toJson val expected = @@ -1409,7 +1408,7 @@ object OpenAPIGenSpec extends ZIOSpecDefault { | } |}""".stripMargin assertTrue(json == minify(expected)) - } + }, ) }