Skip to content

Commit e89d83d

Browse files
Update scalafmt-core to 3.11.3 (#5409)
## About this PR πŸ“¦ Updates [org.scalameta:scalafmt-core](https://github.com/scalameta/scalafmt) from `3.11.2` to `3.11.3` πŸ“œ [GitHub Release Notes](https://github.com/scalameta/scalafmt/releases/tag/v3.11.3) - [Version Diff](scalameta/scalafmt@v3.11.2...v3.11.3) ## Usage βœ… **Please merge!** I'll automatically update this PR to resolve conflicts as long as you don't change it yourself. If you'd like to skip this version, you can just close this PR. If you have any feedback, just mention me in the comments below. Configure Scala Steward for your repository with a [`.scala-steward.conf`](https://github.com/scala-steward-org/scala-steward/blob/ce30bf139b12ba2f32fba6267b7b07ca77f11b78/docs/repo-specific-configuration.md) file. _Have a fantastic day writing Scala!_ <details> <summary>πŸ” Files still referring to the old version number</summary> The following files still refer to the old version number (3.11.2). You might want to review and update them manually. ``` .git-blame-ignore-revs ``` </details> <details> <summary>βš™ Adjust future updates</summary> Add this to your `.scala-steward.conf` file to ignore future updates of this dependency: ``` updates.ignore = [ { groupId = "org.scalameta", artifactId = "scalafmt-core" } ] ``` Or, add this to slow down future updates of this dependency: ``` dependencyOverrides = [{ pullRequests = { frequency = "30 days" }, dependency = { groupId = "org.scalameta", artifactId = "scalafmt-core" } }] ``` </details> <sup> labels: library-update, early-semver-patch, semver-spec-patch, old-version-remains, commit-count:n:3 </sup> <!-- scala-steward = { "Update" : { "ForArtifactId" : { "crossDependency" : [ { "groupId" : "org.scalameta", "artifactId" : { "name" : "scalafmt-core", "maybeCrossName" : "scalafmt-core_2.13" }, "version" : "3.11.2", "sbtVersion" : null, "scalaVersion" : null, "configurations" : null } ], "newerVersions" : [ "3.11.3" ], "newerGroupId" : null, "newerArtifactId" : null } }, "Labels" : [ "library-update", "early-semver-patch", "semver-spec-patch", "old-version-remains", "commit-count:n:3" ] } --> --------- Co-authored-by: scala-steward <scala-steward>
1 parent ba397b8 commit e89d83d

12 files changed

Lines changed: 110 additions & 49 deletions

File tree

β€Ž.git-blame-ignore-revsβ€Ž

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,6 @@ da85b978db204adf6f236bfd4e453628a6d4cdda
8787

8888
# Scala Steward: Reformat with scalafmt 3.11.2
8989
400127d53ebf236548879443afc5b8d08afdd625
90+
91+
# Scala Steward: Reformat with scalafmt 3.11.3
92+
0bc1a9c10d5f2a78304535fdcb74b60c43c70839

β€Ž.scalafmt.confβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version = 3.11.2
1+
version = 3.11.3
22
maxColumn = 140
33
runner.dialect = scala213source3
44
fileOverride {

β€Žopenapi-codegen/core/src/main/scala/sttp/tapir/codegen/endpoints/OutComponent.scalaβ€Ž

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,9 @@ object OutComponent {
154154
val wrappers = declsByWrapperClassName
155155
.map { case (name, seq) =>
156156
val defns =
157-
seq.map { case (_, t, _, ct) => s"""override def ${NameHelpers.safeVariableName(ct)}: () => $t = () => value""" }.sorted
157+
seq
158+
.map { case (_, t, _, ct) => s"""override def ${NameHelpers.safeVariableName(ct)}: () => $t = () => value""" }
159+
.sorted
158160
.mkString("\n")
159161
s"""case class ${name}(value: ${seq.head._2}) extends $traitName{
160162
|${indent(2)(defns)}

β€Žopenapi-codegen/core/src/main/scala/sttp/tapir/codegen/json/CirceSerdeImpl.scalaβ€Ž

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,9 @@ object CirceSerdeImpl {
151151
val encoders = subtypeNames
152152
.map { t =>
153153
val jsonTypeName = JavaEscape.escapeString(schemaToJsonMapping(t))
154-
s"""case x: $t => io.circe.Encoder[$t].apply(x).mapObject(_.add("${JavaEscape.escapeString(discriminator.propertyName)}", io.circe.Json.fromString("$jsonTypeName")))"""
154+
s"""case x: $t => io.circe.Encoder[$t].apply(x).mapObject(_.add("${JavaEscape.escapeString(
155+
discriminator.propertyName
156+
)}", io.circe.Json.fromString("$jsonTypeName")))"""
155157
}
156158
.mkString("\n")
157159
val decoders = subtypeNames

β€Žopenapi-codegen/core/src/main/scala/sttp/tapir/codegen/json/JsoniterSerdeImpl.scalaβ€Ž

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,21 +270,27 @@ object JsoniterSerdeImpl {
270270
val codecName = getJsoniterName(name)
271271
val serde =
272272
if (useCustomJsoniterSerdes)
273-
s"""implicit lazy val $codecName: $jsoniterPkgCore.JsonValueCodec[$name] = $jsoniterPkgMacros.JsonCodecMaker.makeOpenapiLike("${JavaEscape.escapeString(discriminator.propertyName)}", {$discriminatorMap})"""
273+
s"""implicit lazy val $codecName: $jsoniterPkgCore.JsonValueCodec[$name] = $jsoniterPkgMacros.JsonCodecMaker.makeOpenapiLike("${JavaEscape
274+
.escapeString(discriminator.propertyName)}", {$discriminatorMap})"""
274275
else {
275276
val config =
276-
s"""$jsoniterBaseConfig.withRequireDiscriminatorFirst(false).withDiscriminatorFieldName(Some("${JavaEscape.escapeString(discriminator.propertyName)}")).withAdtLeafClassNameMapper(x => com.github.plokhotnyuk.jsoniter_scala.macros.JsonCodecMaker.simpleClassName(x) match {$discriminatorMap})"""
277+
s"""$jsoniterBaseConfig.withRequireDiscriminatorFirst(false).withDiscriminatorFieldName(Some("${JavaEscape.escapeString(
278+
discriminator.propertyName
279+
)}")).withAdtLeafClassNameMapper(x => com.github.plokhotnyuk.jsoniter_scala.macros.JsonCodecMaker.simpleClassName(x) match {$discriminatorMap})"""
277280
s"implicit lazy val $codecName: $jsoniterPkgCore.JsonValueCodec[$name] = $jsoniterPkgMacros.JsonCodecMaker.make($config)"
278281
}
279282

280283
s"""$serde
281284
|""".stripMargin
282285
} else {
283286
if (useCustomJsoniterSerdes)
284-
s"""implicit lazy val $codecName: $jsoniterPkgCore.JsonValueCodec[$name] = $jsoniterPkgMacros.JsonCodecMaker.makeOpenapiLike("${JavaEscape.escapeString(discriminator.propertyName)}")"""
287+
s"""implicit lazy val $codecName: $jsoniterPkgCore.JsonValueCodec[$name] = $jsoniterPkgMacros.JsonCodecMaker.makeOpenapiLike("${JavaEscape
288+
.escapeString(discriminator.propertyName)}")"""
285289
else {
286290
val config =
287-
s"""$jsoniterBaseConfig.withRequireDiscriminatorFirst(false).withDiscriminatorFieldName(Some("${JavaEscape.escapeString(discriminator.propertyName)}"))"""
291+
s"""$jsoniterBaseConfig.withRequireDiscriminatorFirst(false).withDiscriminatorFieldName(Some("${JavaEscape.escapeString(
292+
discriminator.propertyName
293+
)}"))"""
288294
s"implicit lazy val $codecName: $jsoniterPkgCore.JsonValueCodec[$name] = $jsoniterPkgMacros.JsonCodecMaker.make($config)"
289295
}
290296
}

β€Žopenapi-codegen/core/src/main/scala/sttp/tapir/codegen/json/ZioSerdeImpl.scalaβ€Ž

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,16 @@ object ZioSerdeImpl {
146146
val encoders = subtypeNames
147147
.map { t =>
148148
val jsonTypeName = JavaEscape.escapeString(schemaToJsonMapping(t))
149-
s"""case x: $t => zio.json.ast.Json.decoder.decodeJson(zio.json.JsonEncoder[$t].encodeJson(x)).getOrElse(throw new RuntimeException("Unable to encode tagged ADT type ${name} to json")).mapObject(_.add("${JavaEscape.escapeString(discriminator.propertyName)}", zio.json.ast.Json.Str("$jsonTypeName")))"""
149+
s"""case x: $t => zio.json.ast.Json.decoder.decodeJson(zio.json.JsonEncoder[$t].encodeJson(x)).getOrElse(throw new RuntimeException("Unable to encode tagged ADT type ${name} to json")).mapObject(_.add("${JavaEscape
150+
.escapeString(discriminator.propertyName)}", zio.json.ast.Json.Str("$jsonTypeName")))"""
150151
}
151152
.mkString("\n")
152153
val decoders = subtypeNames
153-
.map { t => s"""case zio.json.ast.Json.Str("${JavaEscape.escapeString(schemaToJsonMapping(t))}") => zio.json.JsonDecoder[$t].fromJsonAST(json)""" }
154+
.map { t =>
155+
s"""case zio.json.ast.Json.Str("${JavaEscape.escapeString(
156+
schemaToJsonMapping(t)
157+
)}") => zio.json.JsonDecoder[$t].fromJsonAST(json)"""
158+
}
154159
.mkString("\n")
155160
s"""implicit lazy val ${uncapitalisedName}JsonEncoder: zio.json.JsonEncoder[$name] = zio.json.JsonEncoder[zio.json.ast.Json].contramap {
156161
|${indent(2)(encoders)}

β€Žopenapi-codegen/core/src/main/scala/sttp/tapir/codegen/openapi/models/DefaultValueRenderer.scalaβ€Ž

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,11 @@ object DefaultValueRenderer {
5353
thisType match {
5454
case ref: OpenapiSchemaRef => renderMapWithName(kvs)(allModels, lookup(allModels, ref), ref.stripped)
5555
case OpenapiSchemaMap(types, _, _) =>
56-
s"Map(${kvs.map { case (k, v) =>
57-
s""""${JavaEscape.escapeString(k)}" -> ${render(allModels, types, isOptional = false, RenderConfig())(v)}"""
58-
}.mkString(", ")})"
56+
s"Map(${kvs
57+
.map { case (k, v) =>
58+
s""""${JavaEscape.escapeString(k)}" -> ${render(allModels, types, isOptional = false, RenderConfig())(v)}"""
59+
}
60+
.mkString(", ")})"
5961
case OpenapiSchemaObject(properties, required, _, _) =>
6062
val kvsWithProps = kvs.map { case (k, v) => (k, (v, properties.get(k).getOrElse(errorForKey(k)))) }
6163
s"$name(${kvsWithProps
@@ -127,9 +129,11 @@ object DefaultValueRenderer {
127129
renderMapWithName(jsonObject.toMap)(allModels, lookup(allModels, ref), ref.stripped)
128130
case OpenapiSchemaAllOf(Seq(singleElement)) => render(allModels, singleElement, isOptional = false, config)(json)
129131
case OpenapiSchemaMap(types, _, _) =>
130-
s"Map(${jsonObject.toMap.map { case (k, v) =>
131-
s""""${JavaEscape.escapeString(k)}" -> ${render(allModels, types, isOptional = false, config)(v)}"""
132-
}.mkString(", ")})"
132+
s"Map(${jsonObject.toMap
133+
.map { case (k, v) =>
134+
s""""${JavaEscape.escapeString(k)}" -> ${render(allModels, types, isOptional = false, config)(v)}"""
135+
}
136+
.mkString(", ")})"
133137
case other => fail("map", other)
134138
}
135139
)

β€Žopenapi-codegen/core/src/main/scala/sttp/tapir/codegen/security/SecurityGenerator.scalaβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ object SecurityGenerator {
120120
val refreshUrl = f.refreshUrl.map(u => s"""Some("${JavaEscape.escapeString(u)}")""").getOrElse("None")
121121
(s"""auth.oauth2.clientCredentialsFlow("$tokenUrl", $refreshUrl)""", "Bearer", schemeName)
122122
case (OAuth2FlowType.authorizationCode, f) =>
123-
val authUrl = JavaEscape.escapeString(f.authorizationUrl.getOrElse(bail("authorizationUrl required for authorizationCode flow")))
123+
val authUrl =
124+
JavaEscape.escapeString(f.authorizationUrl.getOrElse(bail("authorizationUrl required for authorizationCode flow")))
124125
val tokenUrl = JavaEscape.escapeString(f.tokenUrl.getOrElse(bail("tokenUrl required for authorizationCode flow")))
125126
val refreshUrl = f.refreshUrl.map(u => s"""Some("${JavaEscape.escapeString(u)}")""").getOrElse("None")
126127
(s"""auth.oauth2.authorizationCodeFlow("$authUrl", "$tokenUrl", $refreshUrl)""", "Bearer", schemeName)

β€Žopenapi-codegen/core/src/main/scala/sttp/tapir/codegen/util/NameValidation.scalaβ€Ž

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,18 @@ import sttp.tapir.codegen.openapi.models.OpenapiModels.{OpenapiDocument, Openapi
44
import sttp.tapir.codegen.openapi.models.OpenapiSchemaType
55
import sttp.tapir.codegen.openapi.models.OpenapiSchemaType._
66

7-
/** Ingestion-time validation of names taken from an (untrusted) OpenAPI document that the code generator emits into
8-
* *identifier* positions β€” component schema names, `$ref` targets, object property names and (when used for object
9-
* names) tags. These become class/trait/type/field/val names in the generated source, frequently by raw string
10-
* concatenation (e.g. `${name.capitalize}Decoder`) rather than backtick-quoting, so a name containing characters
11-
* outside the OpenAPI-permitted identifier set could inject arbitrary Scala code.
7+
/** Ingestion-time validation of names taken from an (untrusted) OpenAPI document that the code generator emits into *identifier* positions
8+
* β€” component schema names, `$ref` targets, object property names and (when used for object names) tags. These become
9+
* class/trait/type/field/val names in the generated source, frequently by raw string concatenation (e.g. `${name.capitalize}Decoder`)
10+
* rather than backtick-quoting, so a name containing characters outside the OpenAPI-permitted identifier set could inject arbitrary Scala
11+
* code.
1212
*
1313
* We restrict them to a safe character set: the set OpenAPI permits for component names
14-
* (https://spec.openapis.org/oas/v3.1.0#components-object) plus `$` and `+`. None of these can form executable Scala
15-
* (`$` is a valid Scala identifier character; `+`/`.`/`-` at worst yield a non-compiling identifier, never a break-out),
16-
* while `$`/`+` occur in real-world property names (e.g. GitHub's `+1`, .NET's `$type`). Values that are emitted as
17-
* string literals instead (parameter names, URLs, descriptions, default values, discriminator values, enum values,
18-
* XML names) can legitimately contain any character and are escaped at their emission site rather than restricted
19-
* here. See GHSA-gpcc-36pq-8qxr.
14+
* (https://spec.openapis.org/oas/v3.1.0#components-object) plus `$` and `+`. None of these can form executable Scala (`$` is a valid Scala
15+
* identifier character; `+`/`.`/`-` at worst yield a non-compiling identifier, never a break-out), while `$`/`+` occur in real-world
16+
* property names (e.g. GitHub's `+1`, .NET's `$type`). Values that are emitted as string literals instead (parameter names, URLs,
17+
* descriptions, default values, discriminator values, enum values, XML names) can legitimately contain any character and are escaped at
18+
* their emission site rather than restricted here. See GHSA-gpcc-36pq-8qxr.
2019
*/
2120
object NameValidation {
2221

@@ -28,9 +27,9 @@ object NameValidation {
2827
s"Unsafe $kind '$name' in OpenAPI document: only characters [A-Za-z0-9._$$+-] are permitted (see GHSA-gpcc-36pq-8qxr)"
2928
)
3029

31-
/** Validate a single name that is about to be emitted into an identifier position (e.g. a `$ref` target spliced as
32-
* a type). Use this as a sink-side guard where a name may not have passed through document-level validation (path
33-
* schemas resolved from components, response headers, etc.).
30+
/** Validate a single name that is about to be emitted into an identifier position (e.g. a `$ref` target spliced as a type). Use this as a
31+
* sink-side guard where a name may not have passed through document-level validation (path schemas resolved from components, response
32+
* headers, etc.).
3433
*/
3534
def validateName(kind: String, name: String): Unit = check(kind, name)
3635

@@ -57,8 +56,8 @@ object NameValidation {
5756
case _ => Nil
5857
}
5958

60-
/** Validate every name in the document that reaches an identifier position. Throws IllegalArgumentException on the
61-
* first unsafe name. Idempotent and cheap, so it is safe to call from each public generator entry point.
59+
/** Validate every name in the document that reaches an identifier position. Throws IllegalArgumentException on the first unsafe name.
60+
* Idempotent and cheap, so it is safe to call from each public generator entry point.
6261
*/
6362
def validateDocumentNames(doc: OpenapiDocument, useHeadTagForObjectNames: Boolean): Unit = {
6463
val schemas = doc.components.toSeq.flatMap(_.schemas)

β€Žopenapi-codegen/core/src/main/scala/sttp/tapir/codegen/util/StringUtils.scalaβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ object JavaEscape {
1414
}
1515
}
1616

17-
/** An untrusted string as a complete, escaped Scala string literal (surrounding quotes included). Prefer this over
18-
* hand-writing `"\"" + escapeString(x) + "\""` so the escape and the quotes can't get out of sync.
17+
/** An untrusted string as a complete, escaped Scala string literal (surrounding quotes included). Prefer this over hand-writing
18+
* `"\"" + escapeString(x) + "\""` so the escape and the quotes can't get out of sync.
1919
*/
2020
def quote(str: String): String = "\"" + escapeString(str) + "\""
2121
}

0 commit comments

Comments
Β (0)