From 897ba8fdfcfcea815cd5340311b8c6bdcb943232 Mon Sep 17 00:00:00 2001 From: Roman Langolf Date: Wed, 19 Nov 2025 14:49:40 +0100 Subject: [PATCH 1/4] fix enum type names containing scala keywords --- build.sbt | 14 ++++++++------ modules/cli/src/main/scala/cli.scala | 4 ++-- modules/core/shared/src/main/scala/codegen.scala | 8 +++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/build.sbt b/build.sbt index 421f240..0ec0e74 100644 --- a/build.sbt +++ b/build.sbt @@ -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.4" -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..97b5fea 100644 --- a/modules/core/shared/src/main/scala/codegen.scala +++ b/modules/core/shared/src/main/scala/codegen.scala @@ -440,7 +440,7 @@ 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 @@ -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: From 8cf7f35c2170c4d9e915851952d7f9b6fbf40d23 Mon Sep 17 00:00:00 2001 From: Roman Langolf Date: Wed, 19 Nov 2025 15:04:38 +0100 Subject: [PATCH 2/4] missing scala name mapping --- modules/core/shared/src/main/scala/codegen.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/core/shared/src/main/scala/codegen.scala b/modules/core/shared/src/main/scala/codegen.scala index 97b5fea..fe2de35 100644 --- a/modules/core/shared/src/main/scala/codegen.scala +++ b/modules/core/shared/src/main/scala/codegen.scala @@ -445,7 +445,7 @@ def schemasCode( 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)) }" } From b21705be7dc421448fc7c9628346cf3a5cdc24ab Mon Sep 17 00:00:00 2001 From: Roman Langolf Date: Wed, 19 Nov 2025 15:07:59 +0100 Subject: [PATCH 3/4] update deps --- build.sbt | 2 +- project/plugins.sbt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index 0ec0e74..769f36f 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( 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") From c360e54cc5094596d3177b2a418f25d3056fd04d Mon Sep 17 00:00:00 2001 From: Roman Langolf Date: Wed, 19 Nov 2025 15:24:42 +0100 Subject: [PATCH 4/4] downgrade jsoniter --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 769f36f..8729692 100644 --- a/build.sbt +++ b/build.sbt @@ -46,7 +46,7 @@ val zioVersion = "2.1.22" val zioJsonVersion = "0.7.45" -val jsoniterVersion = "2.38.4" +val jsoniterVersion = "2.38.2" val munitVersion = "1.2.1"