Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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")

Expand Down Expand Up @@ -77,7 +79,7 @@ lazy val core = crossProject(JVMPlatform, NativePlatform)
)
.settings(
libraryDependencies ++= Seq(
"com.lihaoyi" %%% "upickle" % "4.1.0"
"com.lihaoyi" %%% "upickle" % upickleVersion
)
)

Expand Down
4 changes: 2 additions & 2 deletions modules/cli/src/main/scala/cli.scala
Original file line number Diff line number Diff line change
@@ -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

Expand Down
10 changes: 4 additions & 6 deletions modules/core/shared/src/main/scala/codegen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}"
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -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")

Expand Down