Skip to content

Commit

Permalink
[gen] clean whitespace noise in generated code (#3021)
Browse files Browse the repository at this point in the history
  • Loading branch information
hochgi authored Aug 16, 2024
1 parent 29123a9 commit 98b95b2
Show file tree
Hide file tree
Showing 23 changed files with 4 additions and 79 deletions.
5 changes: 0 additions & 5 deletions zio-http-gen/src/main/scala/zio/http/gen/scala/CodeGen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
2 changes: 0 additions & 2 deletions zio-http-gen/src/test/resources/AnimalWithMap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,5 @@ case class Animals(
counts: Map[String, Int],
)
object Animals {

implicit val codec: Schema[Animals] = DeriveSchema.gen[Animals]

}
2 changes: 0 additions & 2 deletions zio-http-gen/src/test/resources/ComponentAliasAge.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)

}
2 changes: 0 additions & 2 deletions zio-http-gen/src/test/resources/ComponentAliasId.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)

}
2 changes: 0 additions & 2 deletions zio-http-gen/src/test/resources/ComponentAliasName.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)

}
2 changes: 0 additions & 2 deletions zio-http-gen/src/test/resources/ComponentAliasSpecies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)

}
4 changes: 0 additions & 4 deletions zio-http-gen/src/test/resources/ComponentAnimal.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,14 @@ 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,
@zio.schema.annotation.validate[Float](zio.schema.validation.Validation.greaterThan(-1.0)) weight: Float,
@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]

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,14 @@ 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,
@zio.schema.annotation.validate[Float](zio.schema.validation.Validation.greaterThan(-1.0)) weight: Float,
@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]

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,5 @@ case class Animal(
id: Id.Type,
)
object Animal {

implicit val codec: Schema[Animal] = DeriveSchema.gen[Animal]

}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -29,8 +27,6 @@ object Animal {
dazzle: Chunk[Zebra],
) extends Animal
object Zebra {

implicit val codec: Schema[Zebra] = DeriveSchema.gen[Zebra]

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,5 @@ case class Animal(
id: Int,
)
object Animal {

implicit val codec: Schema[Animal] = DeriveSchema.gen[Animal]

}
2 changes: 0 additions & 2 deletions zio-http-gen/src/test/resources/ComponentHttpError.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,5 @@ case class HttpError(
messages: Option[String],
)
object HttpError {

implicit val codec: Schema[HttpError] = DeriveSchema.gen[HttpError]

}
2 changes: 0 additions & 2 deletions zio-http-gen/src/test/resources/ComponentLion.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,5 @@ case class Lion(
enemy: Option[Animal.Alligator],
)
object Lion {

implicit val codec: Schema[Lion] = DeriveSchema.gen[Lion]

}
Original file line number Diff line number Diff line change
Expand Up @@ -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]

}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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]

}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,16 @@ object Keywords {
`case`: String,
`match`: String,
)
object RequestBody {

object RequestBody {
implicit val codec: Schema[RequestBody] = DeriveSchema.gen[RequestBody]

}
case class ResponseBody(
`protected`: Boolean,
`trait`: String,
`type`: String,
)
object ResponseBody {

implicit val codec: Schema[ResponseBody] = DeriveSchema.gen[ResponseBody]

}

}

}
4 changes: 0 additions & 4 deletions zio-http-gen/src/test/resources/GeneratedPayment.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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]

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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]

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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]

}
}
2 changes: 0 additions & 2 deletions zio-http-gen/src/test/resources/GeneratedUser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,5 @@ case class User(
name: String,
)
object User {

implicit val codec: Schema[User] = DeriveSchema.gen[User]

}
2 changes: 0 additions & 2 deletions zio-http-gen/src/test/resources/GeneratedUserNameArray.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,5 @@ case class UserNameArray(
name: Chunk[String],
)
object UserNameArray {

implicit val codec: Schema[UserNameArray] = DeriveSchema.gen[UserNameArray]

}
2 changes: 0 additions & 2 deletions zio-http-gen/src/test/resources/GeneratedValues.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,5 @@ case class Values(
value2: String,
)
object Values {

implicit val codec: Schema[Values] = DeriveSchema.gen[Values]

}
2 changes: 0 additions & 2 deletions zio-http-gen/src/test/resources/ValidatedData.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,5 @@ case class ValidatedData(
) age: Int,
)
object ValidatedData {

implicit val codec: Schema[ValidatedData] = DeriveSchema.gen[ValidatedData]

}

0 comments on commit 98b95b2

Please sign in to comment.