diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaSttp4JsoniterClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaSttp4JsoniterClientCodegen.java index c47a7a390680..b065c544f656 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaSttp4JsoniterClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaSttp4JsoniterClientCodegen.java @@ -187,6 +187,8 @@ public void processOpts() { supportingFiles.add(new SupportingFile("helpers.mustache", invokerFolder, "Helpers.scala")); supportingFiles.add(new SupportingFile("project/build.properties.mustache", "project", "build.properties")); + supportingFiles.add(new SupportingFile("project/plugins.mustache", "project", "plugins.sbt")); + supportingFiles.add(new SupportingFile("scalafmt.mustache", "", ".scalafmt.conf")); } @Override diff --git a/modules/openapi-generator/src/main/resources/scala-sttp4-jsoniter/project/plugins.mustache b/modules/openapi-generator/src/main/resources/scala-sttp4-jsoniter/project/plugins.mustache new file mode 100644 index 000000000000..eefc0dd27b23 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/scala-sttp4-jsoniter/project/plugins.mustache @@ -0,0 +1 @@ +addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.6") diff --git a/modules/openapi-generator/src/main/resources/scala-sttp4-jsoniter/scalafmt.mustache b/modules/openapi-generator/src/main/resources/scala-sttp4-jsoniter/scalafmt.mustache new file mode 100644 index 000000000000..e66032cc83c3 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/scala-sttp4-jsoniter/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/client/petstore/scala-sttp4-jsoniter/.openapi-generator/FILES b/samples/client/petstore/scala-sttp4-jsoniter/.openapi-generator/FILES index f0900cae0194..513420c86ce1 100644 --- a/samples/client/petstore/scala-sttp4-jsoniter/.openapi-generator/FILES +++ b/samples/client/petstore/scala-sttp4-jsoniter/.openapi-generator/FILES @@ -1,6 +1,8 @@ +.scalafmt.conf README.md build.sbt project/build.properties +project/plugins.sbt src/main/scala/org/openapitools/client/api/PetApi.scala src/main/scala/org/openapitools/client/api/StoreApi.scala src/main/scala/org/openapitools/client/api/UserApi.scala diff --git a/samples/client/petstore/scala-sttp4-jsoniter/.scalafmt.conf b/samples/client/petstore/scala-sttp4-jsoniter/.scalafmt.conf new file mode 100644 index 000000000000..e66032cc83c3 --- /dev/null +++ b/samples/client/petstore/scala-sttp4-jsoniter/.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/client/petstore/scala-sttp4-jsoniter/project/plugins.sbt b/samples/client/petstore/scala-sttp4-jsoniter/project/plugins.sbt new file mode 100644 index 000000000000..eefc0dd27b23 --- /dev/null +++ b/samples/client/petstore/scala-sttp4-jsoniter/project/plugins.sbt @@ -0,0 +1 @@ +addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.6") diff --git a/samples/server/others/kotlin-server/polymorphism-allof-and-discriminator/README.md b/samples/server/others/kotlin-server/polymorphism-allof-and-discriminator/README.md index d3a5056004b5..6a1eb18ec292 100644 --- a/samples/server/others/kotlin-server/polymorphism-allof-and-discriminator/README.md +++ b/samples/server/others/kotlin-server/polymorphism-allof-and-discriminator/README.md @@ -1,4 +1,4 @@ -# org.openapitools.server - Kotlin Server library for Polymorphism example with allOf and discriminator +# org.openapitools.server - Kotlin Server library for Basic polymorphism example with discriminator No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) diff --git a/samples/server/others/kotlin-server/polymorphism-allof-and-discriminator/src/main/kotlin/org/openapitools/server/models/Cat.kt b/samples/server/others/kotlin-server/polymorphism-allof-and-discriminator/src/main/kotlin/org/openapitools/server/models/Cat.kt index e9e835517bae..99ab4e0f3f50 100644 --- a/samples/server/others/kotlin-server/polymorphism-allof-and-discriminator/src/main/kotlin/org/openapitools/server/models/Cat.kt +++ b/samples/server/others/kotlin-server/polymorphism-allof-and-discriminator/src/main/kotlin/org/openapitools/server/models/Cat.kt @@ -1,5 +1,5 @@ /** - * Polymorphism example with allOf and discriminator + * Basic polymorphism example with discriminator * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * The version of the OpenAPI document: 1.0 @@ -11,11 +11,11 @@ */ package org.openapitools.server.models -import org.openapitools.server.models.Pet /** - * A representation of a cat + * A pet cat * @param huntingSkill The measured skill for hunting + * @param petType */ data class Cat( /* The measured skill for hunting */ @@ -23,12 +23,10 @@ data class Cat( @field:com.fasterxml.jackson.annotation.JsonProperty("huntingSkill") val huntingSkill: Cat.HuntingSkill, - @field:com.fasterxml.jackson.annotation.JsonProperty("name") - override val name: kotlin.String, - @field:com.fasterxml.jackson.annotation.JsonProperty("petType") - override val petType: kotlin.String -) : Pet(name = name, petType = petType) + override val petType: kotlin.String = "cat", + +) : Pet(petType = petType) { /** * The measured skill for hunting diff --git a/samples/server/others/kotlin-server/polymorphism-allof-and-discriminator/src/main/kotlin/org/openapitools/server/models/Dog.kt b/samples/server/others/kotlin-server/polymorphism-allof-and-discriminator/src/main/kotlin/org/openapitools/server/models/Dog.kt index 4066cb7a51f8..9f3cbe860d93 100644 --- a/samples/server/others/kotlin-server/polymorphism-allof-and-discriminator/src/main/kotlin/org/openapitools/server/models/Dog.kt +++ b/samples/server/others/kotlin-server/polymorphism-allof-and-discriminator/src/main/kotlin/org/openapitools/server/models/Dog.kt @@ -1,5 +1,5 @@ /** - * Polymorphism example with allOf and discriminator + * Basic polymorphism example with discriminator * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * The version of the OpenAPI document: 1.0 @@ -11,24 +11,19 @@ */ package org.openapitools.server.models -import org.openapitools.server.models.Pet /** - * A representation of a dog + * A pet dog + * @param petType * @param packSize the size of the pack the dog is from */ data class Dog( + + @field:com.fasterxml.jackson.annotation.JsonProperty("petType") + override val petType: kotlin.String = "dog", /* the size of the pack the dog is from */ @field:com.fasterxml.jackson.annotation.JsonProperty("packSize") - val packSize: kotlin.Int = 0, - - @field:com.fasterxml.jackson.annotation.JsonProperty("name") - override val name: kotlin.String, - - @field:com.fasterxml.jackson.annotation.JsonProperty("petType") - override val petType: kotlin.String -) : Pet(name = name, petType = petType) -{ -} + val packSize: kotlin.Int = 0 +) : Pet(petType = petType) diff --git a/samples/server/others/kotlin-server/polymorphism-allof-and-discriminator/src/main/kotlin/org/openapitools/server/models/Pet.kt b/samples/server/others/kotlin-server/polymorphism-allof-and-discriminator/src/main/kotlin/org/openapitools/server/models/Pet.kt index 5812ac1944eb..1311dc6d56ff 100644 --- a/samples/server/others/kotlin-server/polymorphism-allof-and-discriminator/src/main/kotlin/org/openapitools/server/models/Pet.kt +++ b/samples/server/others/kotlin-server/polymorphism-allof-and-discriminator/src/main/kotlin/org/openapitools/server/models/Pet.kt @@ -1,5 +1,5 @@ /** - * Polymorphism example with allOf and discriminator + * Basic polymorphism example with discriminator * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * The version of the OpenAPI document: 1.0 @@ -11,23 +11,20 @@ */ package org.openapitools.server.models +import org.openapitools.server.models.Cat +import org.openapitools.server.models.Dog /** * - * @param name * @param petType */ @com.fasterxml.jackson.annotation.JsonTypeInfo(use = com.fasterxml.jackson.annotation.JsonTypeInfo.Id.NAME, include = com.fasterxml.jackson.annotation.JsonTypeInfo.As.PROPERTY, property = "petType", visible = true) @com.fasterxml.jackson.annotation.JsonSubTypes( - com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = Cat::class, name = "Cat"), - com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = Dog::class, name = "Dog") + com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = Cat::class, name = "cat"), + com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = Dog::class, name = "dog") ) sealed class Pet( - @field:com.fasterxml.jackson.annotation.JsonProperty("name") - open val name: kotlin.String -, - @field:com.fasterxml.jackson.annotation.JsonProperty("petType") open val petType: kotlin.String