Skip to content

Commit ab5a204

Browse files
committed
add resource method description as comment, update dependencies
1 parent 0ef68ef commit ab5a204

File tree

5 files changed

+25
-23
lines changed

5 files changed

+25
-23
lines changed

build.sbt

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ ThisBuild / description := "Google Cloud client code generator"
22
ThisBuild / organization := "dev.rolang"
33
ThisBuild / licenses := Seq(License.MIT)
44
ThisBuild / homepage := Some(url("https://github.com/rolang/google-rest-api-codegen"))
5-
ThisBuild / scalaVersion := "3.7.1"
5+
ThisBuild / scalaVersion := "3.7.3"
66
ThisBuild / version ~= { v => if (v.contains('+')) s"${v.replace('+', '-')}-SNAPSHOT" else v }
77
ThisBuild / versionScheme := Some("early-semver")
88
ThisBuild / scmInfo := Some(
@@ -19,15 +19,18 @@ ThisBuild / developers := List(
1919
url = url("https://rolang.dev")
2020
)
2121
)
22-
ThisBuild / sonatypeCredentialHost := xerial.sbt.Sonatype.sonatypeCentralHost
2322

2423
lazy val testSettings = Seq(
2524
Compile / scalacOptions ++= Seq("-Xmax-inlines:64"),
2625
scalacOptions -= "-Xfatal-warnings"
2726
)
2827

2928
lazy val publishSettings = List(
30-
publishTo := sonatypePublishToBundle.value
29+
publishTo := {
30+
val centralSnapshots = "https://central.sonatype.com/repository/maven-snapshots/"
31+
if (isSnapshot.value) Some("central-snapshots" at centralSnapshots)
32+
else localStaging.value
33+
}
3134
)
3235

3336
lazy val noPublish = Seq(
@@ -37,15 +40,15 @@ lazy val noPublish = Seq(
3740
publish / skip := true
3841
)
3942

40-
lazy val sttpClient4Version = "4.0.9"
43+
lazy val sttpClient4Version = "4.0.11"
4144

42-
lazy val zioVersion = "2.1.16"
45+
lazy val zioVersion = "2.1.21"
4346

44-
lazy val zioJsonVersion = "0.7.39"
47+
lazy val zioJsonVersion = "0.7.44"
4548

46-
lazy val jsoniterVersion = "2.33.2"
49+
lazy val jsoniterVersion = "2.38.2"
4750

48-
lazy val munitVersion = "1.0.2"
51+
lazy val munitVersion = "1.2.0"
4952

5053
addCommandAlias("fmt", "all scalafmtSbt scalafmt test:scalafmt")
5154

modules/cli/src/main/scala/cli.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// for test runs using scala-cli
22
//> using jvm system
3-
//> using scala 3.7.1
3+
//> using scala 3.7.3
44
//> using file ../../../../core/shared/src/main/scala/codegen.scala
5-
//> using dep com.lihaoyi::upickle:4.2.1
5+
//> using dep com.lihaoyi::upickle:4.3.2
66

77
package gcp.codegen.cli
88

modules/core/shared/src/main/scala/codegen.scala

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def generateBySpec(
165165
| try {
166166
| Right(readFromArray[T](bytes))
167167
| } catch {
168-
| case e: Exception =>
168+
| case e: JsonReaderException =>
169169
| Left(DeserializationException(String(bytes, java.nio.charset.StandardCharsets.UTF_8), e, metadata))
170170
| }
171171
| else Left(UnexpectedStatusCode(String(bytes, java.nio.charset.StandardCharsets.UTF_8), metadata))
@@ -325,10 +325,12 @@ def resourceCode(
325325

326326
val (requiredParams, optParams) = method.scalaParameters.partition(_._2.required)
327327
def params(indent: String) =
328-
requiredParams.map((n, t) => s"${toComment(t.description)}$indent$n: ${t.scalaType(arrType)}") :::
328+
requiredParams.map((n, t) => s"${toComment(t.description, indent)}$indent$n: ${t.scalaType(arrType)}") :::
329329
req.toList.map(r => s"${indent}request: ${r.scalaType(arrType)}") :::
330330
uploadProtocol.toList.map((typ, default) => s"${indent}uploadProtocol: $typ = \"$default\"") :::
331-
optParams.map((n, t) => s"${toComment(t.description)}$indent$n: ${t.scalaType(arrType)} = None") :::
331+
optParams.map((n, t) =>
332+
s"${toComment(t.description, indent)}$indent$n: ${t.scalaType(arrType)} = None"
333+
) :::
332334
List(
333335
s"${indent}endpointUrl: Uri = $rootPkg.baseUrl",
334336
s"${indent}commonQueryParams: QueryParameters = " + ((
@@ -385,7 +387,8 @@ def resourceCode(
385387
)
386388
case _ => (responseType("String"), ".response(asEmptyResponse)")
387389

388-
s"""| def ${toScalaName(k)}(\n${params(indent = " ").mkString(",\n")}\n ): $resType = {$queryParams
390+
s"""|${toComment(method.description)} def ${toScalaName(k)}(\n${params(indent = " ")
391+
.mkString(",\n")}\n ): $resType = {$queryParams
389392
| $setReqUri
390393
| resourceRequest.${method.httpMethod.toLowerCase()}(requestUri.addParams(params))$body$mapResponse
391394
| }""".stripMargin
@@ -529,6 +532,7 @@ case class MediaUpload(protocols: Map[String, MediaUploadProtocol], accept: List
529532

530533
case class Method(
531534
httpMethod: String,
535+
description: Option[String],
532536
path: String,
533537
flatPath: Option[FlatPath],
534538
parameters: Map[String, Parameter],
@@ -589,6 +593,7 @@ object Method:
589593
given Reader[Method] = reader[ujson.Obj].map { o =>
590594
Method(
591595
httpMethod = o("httpMethod").str,
596+
description = o.value.get("description").map(_.str),
592597
path = o("path").str,
593598
flatPath = o.value
594599
.get("flatPath")

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=1.10.11
1+
sbt.version=1.11.6

project/plugins.sbt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.5.7")
1+
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.5.8")
22

33
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")
44

55
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.3.2")
66

7-
addSbtPlugin("com.github.sbt" % "sbt-dynver" % "5.0.1")
8-
9-
addSbtPlugin("org.typelevel" % "sbt-tpolecat" % "0.5.2")
10-
11-
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.3.0")
12-
13-
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.12.2")
7+
addSbtPlugin("com.github.sbt" % "sbt-dynver" % "5.1.1")

0 commit comments

Comments
 (0)