diff --git a/build.sbt b/build.sbt index 421f240..8729692 100644 --- a/build.sbt +++ b/build.sbt @@ -2,7 +2,7 @@ ThisBuild / description := "Google Cloud client code generator" ThisBuild / organization := "dev.rolang" ThisBuild / licenses := Seq(License.MIT) ThisBuild / homepage := Some(url("https://github.com/rolang/google-rest-api-codegen")) -ThisBuild / scalaVersion := "3.7.3" +ThisBuild / scalaVersion := "3.7.4" ThisBuild / version ~= { v => if (v.contains('+')) s"${v.replace('+', '-')}-SNAPSHOT" else v } ThisBuild / versionScheme := Some("early-semver") ThisBuild / scmInfo := Some( @@ -40,15 +40,17 @@ lazy val noPublish = Seq( publish / skip := true ) -lazy val sttpClient4Version = "4.0.11" +val sttpClient4Version = "4.0.13" -lazy val zioVersion = "2.1.21" +val zioVersion = "2.1.22" -lazy val zioJsonVersion = "0.7.44" +val zioJsonVersion = "0.7.45" -lazy val jsoniterVersion = "2.38.2" +val jsoniterVersion = "2.38.2" -lazy val munitVersion = "1.2.0" +val munitVersion = "1.2.1" + +val upickleVersion = "4.4.1" addCommandAlias("fmt", "all scalafmtSbt scalafmt test:scalafmt") @@ -77,7 +79,7 @@ lazy val core = crossProject(JVMPlatform, NativePlatform) ) .settings( libraryDependencies ++= Seq( - "com.lihaoyi" %%% "upickle" % "4.1.0" + "com.lihaoyi" %%% "upickle" % upickleVersion ) ) diff --git a/modules/cli/src/main/scala/cli.scala b/modules/cli/src/main/scala/cli.scala index 36c6f32..dad629c 100644 --- a/modules/cli/src/main/scala/cli.scala +++ b/modules/cli/src/main/scala/cli.scala @@ -1,8 +1,8 @@ // for test runs using scala-cli //> using jvm system -//> using scala 3.7.3 +//> using scala 3.7.4 //> using file ../../../../core/shared/src/main/scala/codegen.scala -//> using dep com.lihaoyi::upickle:4.3.2 +//> using dep com.lihaoyi::upickle:4.4.1 package gcp.codegen.cli diff --git a/modules/core/shared/src/main/scala/codegen.scala b/modules/core/shared/src/main/scala/codegen.scala index 4fa8969..fe2de35 100644 --- a/modules/core/shared/src/main/scala/codegen.scala +++ b/modules/core/shared/src/main/scala/codegen.scala @@ -440,12 +440,12 @@ def schemasCode( val scalaName = s.id.scalaName s"""|case class $scalaName( |${s - .scalaProperties(hasProps) + .sortedProperties(hasProps) .map { (n, t) => val enumType = if jsonCodec == JsonCodec.ZioJson then SchemaType.EnumType.Literal else SchemaType.EnumType.Nominal(s"$scalaName.${toScalaTypeName(n)}") - s"${toComment(t.withTypeDescription)} $n: ${ + s"${toComment(t.withTypeDescription)} ${toScalaName(n)}: ${ (if (t.optional) s"${t.scalaType(arrType, enumType)} = None" else t.scalaType(arrType, enumType)) }" } @@ -483,7 +483,7 @@ def commonSchemaCodecs( case (JsonCodec.Jsoniter, ArrayType.ZioChunk) => schemas.toList .flatMap((sk, sv) => - sv.scalaProperties(hasProps) + sv.sortedProperties(hasProps) .collect { case (k, Property(_, SchemaType.Array(typ, _), _)) => val enumType = if jsonCodec == JsonCodec.ZioJson then SchemaType.EnumType.Literal @@ -817,14 +817,12 @@ case class Schema( // required properties first // references wihout properties are excluded - private def sortedProps(hasProps: SchemaPath => Boolean): List[(String, Property)] = + def sortedProperties(hasProps: SchemaPath => Boolean): List[(String, Property)] = properties .filter { (_, prop) => prop.schemaPath.forall(hasProps(_)) } .sortBy(_._2.typ.optional) - def scalaProperties(hasProps: SchemaPath => Boolean): List[(String, Property)] = - sortedProps(hasProps).map { (k, prop) => (toScalaName(k), prop) } } object Schema: diff --git a/project/plugins.sbt b/project/plugins.sbt index 4332bc1..b0dc3e5 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,4 +1,4 @@ -addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.5.8") +addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.5.9") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")