From 98b95b2849209d50c1fe42374365dd78d556e3e4 Mon Sep 17 00:00:00 2001 From: Gilad Hoch Date: Fri, 16 Aug 2024 14:02:55 +0300 Subject: [PATCH] [gen] clean whitespace noise in generated code (#3021) --- .../src/main/scala/zio/http/gen/scala/CodeGen.scala | 5 ----- zio-http-gen/src/test/resources/AnimalWithMap.scala | 2 -- .../src/test/resources/ComponentAliasAge.scala | 2 -- .../src/test/resources/ComponentAliasId.scala | 2 -- .../src/test/resources/ComponentAliasName.scala | 2 -- .../src/test/resources/ComponentAliasSpecies.scala | 2 -- .../src/test/resources/ComponentAnimal.scala | 4 ---- .../ComponentAnimalWithAbstractMembers.scala | 4 ---- .../test/resources/ComponentAnimalWithAliases.scala | 2 -- .../ComponentAnimalWithFieldsReferencingSubs.scala | 4 ---- .../resources/ComponentAnimalWithoutAliases.scala | 2 -- .../src/test/resources/ComponentHttpError.scala | 2 -- zio-http-gen/src/test/resources/ComponentLion.scala | 2 -- .../EndpointWithRequestResponseBodyInline.scala | 8 +------- ...EndpointWithRequestResponseBodyInlineNested.scala | 12 ++---------- ...ntWithRequestResponseBodyWithKeywordsInline.scala | 8 +------- .../src/test/resources/GeneratedPayment.scala | 4 ---- .../GeneratedPaymentNamedDiscriminator.scala | 4 ---- .../resources/GeneratedPaymentNoDiscriminator.scala | 4 ---- zio-http-gen/src/test/resources/GeneratedUser.scala | 2 -- .../src/test/resources/GeneratedUserNameArray.scala | 2 -- .../src/test/resources/GeneratedValues.scala | 2 -- zio-http-gen/src/test/resources/ValidatedData.scala | 2 -- 23 files changed, 4 insertions(+), 79 deletions(-) diff --git a/zio-http-gen/src/main/scala/zio/http/gen/scala/CodeGen.scala b/zio-http-gen/src/main/scala/zio/http/gen/scala/CodeGen.scala index ec40ee992d..f64259936f 100644 --- a/zio-http-gen/src/main/scala/zio/http/gen/scala/CodeGen.scala +++ b/zio-http-gen/src/main/scala/zio/http/gen/scala/CodeGen.scala @@ -95,24 +95,19 @@ object CodeGen { sb ++= epc } sb += '\n' - sb += '\n' // redundant: may be dropped - but altering all test examples is needed, so it'll match schema.foreach(_.codecLineWithStringBuilder(name, sb)) - sb += '\n' // redundant: may be dropped - but altering all test examples is needed, so it'll match objectsContent.foreach { obj => sb += '\n' sb ++= obj } - sb += '\n' // redundant: may be dropped - but altering all test examples is needed, so it'll match ccContent.foreach { cc => sb += '\n' sb ++= cc } - sb += '\n' // redundant: may be dropped - but altering all test examples is needed, so it'll match enumContent.foreach { en => sb += '\n' sb ++= en } - sb += '\n' // redundant: may be dropped - but altering all test examples is needed, so it'll match sb ++= "\n}" sb.result() } diff --git a/zio-http-gen/src/test/resources/AnimalWithMap.scala b/zio-http-gen/src/test/resources/AnimalWithMap.scala index 2045057554..5236698bcb 100644 --- a/zio-http-gen/src/test/resources/AnimalWithMap.scala +++ b/zio-http-gen/src/test/resources/AnimalWithMap.scala @@ -7,7 +7,5 @@ case class Animals( counts: Map[String, Int], ) object Animals { - implicit val codec: Schema[Animals] = DeriveSchema.gen[Animals] - } diff --git a/zio-http-gen/src/test/resources/ComponentAliasAge.scala b/zio-http-gen/src/test/resources/ComponentAliasAge.scala index 6b06b96620..b373f7c540 100644 --- a/zio-http-gen/src/test/resources/ComponentAliasAge.scala +++ b/zio-http-gen/src/test/resources/ComponentAliasAge.scala @@ -4,7 +4,5 @@ import zio.prelude.Newtype import zio.schema.Schema object Age extends Newtype[Int] { - implicit val schema: Schema[Age.Type] = Schema.primitive[Int].transform(wrap, unwrap) - } \ No newline at end of file diff --git a/zio-http-gen/src/test/resources/ComponentAliasId.scala b/zio-http-gen/src/test/resources/ComponentAliasId.scala index c155234c4c..ecfa0bf968 100644 --- a/zio-http-gen/src/test/resources/ComponentAliasId.scala +++ b/zio-http-gen/src/test/resources/ComponentAliasId.scala @@ -4,7 +4,5 @@ import zio.prelude.Newtype import zio.schema.Schema object Id extends Newtype[Int] { - implicit val schema: Schema[Id.Type] = Schema.primitive[Int].transform(wrap, unwrap) - } \ No newline at end of file diff --git a/zio-http-gen/src/test/resources/ComponentAliasName.scala b/zio-http-gen/src/test/resources/ComponentAliasName.scala index a8fb613b62..7fb765b4e7 100644 --- a/zio-http-gen/src/test/resources/ComponentAliasName.scala +++ b/zio-http-gen/src/test/resources/ComponentAliasName.scala @@ -4,7 +4,5 @@ import zio.prelude.Newtype import zio.schema.Schema object Name extends Newtype[String] { - implicit val schema: Schema[Name.Type] = Schema.primitive[String].transform(wrap, unwrap) - } \ No newline at end of file diff --git a/zio-http-gen/src/test/resources/ComponentAliasSpecies.scala b/zio-http-gen/src/test/resources/ComponentAliasSpecies.scala index de60922bc8..f383ba6a3e 100644 --- a/zio-http-gen/src/test/resources/ComponentAliasSpecies.scala +++ b/zio-http-gen/src/test/resources/ComponentAliasSpecies.scala @@ -4,7 +4,5 @@ import zio.prelude.Newtype import zio.schema.Schema object Species extends Newtype[String] { - implicit val schema: Schema[Species.Type] = Schema.primitive[String].transform(wrap, unwrap) - } \ No newline at end of file diff --git a/zio-http-gen/src/test/resources/ComponentAnimal.scala b/zio-http-gen/src/test/resources/ComponentAnimal.scala index bab488d2a0..4ebaa49bd6 100644 --- a/zio-http-gen/src/test/resources/ComponentAnimal.scala +++ b/zio-http-gen/src/test/resources/ComponentAnimal.scala @@ -14,9 +14,7 @@ object Animal { @zio.schema.annotation.validate[Int](zio.schema.validation.Validation.greaterThan(-1)) num_teeth: Int, ) extends Animal object Alligator { - implicit val codec: Schema[Alligator] = DeriveSchema.gen[Alligator] - } case class Zebra( @zio.schema.annotation.validate[Int](zio.schema.validation.Validation.greaterThan(-1)) age: Int, @@ -24,8 +22,6 @@ object Animal { @zio.schema.annotation.validate[Int](zio.schema.validation.Validation.greaterThan(-1)) num_stripes: Int, ) extends Animal object Zebra { - implicit val codec: Schema[Zebra] = DeriveSchema.gen[Zebra] - } } diff --git a/zio-http-gen/src/test/resources/ComponentAnimalWithAbstractMembers.scala b/zio-http-gen/src/test/resources/ComponentAnimalWithAbstractMembers.scala index eea5078686..d2f5f241bd 100644 --- a/zio-http-gen/src/test/resources/ComponentAnimalWithAbstractMembers.scala +++ b/zio-http-gen/src/test/resources/ComponentAnimalWithAbstractMembers.scala @@ -17,9 +17,7 @@ object Animal { @zio.schema.annotation.validate[Int](zio.schema.validation.Validation.greaterThan(-1)) num_teeth: Int, ) extends Animal object Alligator { - implicit val codec: Schema[Alligator] = DeriveSchema.gen[Alligator] - } case class Zebra( @zio.schema.annotation.validate[Int](zio.schema.validation.Validation.greaterThan(-1)) age: Int, @@ -27,8 +25,6 @@ object Animal { @zio.schema.annotation.validate[Int](zio.schema.validation.Validation.greaterThan(-1)) num_stripes: Int, ) extends Animal object Zebra { - implicit val codec: Schema[Zebra] = DeriveSchema.gen[Zebra] - } } diff --git a/zio-http-gen/src/test/resources/ComponentAnimalWithAliases.scala b/zio-http-gen/src/test/resources/ComponentAnimalWithAliases.scala index 0f89f19a1c..883c911736 100644 --- a/zio-http-gen/src/test/resources/ComponentAnimalWithAliases.scala +++ b/zio-http-gen/src/test/resources/ComponentAnimalWithAliases.scala @@ -11,7 +11,5 @@ case class Animal( id: Id.Type, ) object Animal { - implicit val codec: Schema[Animal] = DeriveSchema.gen[Animal] - } \ No newline at end of file diff --git a/zio-http-gen/src/test/resources/ComponentAnimalWithFieldsReferencingSubs.scala b/zio-http-gen/src/test/resources/ComponentAnimalWithFieldsReferencingSubs.scala index e8d35a7300..5f6d6649f1 100644 --- a/zio-http-gen/src/test/resources/ComponentAnimalWithFieldsReferencingSubs.scala +++ b/zio-http-gen/src/test/resources/ComponentAnimalWithFieldsReferencingSubs.scala @@ -18,9 +18,7 @@ object Animal { @zio.schema.annotation.validate[Int](zio.schema.validation.Validation.greaterThan(-1)) num_teeth: Int, ) extends Animal object Alligator { - implicit val codec: Schema[Alligator] = DeriveSchema.gen[Alligator] - } case class Zebra( @zio.schema.annotation.validate[Int](zio.schema.validation.Validation.greaterThan(-1)) age: Int, @@ -29,8 +27,6 @@ object Animal { dazzle: Chunk[Zebra], ) extends Animal object Zebra { - implicit val codec: Schema[Zebra] = DeriveSchema.gen[Zebra] - } } diff --git a/zio-http-gen/src/test/resources/ComponentAnimalWithoutAliases.scala b/zio-http-gen/src/test/resources/ComponentAnimalWithoutAliases.scala index d87cf706d2..99a16983cf 100644 --- a/zio-http-gen/src/test/resources/ComponentAnimalWithoutAliases.scala +++ b/zio-http-gen/src/test/resources/ComponentAnimalWithoutAliases.scala @@ -11,7 +11,5 @@ case class Animal( id: Int, ) object Animal { - implicit val codec: Schema[Animal] = DeriveSchema.gen[Animal] - } \ No newline at end of file diff --git a/zio-http-gen/src/test/resources/ComponentHttpError.scala b/zio-http-gen/src/test/resources/ComponentHttpError.scala index 3fa594a62f..49d8c5f9bd 100644 --- a/zio-http-gen/src/test/resources/ComponentHttpError.scala +++ b/zio-http-gen/src/test/resources/ComponentHttpError.scala @@ -6,7 +6,5 @@ case class HttpError( messages: Option[String], ) object HttpError { - implicit val codec: Schema[HttpError] = DeriveSchema.gen[HttpError] - } diff --git a/zio-http-gen/src/test/resources/ComponentLion.scala b/zio-http-gen/src/test/resources/ComponentLion.scala index b28b727c5e..f6c3dcd0ec 100644 --- a/zio-http-gen/src/test/resources/ComponentLion.scala +++ b/zio-http-gen/src/test/resources/ComponentLion.scala @@ -7,7 +7,5 @@ case class Lion( enemy: Option[Animal.Alligator], ) object Lion { - implicit val codec: Schema[Lion] = DeriveSchema.gen[Lion] - } \ No newline at end of file diff --git a/zio-http-gen/src/test/resources/EndpointWithRequestResponseBodyInline.scala b/zio-http-gen/src/test/resources/EndpointWithRequestResponseBodyInline.scala index 5ef216a88e..524fc5c9e4 100644 --- a/zio-http-gen/src/test/resources/EndpointWithRequestResponseBodyInline.scala +++ b/zio-http-gen/src/test/resources/EndpointWithRequestResponseBodyInline.scala @@ -16,21 +16,15 @@ object Users { id: Int, name: String, ) - object RequestBody { - + object RequestBody { implicit val codec: Schema[RequestBody] = DeriveSchema.gen[RequestBody] - } case class ResponseBody( id: Int, name: String, ) object ResponseBody { - implicit val codec: Schema[ResponseBody] = DeriveSchema.gen[ResponseBody] - } - } - } diff --git a/zio-http-gen/src/test/resources/EndpointWithRequestResponseBodyInlineNested.scala b/zio-http-gen/src/test/resources/EndpointWithRequestResponseBodyInlineNested.scala index c503a0f509..cc2dce0223 100644 --- a/zio-http-gen/src/test/resources/EndpointWithRequestResponseBodyInlineNested.scala +++ b/zio-http-gen/src/test/resources/EndpointWithRequestResponseBodyInlineNested.scala @@ -17,30 +17,22 @@ object Users { name: String, address: Option[Address], ) - object RequestBody { - + object RequestBody { implicit val codec: Schema[RequestBody] = DeriveSchema.gen[RequestBody] - } case class Address( number: Option[Int], street: Option[String], ) - object Address { - + object Address { implicit val codec: Schema[Address] = DeriveSchema.gen[Address] - } case class ResponseBody( id: Int, name: String, ) object ResponseBody { - implicit val codec: Schema[ResponseBody] = DeriveSchema.gen[ResponseBody] - } - } - } diff --git a/zio-http-gen/src/test/resources/EndpointWithRequestResponseBodyWithKeywordsInline.scala b/zio-http-gen/src/test/resources/EndpointWithRequestResponseBodyWithKeywordsInline.scala index 10c28ac151..496f1c9284 100644 --- a/zio-http-gen/src/test/resources/EndpointWithRequestResponseBodyWithKeywordsInline.scala +++ b/zio-http-gen/src/test/resources/EndpointWithRequestResponseBodyWithKeywordsInline.scala @@ -17,10 +17,8 @@ object Keywords { `case`: String, `match`: String, ) - object RequestBody { - + object RequestBody { implicit val codec: Schema[RequestBody] = DeriveSchema.gen[RequestBody] - } case class ResponseBody( `protected`: Boolean, @@ -28,11 +26,7 @@ object Keywords { `type`: String, ) object ResponseBody { - implicit val codec: Schema[ResponseBody] = DeriveSchema.gen[ResponseBody] - } - } - } diff --git a/zio-http-gen/src/test/resources/GeneratedPayment.scala b/zio-http-gen/src/test/resources/GeneratedPayment.scala index dc1324a71c..e1cc7ddf8d 100644 --- a/zio-http-gen/src/test/resources/GeneratedPayment.scala +++ b/zio-http-gen/src/test/resources/GeneratedPayment.scala @@ -13,17 +13,13 @@ object Payment { cvv: String, ) object Card { - implicit val codec: Schema[Card] = DeriveSchema.gen[Card] - } @caseName("cash") case class Cash( amount: Int, ) object Cash { - implicit val codec: Schema[Cash] = DeriveSchema.gen[Cash] - } } diff --git a/zio-http-gen/src/test/resources/GeneratedPaymentNamedDiscriminator.scala b/zio-http-gen/src/test/resources/GeneratedPaymentNamedDiscriminator.scala index a893218ba1..2c557f1b3b 100644 --- a/zio-http-gen/src/test/resources/GeneratedPaymentNamedDiscriminator.scala +++ b/zio-http-gen/src/test/resources/GeneratedPaymentNamedDiscriminator.scala @@ -14,17 +14,13 @@ object PaymentNamedDiscriminator { cvv: String, ) extends PaymentNamedDiscriminator object Card { - implicit val codec: Schema[Card] = DeriveSchema.gen[Card] - } @caseName("cash") case class Cash( amount: Int, ) extends PaymentNamedDiscriminator object Cash { - implicit val codec: Schema[Cash] = DeriveSchema.gen[Cash] - } } diff --git a/zio-http-gen/src/test/resources/GeneratedPaymentNoDiscriminator.scala b/zio-http-gen/src/test/resources/GeneratedPaymentNoDiscriminator.scala index 9684806325..6b8eba312c 100644 --- a/zio-http-gen/src/test/resources/GeneratedPaymentNoDiscriminator.scala +++ b/zio-http-gen/src/test/resources/GeneratedPaymentNoDiscriminator.scala @@ -13,16 +13,12 @@ object PaymentNoDiscriminator { cvv: String, ) extends PaymentNoDiscriminator object Card { - implicit val codec: Schema[Card] = DeriveSchema.gen[Card] - } case class Cash( amount: Int, ) extends PaymentNoDiscriminator object Cash { - implicit val codec: Schema[Cash] = DeriveSchema.gen[Cash] - } } diff --git a/zio-http-gen/src/test/resources/GeneratedUser.scala b/zio-http-gen/src/test/resources/GeneratedUser.scala index 22d95ad94f..de571e4173 100644 --- a/zio-http-gen/src/test/resources/GeneratedUser.scala +++ b/zio-http-gen/src/test/resources/GeneratedUser.scala @@ -7,7 +7,5 @@ case class User( name: String, ) object User { - implicit val codec: Schema[User] = DeriveSchema.gen[User] - } diff --git a/zio-http-gen/src/test/resources/GeneratedUserNameArray.scala b/zio-http-gen/src/test/resources/GeneratedUserNameArray.scala index dce6b4f99a..7f79054c8f 100644 --- a/zio-http-gen/src/test/resources/GeneratedUserNameArray.scala +++ b/zio-http-gen/src/test/resources/GeneratedUserNameArray.scala @@ -8,7 +8,5 @@ case class UserNameArray( name: Chunk[String], ) object UserNameArray { - implicit val codec: Schema[UserNameArray] = DeriveSchema.gen[UserNameArray] - } diff --git a/zio-http-gen/src/test/resources/GeneratedValues.scala b/zio-http-gen/src/test/resources/GeneratedValues.scala index c451c1145f..5d5057bae0 100644 --- a/zio-http-gen/src/test/resources/GeneratedValues.scala +++ b/zio-http-gen/src/test/resources/GeneratedValues.scala @@ -7,7 +7,5 @@ case class Values( value2: String, ) object Values { - implicit val codec: Schema[Values] = DeriveSchema.gen[Values] - } diff --git a/zio-http-gen/src/test/resources/ValidatedData.scala b/zio-http-gen/src/test/resources/ValidatedData.scala index f30b02ac57..8f73248c9d 100644 --- a/zio-http-gen/src/test/resources/ValidatedData.scala +++ b/zio-http-gen/src/test/resources/ValidatedData.scala @@ -9,7 +9,5 @@ case class ValidatedData( ) age: Int, ) object ValidatedData { - implicit val codec: Schema[ValidatedData] = DeriveSchema.gen[ValidatedData] - }