Skip to content

Commit 682e45c

Browse files
authored
Add scalafmt plugin to scala-finch generator (#23459)
1 parent dd6ea59 commit 682e45c

10 files changed

Lines changed: 125 additions & 2 deletions

File tree

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaFinchServerCodegen.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ public ScalaFinchServerCodegen() {
156156

157157
supportingFiles.add(new SupportingFile("project/build.properties", "project", "build.properties"));
158158
supportingFiles.add(new SupportingFile("project/plugins.sbt", "project", "plugins.sbt"));
159+
supportingFiles.add(new SupportingFile("scalafmt.mustache", "", ".scalafmt.conf"));
159160
supportingFiles.add(new SupportingFile("sbt", "", "sbt"));
160161

161162
supportingFiles.add(new SupportingFile("endpoint.mustache", sourceFolder, "endpoint.scala"));

modules/openapi-generator/src/main/resources/scala-finch/project/plugins.sbt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.3")
55
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.5.3")
66

77
addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.6.0")
8+
9+
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.6")
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
version=3.10.6
2+
runner.dialect = scala212
3+
project {
4+
git = false
5+
excludeFilters = [
6+
scalafmt-benchmarks/src/resources,
7+
sbt-test
8+
bin/issue
9+
]
10+
layout = StandardConvention
11+
}
12+
align {
13+
preset = none
14+
stripMargin = true
15+
}
16+
binPack {
17+
importSelectors = fold
18+
}
19+
newlines {
20+
avoidForSimpleOverflow = all
21+
ignoreInSyntax = false
22+
source = fold
23+
}
24+
rewrite {
25+
rules = [
26+
AvoidInfix,
27+
Imports,
28+
RedundantBraces,
29+
RedundantParens,
30+
SortModifiers,
31+
]
32+
imports {
33+
selectors = fold
34+
removeRedundantSelectors = true
35+
sort = ascii
36+
groups = [
37+
["org\\.scalafmt\\..*"],
38+
["scala\\.meta\\..*", "org\\.scalameta\\..*"],
39+
["sbt\\..*"],
40+
["java.?\\..*"],
41+
["scala\\..*"],
42+
["org\\..*"],
43+
["com\\..*"],
44+
]
45+
}
46+
redundantBraces {
47+
preset = all
48+
oneStatApply {
49+
parensMaxSpan = 300
50+
bracesMinSpan = 300
51+
}
52+
}
53+
redundantParens {
54+
preset = all
55+
}
56+
sortModifiers.preset = styleGuide
57+
trailingCommas.style = "always"
58+
}

samples/server/petstore/scala-finch/.openapi-generator/FILES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.scalafmt.conf
12
README.md
23
build.sbt
34
project/build.properties
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5.1.0-SNAPSHOT
1+
7.22.0-SNAPSHOT
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
version=3.10.6
2+
runner.dialect = scala212
3+
project {
4+
git = false
5+
excludeFilters = [
6+
scalafmt-benchmarks/src/resources,
7+
sbt-test
8+
bin/issue
9+
]
10+
layout = StandardConvention
11+
}
12+
align {
13+
preset = none
14+
stripMargin = true
15+
}
16+
binPack {
17+
importSelectors = fold
18+
}
19+
newlines {
20+
avoidForSimpleOverflow = all
21+
ignoreInSyntax = false
22+
source = fold
23+
}
24+
rewrite {
25+
rules = [
26+
AvoidInfix,
27+
Imports,
28+
RedundantBraces,
29+
RedundantParens,
30+
SortModifiers,
31+
]
32+
imports {
33+
selectors = fold
34+
removeRedundantSelectors = true
35+
sort = ascii
36+
groups = [
37+
["org\\.scalafmt\\..*"],
38+
["scala\\.meta\\..*", "org\\.scalameta\\..*"],
39+
["sbt\\..*"],
40+
["java.?\\..*"],
41+
["scala\\..*"],
42+
["org\\..*"],
43+
["com\\..*"],
44+
]
45+
}
46+
redundantBraces {
47+
preset = all
48+
oneStatApply {
49+
parensMaxSpan = 300
50+
bracesMinSpan = 300
51+
}
52+
}
53+
redundantParens {
54+
preset = all
55+
}
56+
sortModifiers.preset = styleGuide
57+
trailingCommas.style = "always"
58+
}

samples/server/petstore/scala-finch/project/plugins.sbt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.3")
55
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.5.3")
66

77
addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.6.0")
8+
9+
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.6")

samples/server/petstore/scala-finch/src/main/scala/errors.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,3 @@ case class MissingIdentifier(message: String) extends CommonError(message)
2424
* @param message An error message
2525
*/
2626
case class RecordNotFound(message: String) extends CommonError(message)
27-

samples/server/petstore/scala-finch/src/main/scala/org/openapitools/apis/PetApi.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import org.openapitools.models._
66
import org.openapitools.models.ApiResponse
77
import java.io.File
88
import org.openapitools.models.Pet
9+
import scala.collection.immutable.Seq
910
import io.finch.circe._
1011
import io.circe.generic.semiauto._
1112
import com.twitter.concurrent.AsyncStream

samples/server/petstore/scala-finch/src/main/scala/org/openapitools/apis/UserApi.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import org.openapitools._
55
import org.openapitools.models._
66
import scala.collection.immutable.Seq
77
import org.openapitools.models.User
8+
import java.time.ZonedDateTime
89
import io.finch.circe._
910
import io.circe.generic.semiauto._
1011
import com.twitter.concurrent.AsyncStream

0 commit comments

Comments
 (0)