diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaHttp4sServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaHttp4sServerCodegen.java index fe8098feb1ce..776a30dfb77a 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaHttp4sServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaHttp4sServerCodegen.java @@ -327,6 +327,8 @@ public void processOpts() { if (!additionalProperties.containsKey(EXCLUDE_SBT) && !Boolean.parseBoolean((String) additionalProperties.get(EXCLUDE_SBT))) { supportingFiles.add(new SupportingFile("build.sbt", "", "build.sbt")); supportingFiles.add(new SupportingFile("build.properties", "project", "build.properties")); + supportingFiles.add(new SupportingFile("project/plugins.mustache", "project", "plugins.sbt")); + supportingFiles.add(new SupportingFile("scalafmt.mustache", "", ".scalafmt.conf")); } } diff --git a/modules/openapi-generator/src/main/resources/scala-http4s-server/project/plugins.mustache b/modules/openapi-generator/src/main/resources/scala-http4s-server/project/plugins.mustache new file mode 100644 index 000000000000..eefc0dd27b23 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/scala-http4s-server/project/plugins.mustache @@ -0,0 +1 @@ +addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.6") diff --git a/modules/openapi-generator/src/main/resources/scala-http4s-server/scalafmt.mustache b/modules/openapi-generator/src/main/resources/scala-http4s-server/scalafmt.mustache new file mode 100644 index 000000000000..e66032cc83c3 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/scala-http4s-server/scalafmt.mustache @@ -0,0 +1,58 @@ +version=3.10.6 +runner.dialect = scala213 +project { + git = false + excludeFilters = [ + scalafmt-benchmarks/src/resources, + sbt-test + bin/issue + ] + layout = StandardConvention +} +align { + preset = none + stripMargin = true +} +binPack { + importSelectors = fold +} +newlines { + avoidForSimpleOverflow = all + ignoreInSyntax = false + source = fold +} +rewrite { + rules = [ + AvoidInfix, + Imports, + RedundantBraces, + RedundantParens, + SortModifiers, + ] + imports { + selectors = fold + removeRedundantSelectors = true + sort = ascii + groups = [ + ["org\\.scalafmt\\..*"], + ["scala\\.meta\\..*", "org\\.scalameta\\..*"], + ["sbt\\..*"], + ["java.?\\..*"], + ["scala\\..*"], + ["org\\..*"], + ["com\\..*"], + ] + } + redundantBraces { + preset = all + oneStatApply { + parensMaxSpan = 300 + bracesMinSpan = 300 + } + } + redundantParens { + preset = all + } + sortModifiers.preset = styleGuide + trailingCommas.style = "always" +} diff --git a/samples/server/petstore/scala-http4s-server/.openapi-generator/FILES b/samples/server/petstore/scala-http4s-server/.openapi-generator/FILES index 2f902263e957..6c54aebaa7cb 100644 --- a/samples/server/petstore/scala-http4s-server/.openapi-generator/FILES +++ b/samples/server/petstore/scala-http4s-server/.openapi-generator/FILES @@ -1,5 +1,7 @@ +.scalafmt.conf build.sbt project/build.properties +project/plugins.sbt src/main/scala/org/openapitools/api.scala src/main/scala/org/openapitools/apis/FakeApi.scala src/main/scala/org/openapitools/apis/PetApi.scala diff --git a/samples/server/petstore/scala-http4s-server/.scalafmt.conf b/samples/server/petstore/scala-http4s-server/.scalafmt.conf new file mode 100644 index 000000000000..e66032cc83c3 --- /dev/null +++ b/samples/server/petstore/scala-http4s-server/.scalafmt.conf @@ -0,0 +1,58 @@ +version=3.10.6 +runner.dialect = scala213 +project { + git = false + excludeFilters = [ + scalafmt-benchmarks/src/resources, + sbt-test + bin/issue + ] + layout = StandardConvention +} +align { + preset = none + stripMargin = true +} +binPack { + importSelectors = fold +} +newlines { + avoidForSimpleOverflow = all + ignoreInSyntax = false + source = fold +} +rewrite { + rules = [ + AvoidInfix, + Imports, + RedundantBraces, + RedundantParens, + SortModifiers, + ] + imports { + selectors = fold + removeRedundantSelectors = true + sort = ascii + groups = [ + ["org\\.scalafmt\\..*"], + ["scala\\.meta\\..*", "org\\.scalameta\\..*"], + ["sbt\\..*"], + ["java.?\\..*"], + ["scala\\..*"], + ["org\\..*"], + ["com\\..*"], + ] + } + redundantBraces { + preset = all + oneStatApply { + parensMaxSpan = 300 + bracesMinSpan = 300 + } + } + redundantParens { + preset = all + } + sortModifiers.preset = styleGuide + trailingCommas.style = "always" +} diff --git a/samples/server/petstore/scala-http4s-server/project/plugins.sbt b/samples/server/petstore/scala-http4s-server/project/plugins.sbt new file mode 100644 index 000000000000..eefc0dd27b23 --- /dev/null +++ b/samples/server/petstore/scala-http4s-server/project/plugins.sbt @@ -0,0 +1 @@ +addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.6")