Skip to content

Commit 3029054

Browse files
authored
Add scalafmt plugin to scala-sttp client generator (#23377)
1 parent 03c13fb commit 3029054

9 files changed

Lines changed: 183 additions & 0 deletions

File tree

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ public void processOpts() {
172172
supportingFiles.add(new SupportingFile("jsonSupport.mustache", invokerFolder, "JsonSupport.scala"));
173173
supportingFiles.add(new SupportingFile("additionalTypeSerializers.mustache", invokerFolder, "AdditionalTypeSerializers.scala"));
174174
supportingFiles.add(new SupportingFile("project/build.properties.mustache", "project", "build.properties"));
175+
supportingFiles.add(new SupportingFile("project/plugins.mustache", "project", "plugins.sbt"));
176+
supportingFiles.add(new SupportingFile("scalafmt.mustache", "", ".scalafmt.conf"));
175177
supportingFiles.add(new SupportingFile("dateSerializers.mustache", invokerFolder, "DateSerializers.scala"));
176178
}
177179

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
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 = scala213
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/client/petstore/scala-sttp-circe/.openapi-generator/FILES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
.scalafmt.conf
12
README.md
23
build.sbt
34
project/build.properties
5+
project/plugins.sbt
46
src/main/scala/org/openapitools/client/api/FakeApi.scala
57
src/main/scala/org/openapitools/client/api/PetApi.scala
68
src/main/scala/org/openapitools/client/api/StoreApi.scala
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 = scala213
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+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.6")

samples/client/petstore/scala-sttp/.openapi-generator/FILES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
.scalafmt.conf
12
README.md
23
build.sbt
34
project/build.properties
5+
project/plugins.sbt
46
src/main/scala/org/openapitools/client/api/FakeApi.scala
57
src/main/scala/org/openapitools/client/api/PetApi.scala
68
src/main/scala/org/openapitools/client/api/StoreApi.scala
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 = scala213
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+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.6")

0 commit comments

Comments
 (0)