diff --git a/bin/configs/swift5-vapor.yaml b/bin/configs/swift5-vapor.yaml
new file mode 100644
index 000000000000..5f1d2067969f
--- /dev/null
+++ b/bin/configs/swift5-vapor.yaml
@@ -0,0 +1,12 @@
+generatorName: swift5
+outputDir: samples/client/petstore/swift5/vaporLibrary
+library: vapor
+inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
+templateDir: modules/openapi-generator/src/main/resources/swift5
+generateAliasAsModel: true
+additionalProperties:
+ projectName: PetstoreClient
+ useSPMFileStructure: true
+ useClasses: true
+ useBacktickEscapes: true
+ mapFileBinaryToData: true
diff --git a/docs/generators.md b/docs/generators.md
index 2531acc9e670..c71da0663ed5 100644
--- a/docs/generators.md
+++ b/docs/generators.md
@@ -62,7 +62,7 @@ The following generators are available:
* [scala-sttp (beta)](generators/scala-sttp.md)
* [scalaz](generators/scalaz.md)
* [swift4-deprecated (deprecated)](generators/swift4-deprecated.md)
-* [swift5 (beta)](generators/swift5.md)
+* [swift5](generators/swift5.md)
* [typescript (experimental)](generators/typescript.md)
* [typescript-angular](generators/typescript-angular.md)
* [typescript-angularjs-deprecated (deprecated)](generators/typescript-angularjs-deprecated.md)
diff --git a/docs/generators/javascript-flowtyped.md b/docs/generators/javascript-flowtyped.md
index eca0bf2e0808..51ac05927d3e 100644
--- a/docs/generators/javascript-flowtyped.md
+++ b/docs/generators/javascript-flowtyped.md
@@ -18,6 +18,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|npmRepository|Use this property to set an url your private npmRepo in the package.json| |null|
|npmVersion|The version of your npm package. If not provided, using the version from the OpenAPI specification file.| |1.0.0|
|nullSafeAdditionalProps|Set to make additional properties types declare that their indexer may return undefined| |false|
+|paramNaming|Naming convention for parameters: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase|
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|snapshot|When setting this property to true, the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false|
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
diff --git a/docs/generators/swift5.md b/docs/generators/swift5.md
index 51dc7529358f..96cfe8424c08 100644
--- a/docs/generators/swift5.md
+++ b/docs/generators/swift5.md
@@ -16,7 +16,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C#have this enabled by default).|
**true** The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document. **false** The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing. |true|
|lenientTypeCast|Accept and cast values for simple types (string->bool, string->int, int->string)| |false|
-|library|Library template (sub-template) to use|**urlsession** [DEFAULT] HTTP client: URLSession **alamofire** HTTP client: Alamofire |urlsession|
+|library|Library template (sub-template) to use|**urlsession** [DEFAULT] HTTP client: URLSession **alamofire** HTTP client: Alamofire **vapor** HTTP client: Vapor |urlsession|
|mapFileBinaryToData|[WARNING] This option will be removed and enabled by default in the future once we've enhanced the code to work with `Data` in all the different situations. Map File and Binary to Data (default: false)| |false|
|nonPublicApi|Generates code with reduced access modifiers; allows embedding elsewhere without exposing non-public API calls to consumers.(default: false)| |null|
|objcCompatible|Add additional properties and methods for Objective-C compatibility (default: false)| |null|
diff --git a/docs/generators/typescript-angular.md b/docs/generators/typescript-angular.md
index 6916e3f662cc..67341026ceb5 100644
--- a/docs/generators/typescript-angular.md
+++ b/docs/generators/typescript-angular.md
@@ -24,6 +24,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|npmRepository|Use this property to set an url your private npmRepo in the package.json| |null|
|npmVersion|The version of your npm package. If not provided, using the version from the OpenAPI specification file.| |1.0.0|
|nullSafeAdditionalProps|Set to make additional properties types declare that their indexer may return undefined| |false|
+|paramNaming|Naming convention for parameters: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase|
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|providedIn|Use this property to provide Injectables in wanted level (it is only valid in angular version greater or equal to 9.0.0).|**root** The application-level injector in most apps. **none** No providedIn (same as providedInRoot=false) **any** Provides a unique instance in each lazy loaded module while all eagerly loaded modules share one instance. **platform** A special singleton platform injector shared by all applications on the page. |root|
|providedInRoot|Use this property to provide Injectables in root (it is only valid in angular version greater or equal to 6.0.0). IMPORTANT: Deprecated for angular version greater or equal to 9.0.0, use **providedIn** instead.| |false|
diff --git a/docs/generators/typescript-angularjs-deprecated.md b/docs/generators/typescript-angularjs-deprecated.md
index 889c9fb3d2d9..9363a6958da7 100644
--- a/docs/generators/typescript-angularjs-deprecated.md
+++ b/docs/generators/typescript-angularjs-deprecated.md
@@ -15,6 +15,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C#have this enabled by default).|**true** The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document. **false** The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing. |true|
|modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name. Only change it if you provide your own run-time code for (de-)serialization of models| |original|
|nullSafeAdditionalProps|Set to make additional properties types declare that their indexer may return undefined| |false|
+|paramNaming|Naming convention for parameters: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase|
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
diff --git a/docs/generators/typescript-aurelia.md b/docs/generators/typescript-aurelia.md
index a1f568cfb65f..aaad28dd75bc 100644
--- a/docs/generators/typescript-aurelia.md
+++ b/docs/generators/typescript-aurelia.md
@@ -17,6 +17,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|npmName|The name under which you want to publish generated npm package. Required to generate a full package| |null|
|npmVersion|The version of your npm package. If not provided, using the version from the OpenAPI specification file.| |1.0.0|
|nullSafeAdditionalProps|Set to make additional properties types declare that their indexer may return undefined| |false|
+|paramNaming|Naming convention for parameters: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase|
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|snapshot|When setting this property to true, the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false|
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
diff --git a/docs/generators/typescript-axios.md b/docs/generators/typescript-axios.md
index 5bddee541892..3e9f31aed5f0 100644
--- a/docs/generators/typescript-axios.md
+++ b/docs/generators/typescript-axios.md
@@ -18,6 +18,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|npmRepository|Use this property to set an url of your private npmRepo in the package.json| |null|
|npmVersion|The version of your npm package. If not provided, using the version from the OpenAPI specification file.| |1.0.0|
|nullSafeAdditionalProps|Set to make additional properties types declare that their indexer may return undefined| |false|
+|paramNaming|Naming convention for parameters: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase|
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|snapshot|When setting this property to true, the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false|
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
diff --git a/docs/generators/typescript-fetch.md b/docs/generators/typescript-fetch.md
index 2acbe8c77413..d197da526a5b 100644
--- a/docs/generators/typescript-fetch.md
+++ b/docs/generators/typescript-fetch.md
@@ -18,6 +18,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|npmRepository|Use this property to set an url your private npmRepo in the package.json| |null|
|npmVersion|The version of your npm package. If not provided, using the version from the OpenAPI specification file.| |1.0.0|
|nullSafeAdditionalProps|Set to make additional properties types declare that their indexer may return undefined| |false|
+|paramNaming|Naming convention for parameters: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase|
|prefixParameterInterfaces|Setting this property to true will generate parameter interface declarations prefixed with API class name to avoid name conflicts.| |false|
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|snapshot|When setting this property to true, the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false|
diff --git a/docs/generators/typescript-inversify.md b/docs/generators/typescript-inversify.md
index 41df5d2b2b7d..38077cb2b40a 100644
--- a/docs/generators/typescript-inversify.md
+++ b/docs/generators/typescript-inversify.md
@@ -18,6 +18,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|npmRepository|Use this property to set an url your private npmRepo in the package.json| |null|
|npmVersion|The version of your npm package. If not provided, using the version from the OpenAPI specification file.| |1.0.0|
|nullSafeAdditionalProps|Set to make additional properties types declare that their indexer may return undefined| |false|
+|paramNaming|Naming convention for parameters: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase|
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|snapshot|When setting this property to true, the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false|
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
diff --git a/docs/generators/typescript-jquery.md b/docs/generators/typescript-jquery.md
index 33713bf6f853..fcff7abe194b 100644
--- a/docs/generators/typescript-jquery.md
+++ b/docs/generators/typescript-jquery.md
@@ -19,6 +19,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|npmRepository|Use this property to set an url your private npmRepo in the package.json| |null|
|npmVersion|The version of your npm package. If not provided, using the version from the OpenAPI specification file.| |1.0.0|
|nullSafeAdditionalProps|Set to make additional properties types declare that their indexer may return undefined| |false|
+|paramNaming|Naming convention for parameters: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase|
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|snapshot|When setting this property to true, the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false|
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
diff --git a/docs/generators/typescript-nestjs.md b/docs/generators/typescript-nestjs.md
index 0697f2266f67..50e9acb16754 100644
--- a/docs/generators/typescript-nestjs.md
+++ b/docs/generators/typescript-nestjs.md
@@ -22,6 +22,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|npmRepository|Use this property to set an url your private npmRepo in the package.json| |null|
|npmVersion|The version of your npm package. If not provided, using the version from the OpenAPI specification file.| |1.0.0|
|nullSafeAdditionalProps|Set to make additional properties types declare that their indexer may return undefined| |false|
+|paramNaming|Naming convention for parameters: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase|
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|serviceFileSuffix|The suffix of the file of the generated service (service<suffix>.ts).| |.service|
|serviceSuffix|The suffix of the generated service.| |Service|
diff --git a/docs/generators/typescript-node.md b/docs/generators/typescript-node.md
index 8c755639588a..388dfd551bde 100644
--- a/docs/generators/typescript-node.md
+++ b/docs/generators/typescript-node.md
@@ -18,6 +18,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|npmRepository|Use this property to set an url your private npmRepo in the package.json| |null|
|npmVersion|The version of your npm package. If not provided, using the version from the OpenAPI specification file.| |1.0.0|
|nullSafeAdditionalProps|Set to make additional properties types declare that their indexer may return undefined| |false|
+|paramNaming|Naming convention for parameters: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase|
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|snapshot|When setting this property to true, the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false|
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
diff --git a/docs/generators/typescript-redux-query.md b/docs/generators/typescript-redux-query.md
index f35e028ff4b9..dd79fa1a433d 100644
--- a/docs/generators/typescript-redux-query.md
+++ b/docs/generators/typescript-redux-query.md
@@ -18,6 +18,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|npmRepository|Use this property to set an url your private npmRepo in the package.json| |null|
|npmVersion|The version of your npm package. If not provided, using the version from the OpenAPI specification file.| |1.0.0|
|nullSafeAdditionalProps|Set to make additional properties types declare that their indexer may return undefined| |false|
+|paramNaming|Naming convention for parameters: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase|
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|snapshot|When setting this property to true, the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false|
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
diff --git a/docs/generators/typescript-rxjs.md b/docs/generators/typescript-rxjs.md
index 05909b89bd27..509991799854 100644
--- a/docs/generators/typescript-rxjs.md
+++ b/docs/generators/typescript-rxjs.md
@@ -18,6 +18,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|npmRepository|Use this property to set an url your private npmRepo in the package.json| |null|
|npmVersion|The version of your npm package. If not provided, using the version from the OpenAPI specification file.| |1.0.0|
|nullSafeAdditionalProps|Set to make additional properties types declare that their indexer may return undefined| |false|
+|paramNaming|Naming convention for parameters: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase|
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|snapshot|When setting this property to true, the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false|
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
diff --git a/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/tasks/ValidateTask.kt b/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/tasks/ValidateTask.kt
index 3d0cbab2b064..6f3038e4e29c 100644
--- a/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/tasks/ValidateTask.kt
+++ b/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/tasks/ValidateTask.kt
@@ -56,11 +56,11 @@ import org.openapitools.codegen.validations.oas.RuleConfiguration
open class ValidateTask : DefaultTask() {
@get:InputFile
@PathSensitive(PathSensitivity.RELATIVE)
- var inputSpec = project.objects.property()
+ val inputSpec = project.objects.property()
@Optional
@Input
- var recommend = project.objects.property()
+ val recommend = project.objects.property()
@Suppress("unused")
@get:Internal
@@ -128,4 +128,4 @@ open class ValidateTask : DefaultTask() {
out.println("Spec is valid.")
}
}
-}
\ No newline at end of file
+}
diff --git a/modules/openapi-generator-gradle-plugin/src/test/kotlin/ValidateTaskDslTest.kt b/modules/openapi-generator-gradle-plugin/src/test/kotlin/ValidateTaskDslTest.kt
index 2b06e853192e..94ae68ab3af8 100644
--- a/modules/openapi-generator-gradle-plugin/src/test/kotlin/ValidateTaskDslTest.kt
+++ b/modules/openapi-generator-gradle-plugin/src/test/kotlin/ValidateTaskDslTest.kt
@@ -3,6 +3,8 @@ package org.openapitools.generator.gradle.plugin
import org.gradle.testkit.runner.GradleRunner
import org.gradle.testkit.runner.TaskOutcome.FAILED
import org.gradle.testkit.runner.TaskOutcome.SUCCESS
+import org.gradle.util.GradleVersion
+import org.testng.annotations.DataProvider
import org.testng.annotations.Test
import java.io.File
import kotlin.test.assertEquals
@@ -11,8 +13,25 @@ import kotlin.test.assertTrue
class ValidateTaskDslTest : TestBase() {
override var temp: File = createTempDir(javaClass.simpleName)
- @Test
- fun `openApiValidate should fail on non-file spec`() {
+ @DataProvider(name = "gradle_version_provider")
+ fun gradleVersionProvider(): Array> = arrayOf(
+ arrayOf(null), // uses the version of Gradle used to build the plugin itself
+ arrayOf("5.6.4"),
+ arrayOf("6.9"),
+ arrayOf("7.0"))
+
+ private fun getGradleRunner(gradleVersion: String?): GradleRunner {
+ val gradleRunner = GradleRunner.create()
+ return if (gradleVersion.isNullOrBlank()) {
+ //Use the current version of Gradle
+ gradleRunner
+ } else {
+ gradleRunner.withGradleVersion(gradleVersion)
+ }
+ }
+
+ @Test(dataProvider = "gradle_version_provider")
+ fun `openApiValidate should fail on non-file spec`(gradleVersion: String?) {
// Arrange
withProject("""
| plugins {
@@ -25,20 +44,28 @@ class ValidateTaskDslTest : TestBase() {
""".trimMargin())
// Act
- val result = GradleRunner.create()
+ val result = getGradleRunner(gradleVersion)
.withProjectDir(temp)
.withArguments("openApiValidate")
.withPluginClasspath()
.buildAndFail()
// Assert
- assertTrue(result.output.contains("some_location' specified for property 'inputSpec' does not exist"), "Unexpected/no message presented to the user for a spec pointing to an invalid URI.")
+ val gradleActualVersion = gradleVersion ?: GradleVersion.current().version
+ val gradleVersionParts = gradleActualVersion.split(".")
+ val isBeforeGradle7 = (gradleVersionParts.isEmpty() || gradleVersionParts[0].toInt() < 7)
+ val expectedMessage = if (isBeforeGradle7) {
+ "some_location' specified for property 'inputSpec' does not exist"
+ } else {
+ "An input file was expected to be present but it doesn't exist."
+ }
+ assertTrue(result.output.contains(expectedMessage), "Unexpected/no message presented to the user for a spec pointing to an invalid URI.")
assertEquals(FAILED, result.task(":openApiValidate")?.outcome,
"Expected a failed run, but found ${result.task(":openApiValidate")?.outcome}")
}
- @Test
- fun `openApiValidate should succeed on valid spec`() {
+ @Test(dataProvider = "gradle_version_provider")
+ fun `openApiValidate should succeed on valid spec`(gradleVersion: String?) {
// Arrange
val projectFiles = mapOf(
"spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0.yaml")
@@ -55,7 +82,7 @@ class ValidateTaskDslTest : TestBase() {
""".trimMargin(), projectFiles)
// Act
- val result = GradleRunner.create()
+ val result = getGradleRunner(gradleVersion)
.withProjectDir(temp)
.withArguments("openApiValidate")
.withPluginClasspath()
@@ -67,8 +94,8 @@ class ValidateTaskDslTest : TestBase() {
"Expected a successful run, but found ${result.task(":openApiValidate")?.outcome}")
}
- @Test
- fun `openApiValidate should fail on invalid spec`() {
+ @Test(dataProvider = "gradle_version_provider")
+ fun `openApiValidate should fail on invalid spec`(gradleVersion: String?) {
// Arrange
val projectFiles = mapOf(
"spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0-invalid.yaml")
@@ -84,7 +111,7 @@ class ValidateTaskDslTest : TestBase() {
""".trimMargin(), projectFiles)
// Act
- val result = GradleRunner.create()
+ val result = getGradleRunner(gradleVersion)
.withProjectDir(temp)
.withArguments("openApiValidate")
.withPluginClasspath()
@@ -96,4 +123,4 @@ class ValidateTaskDslTest : TestBase() {
"Expected a failed run, but found ${result.task(":openApiValidate")?.outcome}")
}
-}
\ No newline at end of file
+}
diff --git a/modules/openapi-generator-maven-plugin/examples/kotlin.xml b/modules/openapi-generator-maven-plugin/examples/kotlin.xml
index d6ddeeb890db..361cc59c9968 100644
--- a/modules/openapi-generator-maven-plugin/examples/kotlin.xml
+++ b/modules/openapi-generator-maven-plugin/examples/kotlin.xml
@@ -219,6 +219,13 @@
okhttp
4.2.2
+
+
+
+ org.jetbrains.kotlin
+ kotlin-stdlib
+ ${kotlin.version}
+
@@ -229,7 +236,7 @@
2.7
1.0.0
4.8.1
- 1.3.50
+ 1.5.10
1.8
1.8.0
2.2
diff --git a/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/service/Generator.java b/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/service/Generator.java
index be21b970d7a3..7cf052e30836 100644
--- a/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/service/Generator.java
+++ b/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/service/Generator.java
@@ -153,7 +153,7 @@ private static String generate(String language, GeneratorInput opts, Type type)
List files = new DefaultGenerator().opts(clientOptInput).generate();
if (files.size() > 0) {
List filesToAdd = new ArrayList<>();
- LOGGER.debug("adding to " + outputFolder);
+ LOGGER.debug("adding to {}", outputFolder);
filesToAdd.add(new File(outputFolder));
ZipUtil zip = new ZipUtil();
zip.compressFiles(filesToAdd, outputFilename);
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConstants.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConstants.java
index 631ff47eedbc..b8caef27e9f9 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConstants.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConstants.java
@@ -205,12 +205,17 @@ public class CodegenConstants {
public static final String MODEL_PROPERTY_NAMING = "modelPropertyNaming";
public static final String MODEL_PROPERTY_NAMING_DESC = "Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name";
+ public static final String PARAM_NAMING = "paramNaming";
+ public static final String PARAM_NAMING_DESC = "Naming convention for parameters: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name";
+
public static final String DOTNET_FRAMEWORK = "targetFramework";
public static final String DOTNET_FRAMEWORK_DESC = "The target .NET framework version. To target multiple frameworks, use `;` as the separator, e.g. `netstandard2.1;netcoreapp3.0`";
public static final String TEMPLATING_ENGINE = "templatingEngine";
public static final String TEMPLATING_ENGINE_DESC = "The templating engine plugin to use: \"mustache\" (default) or \"handlebars\" (beta)";
+ public static enum PARAM_NAMING_TYPE {camelCase, PascalCase, snake_case, original}
+
public static enum MODEL_PROPERTY_NAMING_TYPE {camelCase, PascalCase, snake_case, original}
public static enum ENUM_PROPERTY_NAMING_TYPE {camelCase, PascalCase, snake_case, original, UPPERCASE}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
index c26a4df1362e..f6972cb575fc 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
@@ -2711,14 +2711,18 @@ private CodegenProperty discriminatorFound(String composedSchemaName, Schema sc,
String modelName = ModelUtils.getSimpleRef(oneOf.get$ref());
CodegenProperty thisCp = discriminatorFound(composedSchemaName, oneOf, discPropName, openAPI);
if (thisCp == null) {
- LOGGER.warn("'" + composedSchemaName + "' defines discriminator '" + discPropName + "', but the referenced OneOf schema '" + modelName + "' is missing " + discPropName);
+ LOGGER.warn(
+ "'{}' defines discriminator '{}', but the referenced OneOf schema '{}' is missing {}",
+ composedSchemaName, discPropName, modelName, discPropName);
}
if (cp.dataType == null) {
cp = thisCp;
continue;
}
if (cp != thisCp) {
- LOGGER.warn("'" + composedSchemaName + "' defines discriminator '" + discPropName + "', but the OneOf schema '" + modelName + "' has a different " + discPropName + " definition than the prior OneOf schema's. Make sure the " + discPropName + " type and required values are the same");
+ LOGGER.warn(
+ "'{}' defines discriminator '{}', but the OneOf schema '{}' has a different {} definition than the prior OneOf schema's. Make sure the {} type and required values are the same",
+ composedSchemaName, discPropName, modelName, discPropName, discPropName);
}
}
return cp;
@@ -2730,14 +2734,18 @@ private CodegenProperty discriminatorFound(String composedSchemaName, Schema sc,
String modelName = ModelUtils.getSimpleRef(anyOf.get$ref());
CodegenProperty thisCp = discriminatorFound(composedSchemaName, anyOf, discPropName, openAPI);
if (thisCp == null) {
- LOGGER.warn("'" + composedSchemaName + "' defines discriminator '" + discPropName + "', but the referenced AnyOf schema '" + modelName + "' is missing " + discPropName);
+ LOGGER.warn(
+ "'{}' defines discriminator '{}', but the referenced AnyOf schema '{}' is missing {}",
+ composedSchemaName, discPropName, modelName, discPropName);
}
if (cp.dataType == null) {
cp = thisCp;
continue;
}
if (cp != thisCp) {
- LOGGER.warn("'" + composedSchemaName + "' defines discriminator '" + discPropName + "', but the AnyOf schema '" + modelName + "' has a different " + discPropName + " definition than the prior AnyOf schema's. Make sure the " + discPropName + " type and required values are the same");
+ LOGGER.warn(
+ "'{}' defines discriminator '{}', but the AnyOf schema '{}' has a different {} definition than the prior AnyOf schema's. Make sure the {} type and required values are the same",
+ composedSchemaName, discPropName, modelName, discPropName, discPropName);
}
}
return cp;
@@ -2875,7 +2883,9 @@ protected List getOneOfAnyOfDescendants(String composedSchemaName,
// schemas also has inline composed schemas
// Note: if it is only inline one level, then the inline model resolver will move it into its own
// schema and make it a $ref schema in the oneOf/anyOf location
- LOGGER.warn("Invalid inline schema defined in oneOf/anyOf in '" + composedSchemaName + "'. Per the OpenApi spec, for this case when a composed schema defines a discriminator, the oneOf/anyOf schemas must use $ref. Change this inline definition to a $ref definition");
+ LOGGER.warn(
+ "Invalid inline schema defined in oneOf/anyOf in '{}'. Per the OpenApi spec, for this case when a composed schema defines a discriminator, the oneOf/anyOf schemas must use $ref. Change this inline definition to a $ref definition",
+ composedSchemaName);
}
CodegenProperty df = discriminatorFound(composedSchemaName, sc, discPropName, openAPI);
String modelName = ModelUtils.getSimpleRef(ref);
@@ -2895,7 +2905,8 @@ protected List getOneOfAnyOfDescendants(String composedSchemaName,
msgSuffix += spacer + "invalid optional definition of " + discPropName + ", include it in required";
}
}
- LOGGER.warn("'" + composedSchemaName + "' defines discriminator '" + discPropName + "', but the referenced schema '" + modelName + "' is incorrect. " + msgSuffix);
+ LOGGER.warn("'{}' defines discriminator '{}', but the referenced schema '{}' is incorrect. {}",
+ composedSchemaName, discPropName, modelName, msgSuffix);
}
MappedModel mm = new MappedModel(modelName, toModelName(modelName));
descendentSchemas.add(mm);
@@ -4436,7 +4447,9 @@ public CodegenParameter fromParameter(Parameter parameter, Set imports)
}).collect(Collectors.toList());
}
else {
- LOGGER.warn("No object schema found for deepObject parameter" + codegenParameter + " deepObject won't have specific properties");
+ LOGGER.warn(
+ "No object schema found for deepObject parameter{} deepObject won't have specific properties",
+ codegenParameter);
}
}
@@ -4728,7 +4741,7 @@ public void addOperationToGroup(String tag, String resourcePath, Operation opera
}
}
if (!co.operationId.equals(uniqueName)) {
- LOGGER.warn("generated unique operationId `" + uniqueName + "`");
+ LOGGER.warn("generated unique operationId `{}`", uniqueName);
}
co.operationId = uniqueName;
co.operationIdLowerCase = uniqueName.toLowerCase(Locale.ROOT);
@@ -4883,7 +4896,7 @@ private void addVars(IJsonSchemaValidationProperties m, List va
final String key = entry.getKey();
final Schema prop = entry.getValue();
if (prop == null) {
- LOGGER.warn("Please report the issue. There shouldn't be null property for " + key);
+ LOGGER.warn("Please report the issue. There shouldn't be null property for {}", key);
} else {
final CodegenProperty cp = fromProperty(key, prop);
cp.required = mandatory.contains(key);
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/examples/ExampleGenerator.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/examples/ExampleGenerator.java
index 0c4f9ad726d3..e699a252719b 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/examples/ExampleGenerator.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/examples/ExampleGenerator.java
@@ -204,7 +204,7 @@ private List> generate(Object example, List mediaTyp
output.add(kv);
} else if (mediaType.startsWith(MIME_TYPE_XML)) {
// TODO
- LOGGER.warn("XML example value of (array/primitive) is not handled at the moment: " + example);
+ LOGGER.warn("XML example value of (array/primitive) is not handled at the moment: {}", example);
}
}
}
@@ -296,7 +296,7 @@ private Object resolvePropertyToExample(String propertyName, String mediaType, S
LOGGER.debug("URI or URL format, without default or enum, generating random one.");
return "http://example.com/aeiou";
}
- LOGGER.debug("No values found, using property name " + propertyName + " as example");
+ LOGGER.debug("No values found, using property name {} as example", propertyName);
return propertyName;
} else if (!StringUtils.isEmpty(property.get$ref())) { // model
String simpleName = ModelUtils.getSimpleRef(property.get$ref());
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractAdaCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractAdaCodegen.java
index 309ae0357fcf..f6374d6d9463 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractAdaCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractAdaCodegen.java
@@ -220,7 +220,7 @@ public String toFilename(String name) {
protected String toAdaIdentifier(String name, String prefix) {
// We cannot use reserved keywords for identifiers
if (isReservedWord(name)) {
- LOGGER.warn("Identifier '" + name + "' is a reserved word, renamed to " + prefix + name);
+ LOGGER.warn("Identifier '{}' is a reserved word, renamed to {}{}", name, prefix, name);
name = prefix + name;
}
StringBuilder result = new StringBuilder();
@@ -287,20 +287,22 @@ public String toModelName(final String name) {
// model name cannot use reserved keyword, e.g. return
if (isReservedWord(name)) {
String modelName = "Model_" + result;
- LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + modelName);
+ LOGGER.warn("{} (reserved word) cannot be used as model name. Renamed to {}", name, modelName);
return modelName;
}
// model name starts with number
if (result.matches("^\\d.*")) {
String modelName = "Model_" + result; // e.g. 200Response => Model_200Response (after camelize)
- LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + modelName);
+ LOGGER.warn("{} (model name starts with number) cannot be used as model name. Renamed to {}", name,
+ modelName);
return modelName;
}
if (languageSpecificPrimitives.contains(result)) {
String modelName = "Model_" + result;
- LOGGER.warn(name + " (model name matches existing language type) cannot be used as a model name. Renamed to " + modelName);
+ LOGGER.warn("{} (model name matches existing language type) cannot be used as a model name. Renamed to {}",
+ name, modelName);
return modelName;
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractApexCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractApexCodegen.java
index f2a577ca899e..2b27370900ee 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractApexCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractApexCodegen.java
@@ -162,14 +162,15 @@ public String toModelName(final String name) {
// model name cannot use reserved keyword, e.g. return
if (isReservedWord(camelizedName)) {
final String modelName = "Model" + camelizedName;
- LOGGER.warn(camelizedName + " (reserved word) cannot be used as model name. Renamed to " + modelName);
+ LOGGER.warn("{} (reserved word) cannot be used as model name. Renamed to {}", camelizedName, modelName);
return modelName;
}
// model name starts with number
if (camelizedName.matches("^\\d.*")) {
final String modelName = "Model" + camelizedName; // e.g. 200Response => Model200Response (after camelize)
- LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + modelName);
+ LOGGER.warn("{} (model name starts with number) cannot be used as model name. Renamed to {}", name,
+ modelName);
return modelName;
}
@@ -188,7 +189,7 @@ public String getTypeDeclaration(Schema p) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
if (inner == null) {
- LOGGER.warn(ap.getName() + "(array property) does not have a proper inner type defined");
+ LOGGER.warn("{}(array property) does not have a proper inner type defined", ap.getName());
// TODO maybe better defaulting to StringProperty than returning null
return null;
}
@@ -197,7 +198,7 @@ public String getTypeDeclaration(Schema p) {
Schema inner = getAdditionalProperties(p);
if (inner == null) {
- LOGGER.warn(p.getName() + "(map property) does not have a proper inner type defined");
+ LOGGER.warn("{}(map property) does not have a proper inner type defined", p.getName());
// TODO maybe better defaulting to StringProperty than returning null
return null;
}
@@ -408,7 +409,7 @@ public String getSchemaType(Schema p) {
}
if (null == schemaType) {
- LOGGER.error("No Type defined for Property " + p);
+ LOGGER.error("No Type defined for Property {}", p);
}
return toModelName(schemaType);
}
@@ -425,7 +426,7 @@ public String toOperationId(String operationId) {
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
String newOperationId = camelize("call_" + operationId, true);
- LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId);
+ LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java
index eb263b34c378..883f6cb078b2 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java
@@ -789,13 +789,13 @@ public String toOperationId(String operationId) {
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
- LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + camelize(sanitizeName("call_" + operationId)));
+ LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, camelize(sanitizeName("call_" + operationId)));
operationId = "call_" + operationId;
}
// operationId starts with a number
if (operationId.matches("^\\d.*")) {
- LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + camelize(sanitizeName("call_" + operationId)));
+ LOGGER.warn("{} (starting with a number) cannot be used as method name. Renamed to {}", operationId, camelize(sanitizeName("call_" + operationId)));
operationId = "call_" + operationId;
}
@@ -1032,13 +1032,14 @@ public String toModelName(String name) {
// model name cannot use reserved keyword, e.g. return
if (isReservedWord(name)) {
- LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + camelize("model_" + name));
+ LOGGER.warn("{} (reserved word) cannot be used as model name. Renamed to {}", name, camelize("model_" + name));
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
}
// model name starts with number
if (name.matches("^\\d.*")) {
- LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + camelize("model_" + name));
+ LOGGER.warn("{} (model name starts with number) cannot be used as model name. Renamed to {}", name,
+ camelize("model_" + name));
name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
}
@@ -1267,7 +1268,7 @@ public void postProcessFile(File file, String fileType) {
if (exitValue != 0) {
LOGGER.error("Error running the command ({}). Exit code: {}", command, exitValue);
} else {
- LOGGER.info("Successfully executed: " + command);
+ LOGGER.info("Successfully executed: {}", command);
}
} catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCppCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCppCodegen.java
index 71f0757d91cb..24dabafd7cf7 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCppCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCppCodegen.java
@@ -237,7 +237,7 @@ public String escapeReservedWord(String name) {
@Override
public String toOperationId(String operationId) {
if (isReservedWord(operationId)) {
- LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + escapeReservedWord(operationId));
+ LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, escapeReservedWord(operationId));
return escapeReservedWord(operationId);
}
return sanitizeName(super.toOperationId(operationId));
@@ -329,7 +329,7 @@ public void postProcessFile(File file, String fileType) {
if (exitValue != 0) {
LOGGER.error("Error running the command ({}). Exit value: {}", command, exitValue);
} else {
- LOGGER.info("Successfully executed: " + command);
+ LOGGER.info("Successfully executed: {}", command);
}
} catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractEiffelCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractEiffelCodegen.java
index 945f73249209..d0554f2646d1 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractEiffelCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractEiffelCodegen.java
@@ -192,22 +192,22 @@ public String toModelFilename(String name) {
// model name cannot use reserved keyword, e.g. return
if (isReservedWord(name)) {
- LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + ("model_" + name));
+ LOGGER.warn("{} (reserved word) cannot be used as model name. Renamed to {}", name, "model_" + name);
name = "model_" + name; // e.g. return => ModelReturn (after
// camelize)
}
// model name starts with number
if (name.matches("^\\d.*")) {
- LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to "
- + ("model_" + name));
+ LOGGER.warn("{} (model name starts with number) cannot be used as model name. Renamed to {}", name,
+ "model_" + name);
name = "model_" + name; // e.g. 200Response => Model200Response
// (after camelize)
}
// model name starts with _
if (name.startsWith("_")) {
- LOGGER.warn(name + " (model name starts with _) cannot be used as model name. Renamed to "
- + ("model" + name));
+ LOGGER.warn("{} (model name starts with _) cannot be used as model name. Renamed to {}", name,
+ "model" + name);
name = "model" + name; // e.g. 200Response => Model200Response
// (after camelize)
}
@@ -344,8 +344,7 @@ public String toOperationId(String operationId) {
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(sanitizedOperationId)) {
- LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to "
- + camelize("call_" + operationId));
+ LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, camelize("call_" + operationId));
sanitizedOperationId = "call_" + sanitizedOperationId;
}
@@ -609,7 +608,7 @@ public String toEiffelFeatureStyle(String operationId) {
@Override
protected void updatePropertyForArray(CodegenProperty property, CodegenProperty innerProperty) {
if (innerProperty == null) {
- LOGGER.warn("skipping invalid array property " + Json.pretty(property));
+ LOGGER.warn("skipping invalid array property {}", Json.pretty(property));
return;
}
property.dataFormat = innerProperty.dataFormat;
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractFSharpCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractFSharpCodegen.java
index 0dc4e1126a75..d33738bd824d 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractFSharpCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractFSharpCodegen.java
@@ -628,13 +628,13 @@ public String toOperationId(String operationId) {
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
- LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + camelize(sanitizeName("call_" + operationId)));
+ LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, camelize(sanitizeName("call_" + operationId)));
operationId = "call_" + operationId;
}
// operationId starts with a number
if (operationId.matches("^\\d.*")) {
- LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + camelize(sanitizeName("call_" + operationId)));
+ LOGGER.warn("{} (starting with a number) cannot be used as method name. Renamed to {}", operationId, camelize(sanitizeName("call_" + operationId)));
operationId = "call_" + operationId;
}
@@ -900,13 +900,14 @@ public String toModelName(String name) {
// model name cannot use reserved keyword, e.g. return
if (isReservedWord(name)) {
- LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + camelize("model_" + name));
+ LOGGER.warn("{} (reserved word) cannot be used as model name. Renamed to {}", name, camelize("model_" + name));
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
}
// model name starts with number
if (name.matches("^\\d.*")) {
- LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + camelize("model_" + name));
+ LOGGER.warn("{} (model name starts with number) cannot be used as model name. Renamed to {}", name,
+ camelize("model_" + name));
name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
}
@@ -1121,7 +1122,7 @@ public void postProcessFile(File file, String fileType) {
if (exitValue != 0) {
LOGGER.error("Error running the command ({}). Exit code: {}", command, exitValue);
} else {
- LOGGER.info("Successfully executed: " + command);
+ LOGGER.info("Successfully executed: {}", command);
}
} catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGoCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGoCodegen.java
index cee83d467c84..c4dd2d451686 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGoCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGoCodegen.java
@@ -202,7 +202,7 @@ public String toVarName(String name) {
// for reserved word append _
if (isReservedWord(name)) {
- LOGGER.warn(name + " (reserved word) cannot be used as variable name. Renamed to " + escapeReservedWord(name));
+ LOGGER.warn("{} (reserved word) cannot be used as variable name. Renamed to {}", name, escapeReservedWord(name));
name = escapeReservedWord(name);
}
@@ -234,7 +234,7 @@ public String toParamName(String name) {
// really should just be a letter, e.g. "p Person"), but we'll get
// around to that some other time... Maybe.
if (isReservedWord(name)) {
- LOGGER.warn(name + " (reserved word) cannot be used as parameter name. Renamed to " + name + "_");
+ LOGGER.warn("{} (reserved word) cannot be used as parameter name. Renamed to {}_", name, name);
name = name + "_";
}
@@ -269,7 +269,8 @@ public String toModelFilename(String name) {
name = toModel("model_" + name);
if (isReservedFilename(name)) {
- LOGGER.warn(name + ".go with suffix (reserved word) cannot be used as filename. Renamed to " + name + "_.go");
+ LOGGER.warn("{}.go with suffix (reserved word) cannot be used as filename. Renamed to {}_.go", name,
+ name);
name += "_";
}
return name;
@@ -292,14 +293,14 @@ public String toModel(String name, boolean doUnderscore) {
// model name cannot use reserved keyword, e.g. return
if (isReservedWord(name)) {
- LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + ("model_" + name));
+ LOGGER.warn("{} (reserved word) cannot be used as model name. Renamed to {}", name, "model_" + name);
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
}
// model name starts with number
if (name.matches("^\\d.*")) {
- LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to "
- + ("model_" + name));
+ LOGGER.warn("{} (model name starts with number) cannot be used as model name. Renamed to {}", name,
+ "model_" + name);
name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
}
@@ -317,7 +318,8 @@ public String toApiFilename(String name) {
// e.g. PetApi.go => pet_api.go
api = "api_" + underscore(api);
if (isReservedFilename(api)) {
- LOGGER.warn(name + ".go with suffix (reserved word) cannot be used as filename. Renamed to " + api + "_.go");
+ LOGGER.warn("{}.go with suffix (reserved word) cannot be used as filename. Renamed to {}_.go", name,
+ api);
api += "_";
}
apiName = api;
@@ -441,14 +443,13 @@ public String toOperationId(String operationId) {
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(sanitizedOperationId)) {
- LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to "
- + camelize("call_" + sanitizedOperationId));
+ LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, camelize("call_" + sanitizedOperationId));
sanitizedOperationId = "call_" + sanitizedOperationId;
}
// operationId starts with a number
if (sanitizedOperationId.matches("^\\d.*")) {
- LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + camelize("call_" + sanitizedOperationId));
+ LOGGER.warn("{} (starting with a number) cannot be used as method name. Renamed to {}", operationId, camelize("call_" + sanitizedOperationId));
sanitizedOperationId = "call_" + sanitizedOperationId;
}
@@ -831,7 +832,7 @@ public void postProcessFile(File file, String fileType) {
if (exitValue != 0) {
LOGGER.error("Error running the command ({}). Exit code: {}", command, exitValue);
} else {
- LOGGER.info("Successfully executed: " + command);
+ LOGGER.info("Successfully executed: {}", command);
}
} catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGraphQLCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGraphQLCodegen.java
index 5246963a8b17..c5a04049af0d 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGraphQLCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGraphQLCodegen.java
@@ -193,13 +193,14 @@ public String toModelFilename(String name) {
// model name cannot use reserved keyword, e.g. return
if (isReservedWord(name)) {
- LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + ("model_" + name));
+ LOGGER.warn("{} (reserved word) cannot be used as model name. Renamed to {}", name, "model_" + name);
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
}
// model name starts with number
if (name.matches("^\\d.*")) {
- LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + ("model_" + name));
+ LOGGER.warn("{} (model name starts with number) cannot be used as model name. Renamed to {}", name,
+ "model_" + name);
name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
}
@@ -317,7 +318,7 @@ public String toOperationId(String operationId) {
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(sanitizedOperationId)) {
- LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + underscore("call_" + operationId));
+ LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, underscore("call_" + operationId));
sanitizedOperationId = "call_" + sanitizedOperationId;
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java
index 0ef7bc8d8438..320da10803f3 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java
@@ -313,13 +313,14 @@ public void processOpts() {
String derivedInvokerPackage = deriveInvokerPackageName((String) additionalProperties.get(CodegenConstants.API_PACKAGE));
this.additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, derivedInvokerPackage);
this.setInvokerPackage((String) additionalProperties.get(CodegenConstants.INVOKER_PACKAGE));
- LOGGER.info("Invoker Package Name, originally not set, is now derived from api package name: " + derivedInvokerPackage);
+ LOGGER.info("Invoker Package Name, originally not set, is now derived from api package name: {}", derivedInvokerPackage);
} else if (additionalProperties.containsKey(CodegenConstants.MODEL_PACKAGE)) {
// guess from model package
String derivedInvokerPackage = deriveInvokerPackageName((String) additionalProperties.get(CodegenConstants.MODEL_PACKAGE));
this.additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, derivedInvokerPackage);
this.setInvokerPackage((String) additionalProperties.get(CodegenConstants.INVOKER_PACKAGE));
- LOGGER.info("Invoker Package Name, originally not set, is now derived from model package name: " + derivedInvokerPackage);
+ LOGGER.info("Invoker Package Name, originally not set, is now derived from model package name: {}",
+ derivedInvokerPackage);
} else {
//not set, use default to be passed to template
additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage);
@@ -786,14 +787,15 @@ public String toModelName(final String name) {
// model name cannot use reserved keyword, e.g. return
if (isReservedWord(camelizedName)) {
final String modelName = "Model" + camelizedName;
- LOGGER.warn(camelizedName + " (reserved word) cannot be used as model name. Renamed to " + modelName);
+ LOGGER.warn("{} (reserved word) cannot be used as model name. Renamed to {}", camelizedName, modelName);
return modelName;
}
// model name starts with number
if (camelizedName.matches("^\\d.*")) {
final String modelName = "Model" + camelizedName; // e.g. 200Response => Model200Response (after camelize)
- LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + modelName);
+ LOGGER.warn("{} (model name starts with number) cannot be used as model name. Renamed to {}", name,
+ modelName);
return modelName;
}
@@ -1140,7 +1142,7 @@ public String getSchemaType(Schema p) {
}
if (null == openAPIType) {
- LOGGER.error("No Type defined for Schema " + p);
+ LOGGER.error("No Type defined for Schema {}", p);
}
return toModelName(openAPIType);
}
@@ -1157,7 +1159,7 @@ public String toOperationId(String operationId) {
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
String newOperationId = camelize("call_" + operationId, true);
- LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId);
+ LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}
@@ -1284,7 +1286,7 @@ public void preprocessOpenAPI(OpenAPI openAPI) {
continue;
}
for (Operation operation : path.readOperations()) {
- LOGGER.info("Processing operation " + operation.getOperationId());
+ LOGGER.info("Processing operation {}", operation.getOperationId());
if (hasBodyParameter(openAPI, operation) || hasFormParameter(openAPI, operation)) {
String defaultContentType = hasFormParameter(openAPI, operation) ? "application/x-www-form-urlencoded" : "application/json";
List consumes = new ArrayList<>(getConsumesInfo(openAPI, operation));
@@ -1838,7 +1840,7 @@ public void postProcessFile(File file, String fileType) {
if (exitValue != 0) {
LOGGER.error("Error running the command ({}). Exit value: {}", command, exitValue);
} else {
- LOGGER.info("Successfully executed: " + command);
+ LOGGER.info("Successfully executed: {}", command);
}
} catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractKotlinCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractKotlinCodegen.java
index e3d4204a8d60..c681aaf51cb9 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractKotlinCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractKotlinCodegen.java
@@ -421,7 +421,7 @@ public void processOpts() {
}
if (additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) {
- LOGGER.warn(CodegenConstants.INVOKER_PACKAGE + " with " + this.getName() + " generator is ignored. Use " + CodegenConstants.PACKAGE_NAME + ".");
+ LOGGER.warn("{} with {} generator is ignored. Use {}.", CodegenConstants.INVOKER_PACKAGE, this.getName(), CodegenConstants.PACKAGE_NAME);
}
if (additionalProperties.containsKey(CodegenConstants.SERIALIZABLE_MODEL)) {
@@ -624,14 +624,15 @@ public String toModelName(final String name) {
// model name cannot use reserved keyword, e.g. return
if (isReservedWord(modifiedName)) {
final String modelName = "Model" + modifiedName;
- LOGGER.warn(modifiedName + " (reserved word) cannot be used as model name. Renamed to " + modelName);
+ LOGGER.warn("{} (reserved word) cannot be used as model name. Renamed to {}", modifiedName, modelName);
return modelName;
}
// model name starts with number
if (modifiedName.matches("^\\d.*")) {
final String modelName = "Model" + modifiedName; // e.g. 200Response => Model200Response (after camelize)
- LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + modelName);
+ LOGGER.warn("{} (model name starts with number) cannot be used as model name. Renamed to {}", name,
+ modelName);
return modelName;
}
@@ -655,7 +656,7 @@ public String toOperationId(String operationId) {
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
String newOperationId = camelize("call_" + operationId, true);
- LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId);
+ LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}
@@ -890,7 +891,7 @@ public void postProcessFile(File file, String fileType) {
if (exitValue != 0) {
LOGGER.error("Error running the command ({}). Exit value: {}", command, exitValue);
} else {
- LOGGER.info("Successfully executed: " + command);
+ LOGGER.info("Successfully executed: {}", command);
}
} catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPhpCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPhpCodegen.java
index 115e945d6aca..4e1f571a709a 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPhpCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPhpCodegen.java
@@ -295,14 +295,15 @@ public String getTypeDeclaration(Schema p) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
if (inner == null) {
- LOGGER.warn(ap.getName() + "(array property) does not have a proper inner type defined.Default to string");
+ LOGGER.warn("{}(array property) does not have a proper inner type defined.Default to string",
+ ap.getName());
inner = new StringSchema().description("TODO default missing array inner type to string");
}
return getTypeDeclaration(inner) + "[]";
} else if (ModelUtils.isMapSchema(p)) {
Schema inner = getAdditionalProperties(p);
if (inner == null) {
- LOGGER.warn(p.getName() + "(map property) does not have a proper inner type defined. Default to string");
+ LOGGER.warn("{}(map property) does not have a proper inner type defined. Default to string", p.getName());
inner = new StringSchema().description("TODO default missing map inner type to string");
}
return getSchemaType(p) + "";
@@ -408,13 +409,14 @@ private String toGenericName(String name) {
// model name cannot use reserved keyword
if (isReservedWord(name)) {
- LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + camelize("model_" + name));
+ LOGGER.warn("{} (reserved word) cannot be used as model name. Renamed to {}", name, camelize("model_" + name));
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
}
// model name starts with number
if (name.matches("^\\d.*")) {
- LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + camelize("model_" + name));
+ LOGGER.warn("{} (model name starts with number) cannot be used as model name. Renamed to {}", name,
+ camelize("model_" + name));
name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
}
@@ -492,13 +494,13 @@ public String toOperationId(String operationId) {
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
- LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + camelize(sanitizeName("call_" + operationId), true));
+ LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, camelize(sanitizeName("call_" + operationId), true));
operationId = "call_" + operationId;
}
// operationId starts with a number
if (operationId.matches("^\\d.*")) {
- LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + camelize(sanitizeName("call_" + operationId), true));
+ LOGGER.warn("{} (starting with a number) cannot be used as method name. Renamed to {}", operationId, camelize(sanitizeName("call_" + operationId), true));
operationId = "call_" + operationId;
}
@@ -590,7 +592,7 @@ public void setParameterExampleValue(CodegenParameter p) {
// type is a model class, e.g. User
example = "new " + getTypeDeclaration(type) + "()";
} else {
- LOGGER.warn("Type " + type + " not handled properly in setParameterExampleValue");
+ LOGGER.warn("Type {} not handled properly in setParameterExampleValue", type);
}
if (example == null) {
@@ -747,7 +749,7 @@ public void postProcessFile(File file, String fileType) {
if (exitValue != 0) {
LOGGER.error("Error running the command ({}). Exit value: {}", command, exitValue);
} else {
- LOGGER.info("Successfully executed: " + command);
+ LOGGER.info("Successfully executed: {}", command);
}
} catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonConnexionServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonConnexionServerCodegen.java
index df60913e61e4..2e04cd2d3e6e 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonConnexionServerCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonConnexionServerCodegen.java
@@ -343,7 +343,9 @@ public void preprocessOpenAPI(OpenAPI openAPI) {
fixedPath += "/" + token;
}
if (!fixedPath.equals(pathname)) {
- LOGGER.warn("Path '" + pathname + "' is not consistant with Python variable names. It will be replaced by '" + fixedPath + "'");
+ LOGGER.warn(
+ "Path '{}' is not consistant with Python variable names. It will be replaced by '{}'",
+ pathname, fixedPath);
paths.remove(pathname);
path.addExtension("x-python-connexion-openapi-name", pathname);
paths.put(fixedPath, path);
@@ -373,12 +375,14 @@ public void preprocessOpenAPI(OpenAPI openAPI) {
String swaggerParameterName = parameter.getName();
String pythonParameterName = this.toParamName(swaggerParameterName);
if (!swaggerParameterName.equals(pythonParameterName)) {
- LOGGER.warn("Parameter name '" + swaggerParameterName + "' is not consistant with Python variable names. It will be replaced by '" + pythonParameterName + "'");
+ LOGGER.warn(
+ "Parameter name '{}' is not consistant with Python variable names. It will be replaced by '{}'",
+ swaggerParameterName, pythonParameterName);
parameter.addExtension("x-python-connexion-openapi-name", swaggerParameterName);
parameter.setName(pythonParameterName);
}
if (swaggerParameterName.isEmpty()) {
- LOGGER.error("Missing parameter name in " + pathname + "." + parameter.getIn());
+ LOGGER.error("Missing parameter name in {}.{}", pathname, parameter.getIn());
}
}
}
@@ -435,13 +439,13 @@ private void addSecurityExtensions(OpenAPI openAPI) {
}
break;
case OPENIDCONNECT:
- LOGGER.warn("Security type " + securityScheme.getType().toString() + " is not supported by connextion yet");
+ LOGGER.warn("Security type {} is not supported by connextion yet", securityScheme.getType().toString());
case OAUTH2:
addSecurityExtension(securityScheme, "x-tokenInfoFunc", baseFunctionName + "info_from_" + securityName);
addSecurityExtension(securityScheme, "x-scopeValidateFunc", baseFunctionName + "validate_scope_" + securityName);
break;
default:
- LOGGER.warn("Unknown security type " + securityScheme.getType().toString());
+ LOGGER.warn("Unknown security type {}", securityScheme.getType().toString());
}
}
}
@@ -498,7 +502,9 @@ public Map postProcessSupportingFileData(Map obj
// Get and remove the (temporary) vendor extension
String openapiPathname = (String) pathExtensions.remove("x-python-connexion-openapi-name");
if (openapiPathname != null && !openapiPathname.equals(pythonPathname)) {
- LOGGER.info("Path '" + pythonPathname + "' is not consistant with the original OpenAPI definition. It will be replaced back by '" + openapiPathname + "'");
+ LOGGER.info(
+ "Path '{}' is not consistant with the original OpenAPI definition. It will be replaced back by '{}'",
+ pythonPathname, openapiPathname);
paths.remove(pythonPathname);
paths.put(openapiPathname, path);
}
@@ -517,13 +523,18 @@ public Map postProcessSupportingFileData(Map obj
if (swaggerParameterName != null) {
String pythonParameterName = parameter.getName();
if (!swaggerParameterName.equals(pythonParameterName)) {
- LOGGER.info("Reverting name of parameter '" + pythonParameterName + "' of operation '" + operation.getOperationId() + "' back to '" + swaggerParameterName + "'");
+ LOGGER.info(
+ "Reverting name of parameter '{}' of operation '{}' back to '{}'",
+ pythonParameterName, operation.getOperationId(), swaggerParameterName);
parameter.setName(swaggerParameterName);
} else {
- LOGGER.debug("Name of parameter '" + pythonParameterName + "' of operation '" + operation.getOperationId() + "' was unchanged.");
+ LOGGER.debug("Name of parameter '{}' of operation '{}' was unchanged.",
+ pythonParameterName, operation.getOperationId());
}
} else {
- LOGGER.debug("x-python-connexion-openapi-name was not set on parameter '" + parameter.getName() + "' of operation '" + operation.getOperationId() + "'");
+ LOGGER.debug(
+ "x-python-connexion-openapi-name was not set on parameter '{}' of operation '{}'",
+ parameter.getName(), operation.getOperationId());
}
}
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractScalaCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractScalaCodegen.java
index 7ceb98d917e1..7b7aef86da9e 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractScalaCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractScalaCodegen.java
@@ -461,14 +461,15 @@ public String toModelName(final String name) {
// model name cannot use reserved keyword, e.g. return
if (isReservedWord(camelizedName)) {
final String modelName = "Model" + camelizedName;
- LOGGER.warn(camelizedName + " (reserved word) cannot be used as model name. Renamed to " + modelName);
+ LOGGER.warn("{} (reserved word) cannot be used as model name. Renamed to {}", camelizedName, modelName);
return modelName;
}
// model name starts with number
if (name.matches("^\\d.*")) {
final String modelName = "Model" + camelizedName; // e.g. 200Response => Model200Response (after camelize)
- LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + modelName);
+ LOGGER.warn("{} (model name starts with number) cannot be used as model name. Renamed to {}", name,
+ modelName);
return modelName;
}
@@ -531,7 +532,7 @@ public void postProcessFile(File file, String fileType) {
if (exitValue != 0) {
LOGGER.error("Error running the command ({}). Exit value: {}", command, exitValue);
} else {
- LOGGER.info("Successfully executed: " + command);
+ LOGGER.info("Successfully executed: {}", command);
}
} catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
@@ -553,7 +554,7 @@ public String toOperationId(String operationId) {
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
String newOperationId = camelize("call_" + operationId, true);
- LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId);
+ LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java
index 353c05d5a2e7..c6762f1903ea 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java
@@ -27,6 +27,7 @@
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CodegenConstants.ENUM_PROPERTY_NAMING_TYPE;
import org.openapitools.codegen.CodegenConstants.MODEL_PROPERTY_NAMING_TYPE;
+import org.openapitools.codegen.CodegenConstants.PARAM_NAMING_TYPE;
import org.openapitools.codegen.*;
import org.openapitools.codegen.meta.features.*;
import org.openapitools.codegen.utils.ModelUtils;
@@ -64,6 +65,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
protected MODEL_PROPERTY_NAMING_TYPE modelPropertyNaming = MODEL_PROPERTY_NAMING_TYPE.original;
protected ENUM_PROPERTY_NAMING_TYPE enumPropertyNaming = ENUM_PROPERTY_NAMING_TYPE.PascalCase;
+ protected PARAM_NAMING_TYPE paramNaming = PARAM_NAMING_TYPE.camelCase;
protected Boolean supportsES6 = false;
protected Boolean nullSafeAdditionalProps = false;
protected HashSet languageGenericTypes;
@@ -175,6 +177,7 @@ public AbstractTypeScriptClientCodegen() {
cliOptions.add(new CliOption(CodegenConstants.ENUM_PROPERTY_NAMING, CodegenConstants.ENUM_PROPERTY_NAMING_DESC).defaultValue(this.enumPropertyNaming.name()));
cliOptions.add(new CliOption(CodegenConstants.MODEL_PROPERTY_NAMING, MODEL_PROPERTY_NAMING_DESC_WITH_WARNING).defaultValue(this.modelPropertyNaming.name()));
cliOptions.add(new CliOption(CodegenConstants.SUPPORTS_ES6, CodegenConstants.SUPPORTS_ES6_DESC).defaultValue(String.valueOf(this.getSupportsES6())));
+ cliOptions.add(new CliOption(CodegenConstants.PARAM_NAMING, CodegenConstants.PARAM_NAMING_DESC).defaultValue(this.paramNaming.name()));
this.cliOptions.add(new CliOption(NPM_NAME, "The name under which you want to publish generated npm package." +
" Required to generate a full package"));
this.cliOptions.add(new CliOption(NPM_VERSION, "The version of your npm package. If not provided, using the version from the OpenAPI specification file.").defaultValue(this.getNpmVersion()));
@@ -212,6 +215,10 @@ public void processOpts() {
setModelPropertyNaming((String) additionalProperties.get(CodegenConstants.MODEL_PROPERTY_NAMING));
}
+ if (additionalProperties.containsKey(CodegenConstants.PARAM_NAMING)) {
+ setParamNaming((String) additionalProperties.get(CodegenConstants.PARAM_NAMING));
+ }
+
if (additionalProperties.containsKey(CodegenConstants.SUPPORTS_ES6)) {
setSupportsES6(Boolean.valueOf(additionalProperties.get(CodegenConstants.SUPPORTS_ES6).toString()));
additionalProperties.put("supportsES6", getSupportsES6());
@@ -227,11 +234,15 @@ public void processOpts() {
}
@Override
- public String toModelImport( String name){
+ public String toModelImport(String name){
if(isUnionType(name)){
LOGGER.warn("The import is a union type. Consider using the toModelImportMap method.");
return toModelImportMap(name).values().stream().collect(Collectors.joining("|"));
}
+ if(isIntersectionType(name)){
+ LOGGER.warn("The import is a intersection type. Consider using the toModelImportMap method.");
+ return toModelImportMap(name).values().stream().collect(Collectors.joining("&"));
+ }
return super.toModelImport(name);
}
@@ -243,26 +254,28 @@ public String toModelImport( String name){
* @return Map between the fully qualified model import and the initial given name.
*/
@Override
- public Map toModelImportMap( String name){
- if(isUnionType(name)){
- String[] names = splitUnionType(name);
- return toImportMap(names);
- }
- return toImportMap(name);
+ public Map toModelImportMap(String name){
+ return toImportMap(splitComposedType(name));
+ }
+
+ private String[] splitComposedType (String name) {
+ return name.replace(" ","").split("[|&<>]");
}
private boolean isUnionType(String name){
return name.contains("|");
}
- private String[] splitUnionType(String name){
- return name.replace(" ","").split("\\|");
+ private boolean isIntersectionType(String name){
+ return name.contains("&");
}
private Map toImportMap(String... names){
Map result = Maps.newHashMap();
for(String name: names){
- result.put(toModelImport(name),name);
+ if(needToImport(name)){
+ result.put(toModelImport(name), name);
+ }
}
return result;
}
@@ -324,7 +337,7 @@ public String toParamName(String name) {
name = "_u";
}
- name = camelize(name, true);
+ name = getNameUsingParamNaming(name);
name = toSafeIdentifier(name);
return name;
@@ -384,20 +397,22 @@ protected String toTypescriptTypeName(final String name, String safePrefix) {
// this is unlikely to happen, because we have just camelized the name, while reserved words are usually all lowcase
if (isReservedWord(sanName)) {
String modelName = safePrefix + sanName;
- LOGGER.warn(sanName + " (reserved word) cannot be used as model name. Renamed to " + modelName);
+ LOGGER.warn("{} (reserved word) cannot be used as model name. Renamed to {}", sanName, modelName);
return modelName;
}
// model name starts with number
if (sanName.matches("^\\d.*")) {
String modelName = safePrefix + sanName; // e.g. 200Response => Model200Response
- LOGGER.warn(sanName + " (model name starts with number) cannot be used as model name. Renamed to " + modelName);
+ LOGGER.warn("{} (model name starts with number) cannot be used as model name. Renamed to {}", sanName,
+ modelName);
return modelName;
}
if (languageSpecificPrimitives.contains(sanName)) {
String modelName = safePrefix + sanName;
- LOGGER.warn(sanName + " (model name matches existing language type) cannot be used as a model name. Renamed to " + modelName);
+ LOGGER.warn("{} (model name matches existing language type) cannot be used as a model name. Renamed to {}",
+ sanName, modelName);
return modelName;
}
@@ -589,10 +604,45 @@ public void setModelPropertyNaming(String naming) {
}
}
+ public void setParamNaming(String naming) {
+ try {
+ paramNaming = PARAM_NAMING_TYPE.valueOf(naming);
+ } catch (IllegalArgumentException e) {
+ String values = Stream.of(PARAM_NAMING_TYPE.values())
+ .map(value -> "'" + value.name() + "'")
+ .collect(Collectors.joining(", "));
+
+ String msg = String.format(Locale.ROOT, "Invalid parameter naming '%s'. Must be one of %s.", naming, values);
+ throw new IllegalArgumentException(msg);
+ }
+ }
+
public MODEL_PROPERTY_NAMING_TYPE getModelPropertyNaming() {
return modelPropertyNaming;
}
+ public PARAM_NAMING_TYPE getParamNaming() {
+ return paramNaming;
+ }
+
+ private String getNameUsingParamNaming(String name) {
+ switch (getParamNaming()) {
+ case original:
+ return name;
+ case camelCase:
+ return camelize(name, true);
+ case PascalCase:
+ return camelize(name);
+ case snake_case:
+ return underscore(name);
+ default:
+ throw new IllegalArgumentException("Invalid param naming '" +
+ name + "'. Must be 'original', 'camelCase', " +
+ "'PascalCase' or 'snake_case'");
+ }
+
+ }
+
private String getNameUsingModelPropertyNaming(String name) {
switch (getModelPropertyNaming()) {
case original:
@@ -707,7 +757,7 @@ protected void addImport(CodegenModel m, String type) {
return;
}
- String[] parts = type.split("( [|&] )|[<>]");
+ String[] parts = splitComposedType(type);
for (String s : parts) {
if (needToImport(s)) {
m.imports.add(s);
@@ -854,7 +904,7 @@ public void postProcessFile(File file, String fileType) {
if (exitValue != 0) {
LOGGER.error("Error running the command ({}). Exit value: {}", command, exitValue);
} else {
- LOGGER.info("Successfully executed: " + command);
+ LOGGER.info("Successfully executed: {}", command);
}
} catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AndroidClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AndroidClientCodegen.java
index 2fa04946c816..d3ead4fc86d7 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AndroidClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AndroidClientCodegen.java
@@ -301,14 +301,15 @@ public String toModelName(String name) {
// model name cannot use reserved keyword, e.g. return
if (isReservedWord(name)) {
String modelName = "Model" + name;
- LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + modelName);
+ LOGGER.warn("{} (reserved word) cannot be used as model name. Renamed to {}", name, modelName);
return modelName;
}
// model name starts with number
if (name.matches("^\\d.*")) {
String modelName = "Model" + name; // e.g. 200Response => Model200Response (after camelize)
- LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + modelName);
+ LOGGER.warn("{} (model name starts with number) cannot be used as model name. Renamed to {}", name,
+ modelName);
return modelName;
}
@@ -398,7 +399,7 @@ public String toOperationId(String operationId) {
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
String newOperationId = camelize("call_" + operationId, true);
- LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId);
+ LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AsciidocDocumentationCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AsciidocDocumentationCodegen.java
index 6c2dd4ac4340..83c32409a8a4 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AsciidocDocumentationCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AsciidocDocumentationCodegen.java
@@ -89,10 +89,10 @@ public void execute(final Template.Fragment frag, final Writer out) throws IOExc
String includeStatement = "include::{" + attributePathReference + "}" + escapeCurlyBrackets(relativeFileName) + "[opts=optional]";
if (Files.isRegularFile(filePathToInclude)) {
- LOGGER.debug("including " + ++includeCount + ". file into markup from: " + filePathToInclude.toString());
+ LOGGER.debug("including {}. file into markup from: {}", ++includeCount, filePathToInclude.toString());
out.write("\n" + includeStatement + "\n");
} else {
- LOGGER.debug(++notFoundCount + ". file not found, skip include for: " + filePathToInclude.toString());
+ LOGGER.debug("{}. file not found, skip include for: {}", ++notFoundCount, filePathToInclude.toString());
out.write("\n// markup not found, no " + includeStatement + "\n");
}
}
@@ -140,10 +140,10 @@ public void execute(final Template.Fragment frag, final Writer out) throws IOExc
final Path filePathToLinkTo = Paths.get(basePath, relativeFileName).toAbsolutePath();
if (Files.isRegularFile(filePathToLinkTo)) {
- LOGGER.debug("linking " + ++linkedCount + ". file into markup from: " + filePathToLinkTo.toString());
+ LOGGER.debug("linking {}. file into markup from: {}", ++linkedCount, filePathToLinkTo.toString());
out.write("\n" + linkName + " link:" + relativeFileName + "[]\n");
} else {
- LOGGER.debug(++notFoundLinkCount + ". file not found, skip link for: " + filePathToLinkTo.toString());
+ LOGGER.debug("{}. file not found, skip link for: {}", ++notFoundLinkCount, filePathToLinkTo.toString());
out.write("\n// file not found, no " + linkName + " link :" + relativeFileName + "[]\n");
}
}
@@ -324,8 +324,7 @@ public void processOpts() {
String specDir = this.additionalProperties.get(SPEC_DIR) + "";
if (!Files.isDirectory(Paths.get(specDir))) {
- LOGGER.warn("base part for include markup lambda not found: " + specDir + " as "
- + Paths.get(specDir).toAbsolutePath());
+ LOGGER.warn("base part for include markup lambda not found: {} as {}", specDir, Paths.get(specDir).toAbsolutePath());
}
this.includeSpecMarkupLambda = new IncludeMarkupLambda(SPEC_DIR,specDir);
@@ -333,8 +332,7 @@ public void processOpts() {
String snippetDir = this.additionalProperties.get(SNIPPET_DIR) + "";
if (!Files.isDirectory(Paths.get(snippetDir))) {
- LOGGER.warn("base part for include markup lambda not found: " + snippetDir + " as "
- + Paths.get(snippetDir).toAbsolutePath());
+ LOGGER.warn("base part for include markup lambda not found: {} as {}", snippetDir, Paths.get(snippetDir).toAbsolutePath());
}
this.includeSnippetMarkupLambda = new IncludeMarkupLambda(SNIPPET_DIR,snippetDir);
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AspNetCoreServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AspNetCoreServerCodegen.java
index 141cd952bdec..ca50b0ff1f4c 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AspNetCoreServerCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AspNetCoreServerCodegen.java
@@ -443,7 +443,7 @@ protected void processOperation(CodegenOperation operation) {
String original = operation.path;
operation.path = operation.path.replace("?", "/");
if (!original.equals(operation.path)) {
- LOGGER.warn("Normalized " + original + " to " + operation.path + ". Please verify generated source.");
+ LOGGER.warn("Normalized {} to {}. Please verify generated source.", original, operation.path);
}
}
@@ -567,7 +567,7 @@ private void setClassModifier() {
if ("abstract".equals(classModifier.getOptValue())) {
operationModifier.setOptValue(classModifier.getOptValue());
additionalProperties.put(OPERATION_MODIFIER, operationModifier.getOptValue());
- LOGGER.warn("classModifier is " + classModifier.getOptValue() + " so forcing operatonModifier to " + operationModifier.getOptValue());
+ LOGGER.warn("classModifier is {} so forcing operatonModifier to {}", classModifier.getOptValue(), operationModifier.getOptValue());
}
}
@@ -578,7 +578,7 @@ private void setOperationModifier() {
if ("abstract".equals(operationModifier.getOptValue())) {
generateBody = false;
additionalProperties.put(GENERATE_BODY, generateBody);
- LOGGER.warn("operationModifier is " + operationModifier.getOptValue() + " so forcing generateBody to " + generateBody);
+ LOGGER.warn("operationModifier is {} so forcing generateBody to {}", operationModifier.getOptValue(), generateBody);
} else if (additionalProperties.containsKey(GENERATE_BODY)) {
generateBody = convertPropertyToBooleanAndWriteBack(GENERATE_BODY);
} else {
@@ -593,7 +593,7 @@ private void setModelClassModifier() {
if (isLibrary) {
modelClassModifier.setOptValue("");
additionalProperties.put(MODEL_CLASS_MODIFIER, modelClassModifier.getOptValue());
- LOGGER.warn("buildTarget is " + buildTarget.getOptValue() + " so removing any modelClassModifier ");
+ LOGGER.warn("buildTarget is {} so removing any modelClassModifier ", buildTarget.getOptValue());
}
}
@@ -622,7 +622,7 @@ private void setAspnetCoreVersion(String packageFolder) {
// default, do nothing
compatibilityVersion = "Version_" + aspnetCoreVersion.getOptValue().replace(".", "_");
}
- LOGGER.info("ASP.NET core version: " + aspnetCoreVersion.getOptValue());
+ LOGGER.info("ASP.NET core version: {}", aspnetCoreVersion.getOptValue());
if(!additionalProperties.containsKey(CodegenConstants.TEMPLATE_DIR)){
templateDir = embeddedTemplateDir = "aspnetcore" + File.separator + determineTemplateVersion(aspnetCoreVersion.getOptValue());
}
@@ -660,7 +660,8 @@ private void setUseSwashbuckle() {
private void setNullableReferenceTypes() {
if (additionalProperties.containsKey(NULLABLE_REFERENCE_TYPES)) {
if (aspnetCoreVersion.getOptValue().startsWith("2.")) {
- LOGGER.warn("Nullable annotation are not supported in ASP.NET core version 2. Setting " + NULLABLE_REFERENCE_TYPES + " to false");
+ LOGGER.warn("Nullable annotation are not supported in ASP.NET core version 2. Setting {} to false",
+ NULLABLE_REFERENCE_TYPES);
additionalProperties.put(NULLABLE_REFERENCE_TYPES, false);
} else {
nullableReferenceTypes = convertPropertyToBooleanAndWriteBack(NULLABLE_REFERENCE_TYPES);
@@ -683,12 +684,16 @@ private void setOperationIsAsync() {
private void setIsFramework() {
if (aspnetCoreVersion.getOptValue().startsWith("3.")) {// default, do nothing
- LOGGER.warn("ASP.NET core version is " + aspnetCoreVersion.getOptValue() + " so changing to use frameworkReference instead of packageReference ");
+ LOGGER.warn(
+ "ASP.NET core version is {} so changing to use frameworkReference instead of packageReference ",
+ aspnetCoreVersion.getOptValue());
useFrameworkReference = true;
additionalProperties.put(USE_FRAMEWORK_REFERENCE, useFrameworkReference);
additionalProperties.put(TARGET_FRAMEWORK, "netcoreapp" + aspnetCoreVersion.getOptValue());
} else if (aspnetCoreVersion.getOptValue().startsWith("5.")) {// default, do nothing
- LOGGER.warn("ASP.NET core version is " + aspnetCoreVersion.getOptValue() + " so changing to use frameworkReference instead of packageReference ");
+ LOGGER.warn(
+ "ASP.NET core version is {} so changing to use frameworkReference instead of packageReference ",
+ aspnetCoreVersion.getOptValue());
useFrameworkReference = true;
additionalProperties.put(USE_FRAMEWORK_REFERENCE, useFrameworkReference);
additionalProperties.put(TARGET_FRAMEWORK, "net5.0");
@@ -705,7 +710,7 @@ private void setIsFramework() {
private void setUseNewtonsoft() {
if (aspnetCoreVersion.getOptValue().startsWith("2.")) {
LOGGER.warn("ASP.NET core version 2.X support has been deprecated. Please use ASP.NET core version 3.1 instead");
- LOGGER.warn("ASP.NET core version is " + aspnetCoreVersion.getOptValue() + " so staying on default json library.");
+ LOGGER.warn("ASP.NET core version is {} so staying on default json library.", aspnetCoreVersion.getOptValue());
useNewtonsoft = false;
additionalProperties.put(USE_NEWTONSOFT, useNewtonsoft);
} else {
@@ -719,7 +724,7 @@ private void setUseNewtonsoft() {
private void setUseEndpointRouting() {
if (aspnetCoreVersion.getOptValue().startsWith("3.") || aspnetCoreVersion.getOptValue().startsWith("5.")) {
- LOGGER.warn("ASP.NET core version is " + aspnetCoreVersion.getOptValue() + " so switching to old style endpoint routing.");
+ LOGGER.warn("ASP.NET core version is {} so switching to old style endpoint routing.", aspnetCoreVersion.getOptValue());
useDefaultRouting = false;
additionalProperties.put(USE_DEFAULT_ROUTING, useDefaultRouting);
} else {
@@ -735,12 +740,12 @@ private void setSwashbuckleVersion() {
setCliOption(swashbuckleVersion);
if (aspnetCoreVersion.getOptValue().startsWith("3.") || aspnetCoreVersion.getOptValue().startsWith("5.")) {
- LOGGER.warn("ASP.NET core version is " + aspnetCoreVersion.getOptValue() + " so changing default Swashbuckle version to 5.0.0.");
+ LOGGER.warn("ASP.NET core version is {} so changing default Swashbuckle version to 5.0.0.", aspnetCoreVersion.getOptValue());
swashbuckleVersion.setOptValue("5.0.0");
additionalProperties.put(SWASHBUCKLE_VERSION, swashbuckleVersion.getOptValue());
} else {
// default, do nothing
- LOGGER.info("Swashbuckle version: " + swashbuckleVersion.getOptValue());
+ LOGGER.info("Swashbuckle version: {}", swashbuckleVersion.getOptValue());
}
}
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/BashClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/BashClientCodegen.java
index ea212c92f183..214f98ea3b35 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/BashClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/BashClientCodegen.java
@@ -497,7 +497,7 @@ public CodegenParameter fromParameter(Parameter param, Set imports) {
} else if ("pipes".equals(p.collectionFormat)) {
p.vendorExtensions.put("x-codegen-collection-pipes", true);
} else {
- LOGGER.warn("Unsupported collection format in Bash generator: " + p.collectionFormat);
+ LOGGER.warn("Unsupported collection format in Bash generator: {}", p.collectionFormat);
}
}
}
@@ -778,7 +778,7 @@ public void setParameterExampleValue(CodegenParameter p) {
} else if ("array".equalsIgnoreCase(type) || "map".equalsIgnoreCase(type)) {
// skip map/array as it will be handled below
} else {
- LOGGER.warn("Type " + type + " not handled properly in setParameterExampleValue");
+ LOGGER.warn("Type {} not handled properly in setParameterExampleValue", type);
}
if (example == null) {
@@ -802,20 +802,20 @@ public String toOperationId(String operationId) {
// rename to empty_method_name_1 (e.g.) if method name is empty
if (StringUtils.isEmpty(operationId)) {
operationId = camelize("empty_method_name_" + emptyMethodNameCounter++, true);
- LOGGER.warn("Empty method name (operationId) found. Renamed to " + operationId);
+ LOGGER.warn("Empty method name (operationId) found. Renamed to {}", operationId);
return operationId;
}
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
String newOperationId = underscore("call" + camelize(operationId));
- LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId);
+ LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}
// operationId starts with a number
if (operationId.matches("^\\d.*")) {
- LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + underscore(sanitizeName("call_" + operationId)));
+ LOGGER.warn("{} (starting with a number) cannot be used as method name. Renamed to {}", operationId, underscore(sanitizeName("call_" + operationId)));
operationId = "call_" + operationId;
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CLibcurlClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CLibcurlClientCodegen.java
index 78c6e2507e55..4c7a0c741609 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CLibcurlClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CLibcurlClientCodegen.java
@@ -519,7 +519,7 @@ public String toExampleValue(Schema schema) {
} else if (ModelUtils.isObjectSchema(schema)) {
return null; // models are managed at moustache level
} else {
- LOGGER.warn("Type " + schema.getType() + " not handled properly in toExampleValue");
+ LOGGER.warn("Type {} not handled properly in toExampleValue", schema.getType());
}
if (ModelUtils.isStringSchema(schema)) {
@@ -593,13 +593,14 @@ public String toModelName(String name) {
// model name cannot use reserved keyword, e.g. return
if (isReservedWord(name)) {
String modelName = camelize("Model" + name);
- LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + modelName);
+ LOGGER.warn("{} (reserved word) cannot be used as model name. Renamed to {}", name, modelName);
return modelName;
}
// model name starts with number
if (name.matches("^\\d.*")) {
- LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + camelize("model_" + name));
+ LOGGER.warn("{} (model name starts with number) cannot be used as model name. Renamed to {}", name,
+ camelize("model_" + name));
name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
}
@@ -719,21 +720,21 @@ public String toOperationId(String operationId) {
// rename to empty_method_name_1 (e.g.) if method name is empty
if (StringUtils.isEmpty(operationId)) {
operationId = camelize("empty_method_name_" + emptyMethodNameCounter++);
- LOGGER.warn("Empty method name (operationId) found. Renamed to " + operationId);
+ LOGGER.warn("Empty method name (operationId) found. Renamed to {}", operationId);
return operationId;
}
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
String newOperationId = camelize(sanitizeName("call_" + operationId), true);
- LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId);
+ LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}
// operationId starts with a number
if (operationId.matches("^\\d.*")) {
String newOperationId = camelize(sanitizeName("call_" + operationId), true);
- LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + newOperationId);
+ LOGGER.warn("{} (starting with a number) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}
@@ -889,7 +890,7 @@ public void postProcessFile(File file, String fileType) {
if (exitValue != 0) {
LOGGER.error("Error running the command ({}). Exit code: {}", command, exitValue);
} else {
- LOGGER.info("Successfully executed: " + command);
+ LOGGER.info("Successfully executed: {}", command);
}
} catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpClientCodegen.java
index 052868899f2c..6f93f3294c90 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpClientCodegen.java
@@ -311,7 +311,7 @@ public void processOpts() {
LOGGER.warn(".NET Standard 1.3 support has been DEPRECATED in this generator. Please use `csharp-netcore` generator instead.");
additionalProperties.put(MCS_NET_VERSION_KEY, "4.6-api");
if (additionalProperties.containsKey("supportsUWP")) {
- LOGGER.warn(".NET " + NETSTANDARD + " generator does not support UWP.");
+ LOGGER.warn(".NET {} generator does not support UWP.", NETSTANDARD);
additionalProperties.remove("supportsUWP");
}
@@ -332,7 +332,7 @@ public void processOpts() {
} else if (NET40.equals(this.targetFramework)) {
additionalProperties.put(MCS_NET_VERSION_KEY, "4");
if (additionalProperties.containsKey(CodegenConstants.SUPPORTS_ASYNC)) {
- LOGGER.warn(".NET " + NET40 + " generator does not support async.");
+ LOGGER.warn(".NET {} generator does not support async.", NET40);
additionalProperties.remove(CodegenConstants.SUPPORTS_ASYNC);
}
@@ -350,13 +350,13 @@ public void processOpts() {
if (additionalProperties.containsKey(CodegenConstants.GENERATE_PROPERTY_CHANGED)) {
if (NET35.equals(targetFramework)) {
- LOGGER.warn(CodegenConstants.GENERATE_PROPERTY_CHANGED + " is only supported by generated code for .NET 4+.");
+ LOGGER.warn("{} is only supported by generated code for .NET 4+.", CodegenConstants.GENERATE_PROPERTY_CHANGED);
additionalProperties.remove(CodegenConstants.GENERATE_PROPERTY_CHANGED);
} else if (NETSTANDARD.equals(targetFramework)) {
- LOGGER.warn(CodegenConstants.GENERATE_PROPERTY_CHANGED + " is not supported in .NET Standard generated code.");
+ LOGGER.warn("{} is not supported in .NET Standard generated code.", CodegenConstants.GENERATE_PROPERTY_CHANGED);
additionalProperties.remove(CodegenConstants.GENERATE_PROPERTY_CHANGED);
} else if (Boolean.TRUE.equals(netCoreProjectFileFlag)) {
- LOGGER.warn(CodegenConstants.GENERATE_PROPERTY_CHANGED + " is not supported in .NET Core csproj project format.");
+ LOGGER.warn("{} is not supported in .NET Core csproj project format.", CodegenConstants.GENERATE_PROPERTY_CHANGED);
additionalProperties.remove(CodegenConstants.GENERATE_PROPERTY_CHANGED);
} else {
setGeneratePropertyChanged(convertPropertyToBooleanAndWriteBack(CodegenConstants.GENERATE_PROPERTY_CHANGED));
@@ -714,7 +714,7 @@ public void postProcessEmitDefaultValue(Map vendorExtensions) {
public void setTargetFramework(String dotnetFramework) {
if (!frameworks.containsKey(dotnetFramework)) {
- LOGGER.warn("Invalid .NET framework version, defaulting to " + this.targetFramework);
+ LOGGER.warn("Invalid .NET framework version, defaulting to {}", this.targetFramework);
} else {
this.targetFramework = dotnetFramework;
}
@@ -758,7 +758,7 @@ public void setTargetFramework(String dotnetFramework) {
break;
}
- LOGGER.info("Generating code for .NET Framework " + this.targetFramework);
+ LOGGER.info("Generating code for .NET Framework {}", this.targetFramework);
}
private CodegenModel reconcileInlineEnums(CodegenModel codegenModel, CodegenModel parentCodegenModel) {
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNancyFXServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNancyFXServerCodegen.java
index 74db8d4ca2de..a99243ab3593 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNancyFXServerCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNancyFXServerCodegen.java
@@ -268,7 +268,7 @@ public Map postProcessAllModels(final Map models
}
private void postProcessParentModels(final Map models) {
- LOGGER.debug("Processing parents: " + parentModels);
+ LOGGER.debug("Processing parents: {}", parentModels);
for (final String parent : parentModels) {
final CodegenModel parentModel = ModelUtils.getModelByName(parent, models);
if (parentModel != null) {
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNetCoreClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNetCoreClientCodegen.java
index 356c6a895b05..2b0a5fe068dc 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNetCoreClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNetCoreClientCodegen.java
@@ -639,7 +639,7 @@ public void processOpts() {
}
if (additionalProperties.containsKey(CodegenConstants.GENERATE_PROPERTY_CHANGED)) {
- LOGGER.warn(CodegenConstants.GENERATE_PROPERTY_CHANGED + " is not supported in the .NET Standard generator.");
+ LOGGER.warn("{} is not supported in the .NET Standard generator.", CodegenConstants.GENERATE_PROPERTY_CHANGED);
additionalProperties.remove(CodegenConstants.GENERATE_PROPERTY_CHANGED);
}
@@ -789,7 +789,7 @@ public void setTargetFramework(String dotnetFramework) {
} else {
this.targetFramework = dotnetFramework;
}
- LOGGER.info("Generating code for .NET Framework " + this.targetFramework);
+ LOGGER.info("Generating code for .NET Framework {}", this.targetFramework);
}
public void setTargetFramework(List strategies) {
@@ -804,7 +804,7 @@ public void setTargetFramework(List strategies) {
}
this.targetFramework = strategies.stream().map(p -> p.name)
.collect(Collectors.joining(";"));
- LOGGER.info("Generating code for .NET Framework " + this.targetFramework);
+ LOGGER.info("Generating code for .NET Framework {}", this.targetFramework);
}
public void setTestTargetFramework(String testTargetFramework) {
@@ -1026,7 +1026,8 @@ protected void configureAdditionalProperties(final Map propertie
properties.put(NET_STANDARD, this.isNetStandard);
if (properties.containsKey(SUPPORTS_UWP)) {
- LOGGER.warn(".NET " + this.name + " generator does not support the UWP option. Use the csharp generator instead.");
+ LOGGER.warn(".NET {} generator does not support the UWP option. Use the csharp generator instead.",
+ this.name);
properties.remove(SUPPORTS_UWP);
}
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CrystalClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CrystalClientCodegen.java
index c092a8b5acdd..65083f706940 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CrystalClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CrystalClientCodegen.java
@@ -363,13 +363,14 @@ public String toModelName(final String name) {
// model name cannot use reserved keyword, e.g. return
if (isReservedWord(modelName)) {
modelName = camelize("Model" + modelName);
- LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + modelName);
+ LOGGER.warn("{} (reserved word) cannot be used as model name. Renamed to {}", name, modelName);
return modelName;
}
// model name starts with number
if (modelName.matches("^\\d.*")) {
- LOGGER.warn(modelName + " (model name starts with number) cannot be used as model name. Renamed to " + camelize("model_" + modelName));
+ LOGGER.warn("{} (model name starts with number) cannot be used as model name. Renamed to {}", modelName,
+ camelize("model_" + modelName));
modelName = "model_" + modelName; // e.g. 200Response => Model200Response (after camelize)
}
@@ -482,20 +483,20 @@ public String toOperationId(String operationId) {
// rename to empty_method_name_1 (e.g.) if method name is empty
if (StringUtils.isEmpty(operationId)) {
operationId = underscore("empty_method_name_" + emptyMethodNameCounter++);
- LOGGER.warn("Empty method name (operationId) found. Renamed to " + operationId);
+ LOGGER.warn("Empty method name (operationId) found. Renamed to {}", operationId);
return operationId;
}
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
String newOperationId = underscore("call_" + operationId);
- LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId);
+ LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}
// operationId starts with a number
if (operationId.matches("^\\d.*")) {
- LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + underscore(sanitizeName("call_" + operationId)));
+ LOGGER.warn("{} (starting with a number) cannot be used as method name. Renamed to {}", operationId, underscore(sanitizeName("call_" + operationId)));
operationId = "call_" + operationId;
}
@@ -881,7 +882,7 @@ public void postProcessFile(File file, String fileType) {
}
LOGGER.error("Error running the command ({}). Exit value: {}, Error output: {}", command, exitValue, sb.toString());
} else {
- LOGGER.info("Successfully executed: " + command);
+ LOGGER.info("Successfully executed: {}", command);
}
} catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartDioNextClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartDioNextClientCodegen.java
index 6b7beaeaea2e..6557d7cad3e7 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartDioNextClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartDioNextClientCodegen.java
@@ -153,7 +153,6 @@ public void processOpts() {
final String srcFolder = libFolder + File.separator + "src";
supportingFiles.add(new SupportingFile("api_client.mustache", srcFolder, "api.dart"));
- supportingFiles.add(new SupportingFile("api_util.mustache", srcFolder, "api_util.dart"));
final String authFolder = srcFolder + File.separator + "auth";
supportingFiles.add(new SupportingFile("auth/api_key_auth.mustache", authFolder, "api_key_auth.dart"));
@@ -177,6 +176,7 @@ private void configureSerializationLibrary(String srcFolder) {
private void configureSerializationLibraryBuiltValue(String srcFolder) {
supportingFiles.add(new SupportingFile("serialization/built_value/serializers.mustache", srcFolder, "serializers.dart"));
+ supportingFiles.add(new SupportingFile("serialization/built_value/api_util.mustache", srcFolder, "api_util.dart"));
typeMapping.put("Array", "BuiltList");
typeMapping.put("array", "BuiltList");
@@ -339,7 +339,7 @@ public Map postProcessOperationsWithModels(Map o
}
resultImports.addAll(rewriteImports(op.imports, false));
- if (op.getHasFormParams()) {
+ if (op.getHasFormParams() || op.getHasQueryParams()) {
resultImports.add("package:" + pubName + "/src/api_util.dart");
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElixirClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElixirClientCodegen.java
index 51ce18efe45a..78c1235c9df6 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElixirClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElixirClientCodegen.java
@@ -449,13 +449,14 @@ public String toModelFilename(String name) {
// model name cannot use reserved keyword, e.g. return
if (isReservedWord(name)) {
- LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + ("model_" + name));
+ LOGGER.warn("{} (reserved word) cannot be used as model name. Renamed to {}", name, "model_" + name);
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
}
// model name starts with number
if (name.matches("^\\d.*")) {
- LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + ("model_" + name));
+ LOGGER.warn("{} (model name starts with number) cannot be used as model name. Renamed to {}", name,
+ "model_" + name);
name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
}
@@ -471,13 +472,13 @@ public String toOperationId(String operationId) {
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
- LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + underscore(sanitizeName("call_" + operationId)));
+ LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, underscore(sanitizeName("call_" + operationId)));
return underscore(sanitizeName("call_" + operationId));
}
// operationId starts with a number
if (operationId.matches("^\\d.*")) {
- LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + underscore(sanitizeName("call_" + operationId)));
+ LOGGER.warn("{} (starting with a number) cannot be used as method name. Renamed to {}", operationId, underscore(sanitizeName("call_" + operationId)));
operationId = "call_" + operationId;
}
@@ -602,7 +603,7 @@ public String codeMappingKey() {
return code;
}
- LOGGER.warn("Unknown HTTP status code: " + this.code);
+ LOGGER.warn("Unknown HTTP status code: {}", this.code);
return "\"" + code + "\"";
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElmClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElmClientCodegen.java
index e7aaf1a3695e..ba89d67819c3 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElmClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElmClientCodegen.java
@@ -188,7 +188,7 @@ public String toOperationId(String operationId) {
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
String newOperationId = camelize("call_" + operationId, true);
- LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId);
+ LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ErlangClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ErlangClientCodegen.java
index 00013976a9ba..231d1136b772 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ErlangClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ErlangClientCodegen.java
@@ -300,7 +300,7 @@ public String toApiFilename(String name) {
public String toOperationId(String operationId) {
// method name cannot use reserved keyword, e.g. if
if (isReservedWord(operationId)) {
- LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + underscore(sanitizeName("call_" + operationId)).replaceAll("\\.", "_"));
+ LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, underscore(sanitizeName("call_" + operationId)).replaceAll("\\.", "_"));
operationId = "call_" + operationId;
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ErlangProperCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ErlangProperCodegen.java
index 9e9c1186a25b..40947a5e9582 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ErlangProperCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ErlangProperCodegen.java
@@ -359,7 +359,7 @@ public String toApiFilename(String name) {
public String toOperationId(String operationId) {
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
- LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + underscore(sanitizeName("call_" + operationId)).replaceAll("\\.", "_"));
+ LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, underscore(sanitizeName("call_" + operationId)).replaceAll("\\.", "_"));
operationId = "call_" + operationId;
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ErlangServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ErlangServerCodegen.java
index 117a8aed937e..b1cda784a5a8 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ErlangServerCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ErlangServerCodegen.java
@@ -256,7 +256,7 @@ public String toModelName(String name) {
public String toOperationId(String operationId) {
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
- LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + camelize(sanitizeName("call_" + operationId)));
+ LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, camelize(sanitizeName("call_" + operationId)));
operationId = "call_" + operationId;
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/FlashClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/FlashClientCodegen.java
index 89a5a2ae69a2..8f2d6ce052e0 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/FlashClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/FlashClientCodegen.java
@@ -327,7 +327,7 @@ public String toModelName(String name) {
// model name cannot use reserved keyword, e.g. return
if (isReservedWord(name)) {
- LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + camelize("model_" + name));
+ LOGGER.warn("{} (reserved word) cannot be used as model name. Renamed to {}", name, camelize("model_" + name));
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
}
@@ -377,7 +377,7 @@ public String toOperationId(String operationId) {
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
- LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + underscore(sanitizeName("call_" + operationId)));
+ LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, underscore(sanitizeName("call_" + operationId)));
operationId = "call_" + operationId;
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/FsharpGiraffeServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/FsharpGiraffeServerCodegen.java
index b62591c1d0e3..3764f2c4b724 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/FsharpGiraffeServerCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/FsharpGiraffeServerCodegen.java
@@ -262,7 +262,7 @@ protected void processOperation(CodegenOperation operation) {
String original = operation.path;
operation.path = operation.path.replace("?", "/");
if (!original.equals(operation.path)) {
- LOGGER.warn("Normalized " + original + " to " + operation.path + ". Please verify generated source.");
+ LOGGER.warn("Normalized {} to {}. Please verify generated source.", original, operation.path);
}
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellHttpClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellHttpClientCodegen.java
index 8b264bf325f6..497634d1d9f5 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellHttpClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellHttpClientCodegen.java
@@ -655,8 +655,7 @@ public String toInstantiationType(Schema p) {
Schema additionalProperties2 = getAdditionalProperties(p);
String type = additionalProperties2.getType();
if (null == type) {
- LOGGER.error("No Type defined for Additional Schema " + additionalProperties2 + "\n" //
- + "\tIn Schema: " + p);
+ LOGGER.error("No Type defined for Additional Schema {}\n\tIn Schema: {}", additionalProperties2, p);
}
String inner = getSchemaType(additionalProperties2);
return "(Map.Map Text " + inner + ")";
@@ -693,7 +692,7 @@ public void addOperationToGroup(String tag, String resourcePath, Operation opera
counter++;
}
if (!op.operationId.equals(uniqueName)) {
- LOGGER.warn("generated unique operationId `" + uniqueName + "`");
+ LOGGER.warn("generated unique operationId `{}`", uniqueName);
}
op.operationId = uniqueName;
op.operationIdLowerCase = uniqueName.toLowerCase(Locale.ROOT);
@@ -1455,7 +1454,7 @@ public void postProcessFile(File file, String fileType) {
if (exitValue != 0) {
LOGGER.error("Error running the command ({}). Exit value: {}", command, exitValue);
} else {
- LOGGER.info("Successfully executed: " + command);
+ LOGGER.info("Successfully executed: {}", command);
}
} catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellServantCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellServantCodegen.java
index cefd7cebde8c..e19e4d024a27 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellServantCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellServantCodegen.java
@@ -388,7 +388,7 @@ public String getTypeDeclaration(Schema p) {
@Override
public String getSchemaType(Schema p) {
String schemaType = super.getSchemaType(p);
- LOGGER.debug("debugging OpenAPI type: " + p.getType() + ", " + p.getFormat() + " => " + schemaType);
+ LOGGER.debug("debugging OpenAPI type: {}, {} => {}", p.getType(), p.getFormat(), schemaType);
String type = null;
if (typeMapping.containsKey(schemaType)) {
type = typeMapping.get(schemaType);
@@ -411,8 +411,7 @@ public String toInstantiationType(Schema p) {
Schema additionalProperties2 = getAdditionalProperties(p);
String type = additionalProperties2.getType();
if (null == type) {
- LOGGER.error("No Type defined for Additional Property " + additionalProperties2 + "\n" //
- + "\tIn Property: " + p);
+ LOGGER.error("No Type defined for Additional Property {}\n\tIn Property: {}", additionalProperties2, p);
}
String inner = getSchemaType(additionalProperties2);
return "(Map.Map Text " + inner + ")";
@@ -692,7 +691,7 @@ public void postProcessFile(File file, String fileType) {
if (exitValue != 0) {
LOGGER.error("Error running the command ({}). Exit value: {}", command, exitValue);
} else {
- LOGGER.info("Successfully executed: " + command);
+ LOGGER.info("Successfully executed: {}", command);
}
} catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java
index f82aba5b2842..4fa28b3cb5f1 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java
@@ -468,7 +468,7 @@ public void processOpts() {
} else if (REST_ASSURED.equals(getLibrary())) {
if (getSerializationLibrary() == null) {
- LOGGER.info("No serializationLibrary configured, using '" + SERIALIZATION_LIBRARY_GSON + "' as fallback");
+ LOGGER.info("No serializationLibrary configured, using '{}' as fallback", SERIALIZATION_LIBRARY_GSON);
setSerializationLibrary(SERIALIZATION_LIBRARY_GSON);
}
if (SERIALIZATION_LIBRARY_JACKSON.equals(getSerializationLibrary())) {
@@ -496,7 +496,7 @@ public void processOpts() {
supportingFiles.add(new SupportingFile("kumuluzee.beans.xml.mustache", "src/main/resources/META-INF", "beans.xml"));
}
} else {
- LOGGER.error("Unknown library option (-l/--library): " + getLibrary());
+ LOGGER.error("Unknown library option (-l/--library): {}", getLibrary());
}
if (usePlayWS) {
@@ -553,7 +553,7 @@ public void processOpts() {
}
if (getSerializationLibrary() == null) {
- LOGGER.info("No serializationLibrary configured, using '" + SERIALIZATION_LIBRARY_GSON + "' as fallback");
+ LOGGER.info("No serializationLibrary configured, using '{}' as fallback", SERIALIZATION_LIBRARY_GSON);
setSerializationLibrary(SERIALIZATION_LIBRARY_GSON);
}
switch (getSerializationLibrary()) {
@@ -997,7 +997,9 @@ public void setSerializationLibrary(String serializationLibrary) {
public void forceSerializationLibrary(String serializationLibrary) {
if ((this.serializationLibrary != null) && !this.serializationLibrary.equalsIgnoreCase(serializationLibrary)) {
- LOGGER.warn("The configured serializationLibrary '" + this.serializationLibrary + "', is not supported by the library: '" + getLibrary() + "', switching back to: " + serializationLibrary);
+ LOGGER.warn(
+ "The configured serializationLibrary '{}', is not supported by the library: '{}', switching back to: {}",
+ this.serializationLibrary, getLibrary(), serializationLibrary);
}
setSerializationLibrary(serializationLibrary);
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptApolloClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptApolloClientCodegen.java
index 058d544f52a9..3023ff6ab2ee 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptApolloClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptApolloClientCodegen.java
@@ -528,14 +528,15 @@ public String toModelName(String name) {
// model name cannot use reserved keyword, e.g. return
if (isReservedWord(name)) {
String modelName = "Model" + name;
- LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + modelName);
+ LOGGER.warn("{} (reserved word) cannot be used as model name. Renamed to {}", name, modelName);
return modelName;
}
// model name starts with number
if (name.matches("^\\d.*")) {
String modelName = "Model" + name; // e.g. 200Response => Model200Response (after camelize)
- LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + modelName);
+ LOGGER.warn("{} (model name starts with number) cannot be used as model name. Renamed to {}", name,
+ modelName);
return modelName;
}
@@ -780,7 +781,7 @@ public String getSchemaType(Schema p) {
type = openAPIType;
}
if (null == type) {
- LOGGER.error("No Type defined for Schema " + p);
+ LOGGER.error("No Type defined for Schema {}", p);
}
return toModelName(type);
}
@@ -797,14 +798,14 @@ public String toOperationId(String operationId) {
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
String newOperationId = camelize("call_" + operationId, true);
- LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId);
+ LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}
// operationId starts with a number
if (operationId.matches("^\\d.*")) {
String newOperationId = camelize("call_" + operationId, true);
- LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + newOperationId);
+ LOGGER.warn("{} (starting with a number) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}
@@ -1134,7 +1135,7 @@ public void postProcessFile(File file, String fileType) {
if (exitValue != 0) {
LOGGER.error("Error running the command ({}). Exit code: {}", command, exitValue);
}
- LOGGER.info("Successfully executed: " + command);
+ LOGGER.info("Successfully executed: {}", command);
} catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
// Restore interrupted state
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptClientCodegen.java
index 2f7a34e18189..71a93675a0d3 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptClientCodegen.java
@@ -584,14 +584,15 @@ public String toModelName(String name) {
// model name cannot use reserved keyword, e.g. return
if (isReservedWord(name)) {
String modelName = "Model" + name;
- LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + modelName);
+ LOGGER.warn("{} (reserved word) cannot be used as model name. Renamed to {}", name, modelName);
return modelName;
}
// model name starts with number
if (name.matches("^\\d.*")) {
String modelName = "Model" + name; // e.g. 200Response => Model200Response (after camelize)
- LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + modelName);
+ LOGGER.warn("{} (model name starts with number) cannot be used as model name. Renamed to {}", name,
+ modelName);
return modelName;
}
@@ -836,7 +837,7 @@ public String getSchemaType(Schema p) {
type = openAPIType;
}
if (null == type) {
- LOGGER.error("No Type defined for Schema " + p);
+ LOGGER.error("No Type defined for Schema {}", p);
}
return toModelName(type);
}
@@ -853,14 +854,14 @@ public String toOperationId(String operationId) {
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
String newOperationId = camelize("call_" + operationId, true);
- LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId);
+ LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}
// operationId starts with a number
if (operationId.matches("^\\d.*")) {
String newOperationId = camelize("call_" + operationId, true);
- LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + newOperationId);
+ LOGGER.warn("{} (starting with a number) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}
@@ -1219,7 +1220,7 @@ public void postProcessFile(File file, String fileType) {
if (exitValue != 0) {
LOGGER.error("Error running the command ({}). Exit code: {}", command, exitValue);
}
- LOGGER.info("Successfully executed: " + command);
+ LOGGER.info("Successfully executed: {}", command);
} catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
// Restore interrupted state
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptClosureAngularClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptClosureAngularClientCodegen.java
index 751d75e4f217..5b8bf164a60b 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptClosureAngularClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptClosureAngularClientCodegen.java
@@ -203,7 +203,7 @@ public String toModelName(String name) {
// model name cannot use reserved keyword, e.g. return
if (isReservedWord(name)) {
- LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + camelize("model_" + name));
+ LOGGER.warn("{} (reserved word) cannot be used as model name. Renamed to {}", name, camelize("model_" + name));
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
}
@@ -298,7 +298,7 @@ public String toOperationId(String operationId) {
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
String newOperationId = camelize("call_" + operationId, true);
- LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId);
+ LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinServerCodegen.java
index 0c182417c943..c5063d991858 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinServerCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinServerCodegen.java
@@ -189,7 +189,7 @@ public void processOpts() {
if (StringUtils.isEmpty(library)) {
this.setLibrary(DEFAULT_LIBRARY);
additionalProperties.put(CodegenConstants.LIBRARY, DEFAULT_LIBRARY);
- LOGGER.info("`library` option is empty. Default to " + DEFAULT_LIBRARY);
+ LOGGER.info("`library` option is empty. Default to {}", DEFAULT_LIBRARY);
}
if (additionalProperties.containsKey(Constants.AUTOMATIC_HEAD_REQUESTS)) {
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinServerDeprecatedCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinServerDeprecatedCodegen.java
index 84cee1d2aa97..5c5ec533dedf 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinServerDeprecatedCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinServerDeprecatedCodegen.java
@@ -183,7 +183,7 @@ public void processOpts() {
if (StringUtils.isEmpty(library)) {
this.setLibrary(DEFAULT_LIBRARY);
additionalProperties.put(CodegenConstants.LIBRARY, DEFAULT_LIBRARY);
- LOGGER.info("`library` option is empty. Default to " + DEFAULT_LIBRARY);
+ LOGGER.info("`library` option is empty. Default to {}", DEFAULT_LIBRARY);
}
if (additionalProperties.containsKey(Constants.AUTOMATIC_HEAD_REQUESTS)) {
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java
index cdaae2afe679..4af648fbac4f 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java
@@ -303,7 +303,7 @@ public void processOpts() {
this.setBasePackage((String) additionalProperties.get(CodegenConstants.INVOKER_PACKAGE));
this.setInvokerPackage((String) additionalProperties.get(CodegenConstants.INVOKER_PACKAGE));
additionalProperties.put(BASE_PACKAGE, basePackage);
- LOGGER.info("Set base package to invoker package (" + basePackage + ")");
+ LOGGER.info("Set base package to invoker package ({})", basePackage);
}
if (additionalProperties.containsKey(BASE_PACKAGE)) {
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KtormSchemaCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KtormSchemaCodegen.java
index 979d6e34207f..043b4d64cc42 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KtormSchemaCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KtormSchemaCodegen.java
@@ -301,7 +301,7 @@ public Map postProcessModels(Map objs) {
if (modelVendorExtensions.containsKey(VENDOR_EXTENSION_SCHEMA)) {
// user already specified schema values
- LOGGER.info("Found vendor extension in '" + modelName + "' model, autogeneration skipped");
+ LOGGER.info("Found vendor extension in '{}' model, autogeneration skipped", modelName);
} else {
modelVendorExtensions.put(VENDOR_EXTENSION_SCHEMA, ktormSchema);
ktormSchema.put("tableDefinition", tableDefinition);
@@ -359,7 +359,7 @@ public void postProcessModelProperty(CodegenModel model, CodegenProperty propert
if (vendorExtensions.containsKey(VENDOR_EXTENSION_SCHEMA)) {
// user already specified schema values
- LOGGER.info("Found vendor extension in '" + baseName + "' property, autogeneration skipped");
+ LOGGER.info("Found vendor extension in '{}' property, autogeneration skipped", baseName);
return;
}
@@ -688,7 +688,8 @@ public void processNullAndDefault(CodegenModel model, CodegenProperty property,
try {
columnDefinition.put("colDefault", toColumnTypeDefault(defaultValue, dataType, dataFormat));
} catch (RuntimeException exception) {
- LOGGER.warn("Property '" + baseName + "' of model '" + model.getName() + "' mapped to data type which doesn't support default value");
+ LOGGER.warn("Property '{}' of model '{}' mapped to data type which doesn't support default value",
+ baseName, model.getName());
columnDefinition.put("colDefault", null);
}
}
@@ -985,7 +986,7 @@ private Map toColumnTypeDefault(String defaultValue, String data
public String toDatabaseName(String name) {
String identifier = toIdentifier(name, databaseNamePrefix, databaseNameSuffix);
if (identifier.length() > IDENTIFIER_MAX_LENGTH) {
- LOGGER.warn("Database name too long. Name '" + name + "' will be truncated");
+ LOGGER.warn("Database name too long. Name '{}' will be truncated", name);
identifier = identifier.substring(0, IDENTIFIER_MAX_LENGTH);
}
return identifier;
@@ -1004,7 +1005,7 @@ public String toTableName(String name) {
identifier = underscore(identifier);
}
if (identifier.length() > IDENTIFIER_MAX_LENGTH) {
- LOGGER.warn("Table name too long. Name '" + name + "' will be truncated");
+ LOGGER.warn("Table name too long. Name '{}' will be truncated", name);
identifier = identifier.substring(0, IDENTIFIER_MAX_LENGTH);
}
return identifier;
@@ -1023,7 +1024,7 @@ public String toColumnName(String name) {
identifier = underscore(identifier);
}
if (identifier.length() > IDENTIFIER_MAX_LENGTH) {
- LOGGER.warn("Column name too long. Name '" + name + "' will be truncated");
+ LOGGER.warn("Column name too long. Name '{}' will be truncated", name);
identifier = identifier.substring(0, IDENTIFIER_MAX_LENGTH);
}
return identifier;
@@ -1042,13 +1043,13 @@ public String toIdentifier(String name, String prefix, String suffix) {
String escapedName = escapeQuotedIdentifier(name);
// Database, table, and column names cannot end with space characters.
if (escapedName.matches(".*\\s$")) {
- LOGGER.warn("Database, table, and column names cannot end with space characters. Check '" + name + "' name");
+ LOGGER.warn("Database, table, and column names cannot end with space characters. Check '{}' name", name);
escapedName = escapedName.replaceAll("\\s+$", "");
}
// Identifiers may begin with a digit but unless quoted may not consist solely of digits.
if (escapedName.matches("^\\d+$")) {
- LOGGER.warn("Database, table, and column names cannot consist solely of digits. Check '" + name + "' name");
+ LOGGER.warn("Database, table, and column names cannot consist solely of digits. Check '{}' name", name);
escapedName = prefix + escapedName + suffix;
}
@@ -1074,7 +1075,8 @@ public String escapeQuotedIdentifier(String identifier) {
Pattern regexp = Pattern.compile("[^0-9a-zA-z$_\\x0080-\\xFFFF]");
Matcher matcher = regexp.matcher(identifier);
if (matcher.find()) {
- LOGGER.warn("Identifier '" + identifier + "' contains unsafe characters out of [0-9,a-z,A-Z$_] and U+0080..U+FFFF range");
+ LOGGER.warn("Identifier '{}' contains unsafe characters out of [0-9,a-z,A-Z$_] and U+0080..U+FFFF range",
+ identifier);
identifier = identifier.replaceAll("[^0-9a-zA-z$_\\x0080-\\xFFFF]", "");
}
return identifier;
@@ -1106,7 +1108,9 @@ public String escapeUnsafeCharacters(String input) {
public void setDefaultDatabaseName(String databaseName) {
String escapedName = toDatabaseName(databaseName);
if (!escapedName.equals(databaseName)) {
- LOGGER.error("Invalid database name. '" + databaseName + "' cannot be used as identifier. Escaped value '" + escapedName + "' will be used instead.");
+ LOGGER.error(
+ "Invalid database name. '{}' cannot be used as identifier. Escaped value '{}' will be used instead.",
+ databaseName, escapedName);
}
this.defaultDatabaseName = escapedName;
}
@@ -1152,7 +1156,8 @@ public void setIdentifierNamingConvention(String naming) {
this.identifierNamingConvention = naming;
break;
default:
- LOGGER.warn("\"" + naming + "\" is invalid \"identifierNamingConvention\" argument. Current \"" + this.identifierNamingConvention + "\" used instead.");
+ LOGGER.warn("\"{}\" is invalid \"identifierNamingConvention\" argument. Current \"{}\" used instead.",
+ naming, this.identifierNamingConvention);
}
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/LuaClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/LuaClientCodegen.java
index 819dcf6bf440..41aae956c97c 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/LuaClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/LuaClientCodegen.java
@@ -281,13 +281,14 @@ public String toModelFilename(String name) {
// model name cannot use reserved keyword, e.g. return
if (isReservedWord(name)) {
- LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + ("model_" + name));
+ LOGGER.warn("{} (reserved word) cannot be used as model name. Renamed to {}", name, "model_" + name);
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
}
// model name starts with number
if (name.matches("^\\d.*")) {
- LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + ("model_" + name));
+ LOGGER.warn("{} (model name starts with number) cannot be used as model name. Renamed to {}", name,
+ "model_" + name);
name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
}
@@ -409,7 +410,7 @@ public String toOperationId(String operationId) {
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(sanitizedOperationId)) {
- LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + underscore("call_" + operationId));
+ LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, underscore("call_" + operationId));
sanitizedOperationId = "call_" + sanitizedOperationId;
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/MysqlSchemaCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/MysqlSchemaCodegen.java
index abc3b4e657ee..fa217e1635fa 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/MysqlSchemaCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/MysqlSchemaCodegen.java
@@ -274,7 +274,7 @@ public Map postProcessModels(Map objs) {
if (modelVendorExtensions.containsKey(VENDOR_EXTENSION_MYSQL_SCHEMA)) {
// user already specified schema values
- LOGGER.info("Found vendor extension in '" + modelName + "' model, autogeneration skipped");
+ LOGGER.info("Found vendor extension in '{}' model, autogeneration skipped", modelName);
} else {
modelVendorExtensions.put(VENDOR_EXTENSION_MYSQL_SCHEMA, mysqlSchema);
mysqlSchema.put("tableDefinition", tableDefinition);
@@ -345,7 +345,7 @@ public void processIntegerTypeProperty(CodegenModel model, CodegenProperty prope
if (vendorExtensions.containsKey(VENDOR_EXTENSION_MYSQL_SCHEMA)) {
// user already specified schema values
- LOGGER.info("Found vendor extension in '" + baseName + "' property, autogeneration skipped");
+ LOGGER.info("Found vendor extension in '{}' property, autogeneration skipped", baseName);
return;
}
@@ -364,7 +364,9 @@ public void processIntegerTypeProperty(CodegenModel model, CodegenProperty prope
List enumValues = (List) allowableValues.get("values");
for (int i = 0; i < enumValues.size(); i++) {
if (i > ENUM_MAX_ELEMENTS - 1) {
- LOGGER.warn("ENUM column can have maximum of " + ENUM_MAX_ELEMENTS.toString() + " distinct elements, following value will be skipped: " + (String) enumValues.get(i));
+ LOGGER.warn(
+ "ENUM column can have maximum of {} distinct elements, following value will be skipped: {}",
+ ENUM_MAX_ELEMENTS.toString(), (String) enumValues.get(i));
break;
}
String value = String.valueOf(enumValues.get(i));
@@ -395,7 +397,9 @@ public void processIntegerTypeProperty(CodegenModel model, CodegenProperty prope
try {
columnDefinition.put("colDefault", toCodegenMysqlDataTypeDefault(defaultValue, (String) columnDefinition.get("colDataType")));
} catch (RuntimeException exception) {
- LOGGER.warn("Property '" + baseName + "' of model '" + model.getName() + "' mapped to MySQL data type which doesn't support default value");
+ LOGGER.warn(
+ "Property '{}' of model '{}' mapped to MySQL data type which doesn't support default value",
+ baseName, model.getName());
columnDefinition.put("colDefault", null);
}
}
@@ -432,7 +436,7 @@ public void processDecimalTypeProperty(CodegenModel model, CodegenProperty prope
if (vendorExtensions.containsKey(VENDOR_EXTENSION_MYSQL_SCHEMA)) {
// user already specified schema values
- LOGGER.info("Found vendor extension in '" + baseName + "' property, autogeneration skipped");
+ LOGGER.info("Found vendor extension in '{}' property, autogeneration skipped", baseName);
return;
}
@@ -451,7 +455,9 @@ public void processDecimalTypeProperty(CodegenModel model, CodegenProperty prope
List enumValues = (List) allowableValues.get("values");
for (int i = 0; i < enumValues.size(); i++) {
if (i > ENUM_MAX_ELEMENTS - 1) {
- LOGGER.warn("ENUM column can have maximum of " + ENUM_MAX_ELEMENTS.toString() + " distinct elements, following value will be skipped: " + (String) enumValues.get(i));
+ LOGGER.warn(
+ "ENUM column can have maximum of {} distinct elements, following value will be skipped: {}",
+ ENUM_MAX_ELEMENTS.toString(), (String) enumValues.get(i));
break;
}
String value = String.valueOf(enumValues.get(i));
@@ -481,7 +487,9 @@ public void processDecimalTypeProperty(CodegenModel model, CodegenProperty prope
try {
columnDefinition.put("colDefault", toCodegenMysqlDataTypeDefault(defaultValue, (String) columnDefinition.get("colDataType")));
} catch (RuntimeException exception) {
- LOGGER.warn("Property '" + baseName + "' of model '" + model.getName() + "' mapped to MySQL data type which doesn't support default value");
+ LOGGER.warn(
+ "Property '{}' of model '{}' mapped to MySQL data type which doesn't support default value",
+ baseName, model.getName());
columnDefinition.put("colDefault", null);
}
}
@@ -510,7 +518,7 @@ public void processBooleanTypeProperty(CodegenModel model, CodegenProperty prope
if (vendorExtensions.containsKey(VENDOR_EXTENSION_MYSQL_SCHEMA)) {
// user already specified schema values
- LOGGER.info("Found vendor extension in '" + baseName + "' property, autogeneration skipped");
+ LOGGER.info("Found vendor extension in '{}' property, autogeneration skipped", baseName);
return;
}
@@ -534,7 +542,9 @@ public void processBooleanTypeProperty(CodegenModel model, CodegenProperty prope
try {
columnDefinition.put("colDefault", toCodegenMysqlDataTypeDefault(defaultValue, (String) columnDefinition.get("colDataType")));
} catch (RuntimeException exception) {
- LOGGER.warn("Property '" + baseName + "' of model '" + model.getName() + "' mapped to MySQL data type which doesn't support default value");
+ LOGGER.warn(
+ "Property '{}' of model '{}' mapped to MySQL data type which doesn't support default value",
+ baseName, model.getName());
columnDefinition.put("colDefault", null);
}
}
@@ -568,7 +578,7 @@ public void processStringTypeProperty(CodegenModel model, CodegenProperty proper
if (vendorExtensions.containsKey(VENDOR_EXTENSION_MYSQL_SCHEMA)) {
// user already specified schema values
- LOGGER.info("Found vendor extension in '" + baseName + "' property, autogeneration skipped");
+ LOGGER.info("Found vendor extension in '{}' property, autogeneration skipped", baseName);
return;
}
@@ -589,7 +599,9 @@ public void processStringTypeProperty(CodegenModel model, CodegenProperty proper
columnDefinition.put("colDataTypeArguments", columnDataTypeArguments);
for (int i = 0; i < enumValues.size(); i++) {
if (i > ENUM_MAX_ELEMENTS - 1) {
- LOGGER.warn("ENUM column can have maximum of " + ENUM_MAX_ELEMENTS.toString() + " distinct elements, following value will be skipped: " + (String) enumValues.get(i));
+ LOGGER.warn(
+ "ENUM column can have maximum of {} distinct elements, following value will be skipped: {}",
+ ENUM_MAX_ELEMENTS.toString(), (String) enumValues.get(i));
break;
}
String value = String.valueOf(enumValues.get(i));
@@ -613,7 +625,9 @@ public void processStringTypeProperty(CodegenModel model, CodegenProperty proper
try {
columnDefinition.put("colDefault", toCodegenMysqlDataTypeDefault(defaultValue, (String) columnDefinition.get("colDataType")));
} catch (RuntimeException exception) {
- LOGGER.warn("Property '" + baseName + "' of model '" + model.getName() + "' mapped to MySQL data type which doesn't support default value");
+ LOGGER.warn(
+ "Property '{}' of model '{}' mapped to MySQL data type which doesn't support default value",
+ baseName, model.getName());
columnDefinition.put("colDefault", null);
}
}
@@ -642,7 +656,7 @@ public void processDateTypeProperty(CodegenModel model, CodegenProperty property
if (vendorExtensions.containsKey(VENDOR_EXTENSION_MYSQL_SCHEMA)) {
// user already specified schema values
- LOGGER.info("Found vendor extension in '" + baseName + "' property, autogeneration skipped");
+ LOGGER.info("Found vendor extension in '{}' property, autogeneration skipped", baseName);
return;
}
@@ -664,7 +678,9 @@ public void processDateTypeProperty(CodegenModel model, CodegenProperty property
try {
columnDefinition.put("colDefault", toCodegenMysqlDataTypeDefault(defaultValue, (String) columnDefinition.get("colDataType")));
} catch (RuntimeException exception) {
- LOGGER.warn("Property '" + baseName + "' of model '" + model.getName() + "' mapped to MySQL data type which doesn't support default value");
+ LOGGER.warn(
+ "Property '{}' of model '{}' mapped to MySQL data type which doesn't support default value",
+ baseName, model.getName());
columnDefinition.put("colDefault", null);
}
}
@@ -693,7 +709,7 @@ public void processJsonTypeProperty(CodegenModel model, CodegenProperty property
if (vendorExtensions.containsKey(VENDOR_EXTENSION_MYSQL_SCHEMA)) {
// user already specified schema values
- LOGGER.info("Found vendor extension in '" + baseName + "' property, autogeneration skipped");
+ LOGGER.info("Found vendor extension in '{}' property, autogeneration skipped", baseName);
return;
}
@@ -718,7 +734,9 @@ public void processJsonTypeProperty(CodegenModel model, CodegenProperty property
try {
columnDefinition.put("colDefault", toCodegenMysqlDataTypeDefault(defaultValue, (String) columnDefinition.get("colDataType")));
} catch (RuntimeException exception) {
- LOGGER.warn("Property '" + baseName + "' of model '" + model.getName() + "' mapped to MySQL data type which doesn't support default value");
+ LOGGER.warn(
+ "Property '{}' of model '{}' mapped to MySQL data type which doesn't support default value",
+ baseName, model.getName());
columnDefinition.put("colDefault", null);
}
}
@@ -747,7 +765,7 @@ public void processUnknownTypeProperty(CodegenModel model, CodegenProperty prope
if (vendorExtensions.containsKey(VENDOR_EXTENSION_MYSQL_SCHEMA)) {
// user already specified schema values
- LOGGER.info("Found vendor extension in '" + baseName + "' property, autogeneration skipped");
+ LOGGER.info("Found vendor extension in '{}' property, autogeneration skipped", baseName);
return;
}
@@ -769,7 +787,9 @@ public void processUnknownTypeProperty(CodegenModel model, CodegenProperty prope
try {
columnDefinition.put("colDefault", toCodegenMysqlDataTypeDefault(defaultValue, (String) columnDefinition.get("colDataType")));
} catch (RuntimeException exception) {
- LOGGER.warn("Property '" + baseName + "' of model '" + model.getName() + "' mapped to MySQL data type which doesn't support default value");
+ LOGGER.warn(
+ "Property '{}' of model '{}' mapped to MySQL data type which doesn't support default value",
+ baseName, model.getName());
columnDefinition.put("colDefault", null);
}
}
@@ -803,7 +823,7 @@ public HashMap toCodegenMysqlDataTypeArgument(Object value) {
arg.put("isInteger", false);
arg.put("isNumeric", true);
} else {
- LOGGER.warn("MySQL data type argument can be primitive type only. Class '" + value.getClass() + "' is provided");
+ LOGGER.warn("MySQL data type argument can be primitive type only. Class '{}' is provided", value.getClass());
}
arg.put("argumentValue", value);
return arg;
@@ -987,7 +1007,7 @@ public Boolean isMysqlDataType(String dataType) {
public String toDatabaseName(String name) {
String identifier = toMysqlIdentifier(name, databaseNamePrefix, databaseNameSuffix);
if (identifier.length() > IDENTIFIER_MAX_LENGTH) {
- LOGGER.warn("Database name cannot exceed 64 chars. Name '" + name + "' will be truncated");
+ LOGGER.warn("Database name cannot exceed 64 chars. Name '{}' will be truncated", name);
identifier = identifier.substring(0, IDENTIFIER_MAX_LENGTH);
}
return identifier;
@@ -1006,7 +1026,7 @@ public String toTableName(String name) {
identifier = underscore(identifier);
}
if (identifier.length() > IDENTIFIER_MAX_LENGTH) {
- LOGGER.warn("Table name cannot exceed 64 chars. Name '" + name + "' will be truncated");
+ LOGGER.warn("Table name cannot exceed 64 chars. Name '{}' will be truncated", name);
identifier = identifier.substring(0, IDENTIFIER_MAX_LENGTH);
}
return identifier;
@@ -1025,7 +1045,7 @@ public String toColumnName(String name) {
identifier = underscore(identifier);
}
if (identifier.length() > IDENTIFIER_MAX_LENGTH) {
- LOGGER.warn("Column name cannot exceed 64 chars. Name '" + name + "' will be truncated");
+ LOGGER.warn("Column name cannot exceed 64 chars. Name '{}' will be truncated", name);
identifier = identifier.substring(0, IDENTIFIER_MAX_LENGTH);
}
return identifier;
@@ -1044,13 +1064,13 @@ public String toMysqlIdentifier(String name, String prefix, String suffix) {
String escapedName = escapeMysqlQuotedIdentifier(name);
// Database, table, and column names cannot end with space characters.
if (escapedName.matches(".*\\s$")) {
- LOGGER.warn("Database, table, and column names cannot end with space characters. Check '" + name + "' name");
+ LOGGER.warn("Database, table, and column names cannot end with space characters. Check '{}' name", name);
escapedName = escapedName.replaceAll("\\s+$", "");
}
// Identifiers may begin with a digit but unless quoted may not consist solely of digits.
if (escapedName.matches("^\\d+$")) {
- LOGGER.warn("Database, table, and column names cannot consist solely of digits. Check '" + name + "' name");
+ LOGGER.warn("Database, table, and column names cannot consist solely of digits. Check '{}' name", name);
escapedName = prefix + escapedName + suffix;
}
@@ -1073,7 +1093,8 @@ public String escapeMysqlUnquotedIdentifier(String identifier) {
Pattern regexp = Pattern.compile("[^0-9a-zA-z$_\\u0080-\\uFFFF]");
Matcher matcher = regexp.matcher(identifier);
if (matcher.find()) {
- LOGGER.warn("Identifier '" + identifier + "' contains unsafe characters out of [0-9,a-z,A-Z$_] and U+0080..U+FFFF range");
+ LOGGER.warn("Identifier '{}' contains unsafe characters out of [0-9,a-z,A-Z$_] and U+0080..U+FFFF range",
+ identifier);
identifier = identifier.replaceAll("[^0-9a-zA-z$_\\u0080-\\uFFFF]", "");
}
@@ -1095,7 +1116,8 @@ public String escapeMysqlQuotedIdentifier(String identifier) {
Pattern regexp = Pattern.compile("[^\\u0001-\\u007F\\u0080-\\uFFFF]");
Matcher matcher = regexp.matcher(identifier);
if (matcher.find()) {
- LOGGER.warn("Identifier '" + identifier + "' contains unsafe characters out of U+0001..U+007F and U+0080..U+FFFF range");
+ LOGGER.warn("Identifier '{}' contains unsafe characters out of U+0001..U+007F and U+0080..U+FFFF range",
+ identifier);
identifier = identifier.replaceAll("[^\\u0001-\\u007F\\u0080-\\uFFFF]", "");
}
@@ -1107,7 +1129,9 @@ public String escapeMysqlQuotedIdentifier(String identifier) {
@Override
public String escapeReservedWord(String name) {
- LOGGER.warn("'" + name + "' is MySQL reserved word. Do not use that word or properly escape it with backticks in mustache template");
+ LOGGER.warn(
+ "'{}' is MySQL reserved word. Do not use that word or properly escape it with backticks in mustache template",
+ name);
return name;
}
@@ -1131,7 +1155,9 @@ public String escapeUnsafeCharacters(String input) {
public void setDefaultDatabaseName(String databaseName) {
String escapedName = toDatabaseName(databaseName);
if (!escapedName.equals(databaseName)) {
- LOGGER.error("Invalid database name. '" + databaseName + "' cannot be used as MySQL identifier. Escaped value '" + escapedName + "' will be used instead.");
+ LOGGER.error(
+ "Invalid database name. '{}' cannot be used as MySQL identifier. Escaped value '{}' will be used instead.",
+ databaseName, escapedName);
}
this.defaultDatabaseName = escapedName;
}
@@ -1196,7 +1222,8 @@ public void setIdentifierNamingConvention(String naming) {
this.identifierNamingConvention = naming;
break;
default:
- LOGGER.warn("\"" + naming + "\" is invalid \"identifierNamingConvention\" argument. Current \"" + this.identifierNamingConvention + "\" used instead.");
+ LOGGER.warn("\"{}\" is invalid \"identifierNamingConvention\" argument. Current \"{}\" used instead.",
+ naming, this.identifierNamingConvention);
}
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/NimClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/NimClientCodegen.java
index ff07db2ede8f..b5ee1575bd77 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/NimClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/NimClientCodegen.java
@@ -195,7 +195,7 @@ public void processOpts() {
@Override
public String escapeReservedWord(String name) {
- LOGGER.warn("A reserved word \"" + name + "\" is used. Consider renaming the field name");
+ LOGGER.warn("A reserved word \"{}\" is used. Consider renaming the field name", name);
if (this.reservedWordsMappings().containsKey(name)) {
return this.reservedWordsMappings().get(name);
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/NodeJSExpressServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/NodeJSExpressServerCodegen.java
index 4e6f0a0fb9df..c7edba19de03 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/NodeJSExpressServerCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/NodeJSExpressServerCodegen.java
@@ -445,7 +445,7 @@ public void postProcessFile(File file, String fileType) {
if (exitValue != 0) {
LOGGER.error("Error running the command ({}). Exit code: {}", command, exitValue);
}
- LOGGER.info("Successfully executed: " + command);
+ LOGGER.info("Successfully executed: {}", command);
} catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
// Restore interrupted state
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/OCamlClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/OCamlClientCodegen.java
index 5d46a4af427a..a1a7463937b6 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/OCamlClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/OCamlClientCodegen.java
@@ -530,13 +530,14 @@ public String toModelFilename(String name) {
// model name cannot use reserved keyword, e.g. return
if (isReservedWord(name)) {
- LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + ("model_" + name));
+ LOGGER.warn("{} (reserved word) cannot be used as model name. Renamed to {}", name, "model_" + name);
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
}
// model name starts with number or _
if (name.matches("^\\d.*|^_.*")) {
- LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + ("model_" + name));
+ LOGGER.warn("{} (model name starts with number) cannot be used as model name. Renamed to {}", name,
+ "model_" + name);
name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
}
@@ -578,14 +579,15 @@ public String getTypeDeclaration(Schema p) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
if (inner == null) {
- LOGGER.warn(ap.getName() + "(array property) does not have a proper inner type defined.Default to string");
+ LOGGER.warn("{}(array property) does not have a proper inner type defined.Default to string",
+ ap.getName());
inner = new StringSchema().description("TODO default missing array inner type to string");
}
return getTypeDeclaration(inner) + " list";
} else if (ModelUtils.isMapSchema(p)) {
Schema inner = getAdditionalProperties(p);
if (inner == null) {
- LOGGER.warn(p.getName() + "(map property) does not have a proper inner type defined. Default to string");
+ LOGGER.warn("{}(map property) does not have a proper inner type defined. Default to string", p.getName());
inner = new StringSchema().description("TODO default missing map inner type to string");
}
String prefix = inner.getEnum() != null ? "Enums." : "";
@@ -637,7 +639,7 @@ public String toOperationId(String operationId) {
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(sanitizedOperationId) || sanitizedOperationId.matches("^[0-9].*")) {
- LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + underscore("call_" + operationId));
+ LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, underscore("call_" + operationId));
sanitizedOperationId = "call_" + sanitizedOperationId;
}
@@ -814,7 +816,7 @@ public void postProcessFile(File file, String fileType) {
if (exitValue != 0) {
LOGGER.error("Error running the command ({}). Exit value: {}", command, exitValue);
} else {
- LOGGER.info("Successfully executed: " + command);
+ LOGGER.info("Successfully executed: {}", command);
}
} catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ObjcClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ObjcClientCodegen.java
index e8735b7e380a..7ced61d9f4f9 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ObjcClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ObjcClientCodegen.java
@@ -435,7 +435,8 @@ public boolean isDataTypeBinary(String dataType) {
public String toModelName(String type) {
// model name cannot use reserved keyword
if (reservedWords.contains(type)) {
- LOGGER.warn(type + " (reserved word) cannot be used as model name. Renamed to " + ("model_" + type) + " before further processing");
+ LOGGER.warn("{} (reserved word) cannot be used as model name. Renamed to {} before further processing",
+ type, "model_" + type);
type = "model_" + type; // e.g. return => ModelReturn (after camelize)
}
@@ -614,7 +615,7 @@ public String toOperationId(String operationId) {
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
- LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + camelize(sanitizeName("call_" + operationId), true));
+ LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, camelize(sanitizeName("call_" + operationId), true));
operationId = "call_" + operationId;
}
@@ -765,7 +766,7 @@ public void setParameterExampleValue(CodegenParameter p) {
// e.g. [[SWGPet alloc] init
example = "[[" + type + " alloc] init]";
} else {
- LOGGER.warn("Example value for " + type + " not handled properly in setParameterExampleValue");
+ LOGGER.warn("Example value for {} not handled properly in setParameterExampleValue", type);
}
if (example == null) {
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/OpenAPIGenerator.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/OpenAPIGenerator.java
index 9902ddb0740d..ccd3ff685d61 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/OpenAPIGenerator.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/OpenAPIGenerator.java
@@ -89,7 +89,7 @@ public void processOpenAPI(OpenAPI openAPI) {
try {
String outputFile = outputFolder + File.separator + outputFileName;
FileUtils.writeStringToFile(new File(outputFile), jsonOpenAPI, StandardCharsets.UTF_8);
- LOGGER.info("wrote file to " + outputFile);
+ LOGGER.info("wrote file to {}", outputFile);
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PerlClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PerlClientCodegen.java
index fca307b1f661..b41bb590b361 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PerlClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PerlClientCodegen.java
@@ -336,13 +336,14 @@ public String toModelName(String name) {
// model name cannot use reserved keyword
if (isReservedWord(name)) {
- LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + camelize("model_" + name));
+ LOGGER.warn("{} (reserved word) cannot be used as model name. Renamed to {}", name, camelize("model_" + name));
name = "model_" + name;
}
// model name starts with number
if (name.matches("^\\d.*")) {
- LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + camelize("model_" + name));
+ LOGGER.warn("{} (model name starts with number) cannot be used as model name. Renamed to {}", name,
+ camelize("model_" + name));
name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
}
@@ -409,19 +410,19 @@ public String toOperationId(String operationId) {
//rename to empty_function_name_1 (e.g.) if method name is empty
if (StringUtils.isEmpty(operationId)) {
operationId = underscore("empty_function_name_" + emptyFunctionNameCounter++);
- LOGGER.warn("Empty method name (operationId) found. Renamed to " + operationId);
+ LOGGER.warn("Empty method name (operationId) found. Renamed to {}", operationId);
return operationId;
}
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
- LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + underscore(sanitizeName("call_" + operationId)));
+ LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, underscore(sanitizeName("call_" + operationId)));
return underscore(sanitizeName("call_" + operationId));
}
// operationId starts with a number
if (operationId.matches("^\\d.*")) {
- LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + underscore(sanitizeName("call_" + operationId)));
+ LOGGER.warn("{} (starting with a number) cannot be used as method name. Renamed to {}", operationId, underscore(sanitizeName("call_" + operationId)));
operationId = "call_" + operationId;
}
@@ -620,7 +621,7 @@ public void postProcessFile(File file, String fileType) {
if (exitValue != 0) {
LOGGER.error("Error running the command ({}). Exit code: {}", command, exitValue);
} else {
- LOGGER.info("Successfully executed: " + command);
+ LOGGER.info("Successfully executed: {}", command);
}
} catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpSlim4ServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpSlim4ServerCodegen.java
index 9105a4fe8de4..23a9de743378 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpSlim4ServerCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpSlim4ServerCodegen.java
@@ -195,7 +195,9 @@ public void processOpts() {
additionalProperties.put("isZendDiactoros", Boolean.TRUE);
break;
default:
- LOGGER.warn("\"" + getPsr7Implementation() + "\" is invalid \"psr7Implementation\" codegen option. Default \"slim-psr7\" used instead.");
+ LOGGER.warn(
+ "\"{}\" is invalid \"psr7Implementation\" codegen option. Default \"slim-psr7\" used instead.",
+ getPsr7Implementation());
additionalProperties.put("isSlimPsr7", Boolean.TRUE);
}
@@ -353,7 +355,8 @@ public void setPsr7Implementation(String psr7Implementation) {
break;
default:
this.psr7Implementation = "slim-psr7";
- LOGGER.warn("\"" + psr7Implementation + "\" is invalid \"psr7Implementation\" argument. Default \"slim-psr7\" used instead.");
+ LOGGER.warn("\"{}\" is invalid \"psr7Implementation\" argument. Default \"slim-psr7\" used instead.",
+ psr7Implementation);
}
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PowerShellClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PowerShellClientCodegen.java
index 0b4add676067..9eda8091fdf3 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PowerShellClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PowerShellClientCodegen.java
@@ -742,11 +742,15 @@ public void processOpts() {
}
if (additionalProperties.containsKey(CodegenConstants.MODEL_PACKAGE)) {
- LOGGER.warn(CodegenConstants.MODEL_PACKAGE + " with " + this.getName() + " generator is ignored. Setting this value independently of " + CodegenConstants.PACKAGE_NAME + " is not currently supported.");
+ LOGGER.warn(
+ "{} with {} generator is ignored. Setting this value independently of {} is not currently supported.",
+ CodegenConstants.MODEL_PACKAGE, this.getName(), CodegenConstants.PACKAGE_NAME);
}
if (additionalProperties.containsKey(CodegenConstants.API_PACKAGE)) {
- LOGGER.warn(CodegenConstants.API_PACKAGE + " with " + this.getName() + " generator is ignored. Setting this value independently of " + CodegenConstants.PACKAGE_NAME + " is not currently supported.");
+ LOGGER.warn(
+ "{} with {} generator is ignored. Setting this value independently of {} is not currently supported.",
+ CodegenConstants.API_PACKAGE, this.getName(), CodegenConstants.PACKAGE_NAME);
}
if (additionalProperties.containsKey(CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT)) {
@@ -887,13 +891,15 @@ public String toModelName(String name) {
// model name cannot use reserved keyword, e.g. return
if (isReservedWord(name)) {
- LOGGER.warn(name + " (reserved word or special variable name) cannot be used as model name. Renamed to " + camelize("model_" + name));
+ LOGGER.warn("{} (reserved word or special variable name) cannot be used as model name. Renamed to {}",
+ name, camelize("model_" + name));
name = camelize("model_" + name); // e.g. return => ModelReturn (after camelize)
}
// model name starts with number
if (name.matches("^\\d.*")) {
- LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + camelize("model_" + name));
+ LOGGER.warn("{} (model name starts with number) cannot be used as model name. Renamed to {}", name,
+ camelize("model_" + name));
name = camelize("model_" + name); // e.g. 200Response => Model200Response (after camelize)
}
@@ -969,7 +975,8 @@ public String toParamName(String name) {
// for param name reserved word or word starting with number, append _
if (paramNameReservedWords.contains(name) || name.matches("^\\d.*")) {
- LOGGER.warn(name + " (reserved word or special variable name) cannot be used in naming. Renamed to " + escapeReservedWord(name));
+ LOGGER.warn("{} (reserved word or special variable name) cannot be used in naming. Renamed to {}", name,
+ escapeReservedWord(name));
name = escapeReservedWord(name);
}
@@ -1100,7 +1107,8 @@ public String toVarName(String name) {
// for reserved word or word starting with number, append _
if (isReservedWord(name) || name.matches("^\\d.*")) {
- LOGGER.warn(name + " (reserved word or special variable name) cannot be used in naming. Renamed to " + escapeReservedWord(name));
+ LOGGER.warn("{} (reserved word or special variable name) cannot be used in naming. Renamed to {}", name,
+ escapeReservedWord(name));
name = escapeReservedWord(name);
}
@@ -1310,7 +1318,7 @@ public void postProcessFile(File file, String fileType) {
if (exitValue != 0) {
LOGGER.error("Error running the command ({}). Exit value: {}", command, exitValue);
} else {
- LOGGER.info("Successfully executed: " + command);
+ LOGGER.info("Successfully executed: {}", command);
}
} catch (InterruptedException | IOException e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ProtobufSchemaCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ProtobufSchemaCodegen.java
index e7bc5b46ef55..02a01627dd68 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ProtobufSchemaCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ProtobufSchemaCodegen.java
@@ -176,7 +176,7 @@ public String toOperationId(String operationId) {
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
- LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + camelize(sanitizeName("call_" + operationId)));
+ LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, camelize(sanitizeName("call_" + operationId)));
operationId = "call_" + operationId;
}
@@ -390,13 +390,14 @@ public String toModelName(String name) {
// model name cannot use reserved keyword, e.g. return
if (isReservedWord(name)) {
- LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + camelize("model_" + name));
+ LOGGER.warn("{} (reserved word) cannot be used as model name. Renamed to {}", name, camelize("model_" + name));
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
}
// model name starts with number
if (name.matches("^\\d.*")) {
- LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + camelize("model_" + name));
+ LOGGER.warn("{} (model name starts with number) cannot be used as model name. Renamed to {}", name,
+ camelize("model_" + name));
name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java
index a00683cbd4a0..5612b1d7b0ee 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java
@@ -163,7 +163,9 @@ public void processOpts() {
// default this to true so the python ModelSimple models will be generated
ModelUtils.setGenerateAliasAsModel(true);
- LOGGER.info(CodegenConstants.GENERATE_ALIAS_AS_MODEL + " is hard coded to true in this generator. Alias models will only be generated if they contain validations or enums");
+ LOGGER.info(
+ "{} is hard coded to true in this generator. Alias models will only be generated if they contain validations or enums",
+ CodegenConstants.GENERATE_ALIAS_AS_MODEL);
Boolean attrNoneIfUnset = false;
if (additionalProperties.containsKey(CodegenConstants.PYTHON_ATTR_NONE_IF_UNSET)) {
@@ -1106,7 +1108,7 @@ private String toExampleValueRecursive(String modelName, Schema schema, Object o
String ref = ModelUtils.getSimpleRef(schema.get$ref());
Schema refSchema = allDefinitions.get(ref);
if (null == refSchema) {
- LOGGER.warn("Unable to find referenced schema " + schema.get$ref() + "\n");
+ LOGGER.warn("Unable to find referenced schema {}\n", schema.get$ref());
return fullPrefix + "None" + closeChars;
}
String refModelName = getModelName(schema);
@@ -1307,7 +1309,7 @@ private String toExampleValueRecursive(String modelName, Schema schema, Object o
}
return fullPrefix + closeChars;
} else {
- LOGGER.warn("Type " + schema.getType() + " not handled properly in toExampleValue");
+ LOGGER.warn("Type {} not handled properly in toExampleValue", schema.getType());
}
return example;
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonFastAPIServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonFastAPIServerCodegen.java
index 5cf315ab1357..6ee1131973e9 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonFastAPIServerCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonFastAPIServerCodegen.java
@@ -150,6 +150,7 @@ public void processOpts() {
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
supportingFiles.add(new SupportingFile("pyproject_toml.mustache", "", "pyproject.toml"));
supportingFiles.add(new SupportingFile("setup_cfg.mustache", "", "setup.cfg"));
+ supportingFiles.add(new SupportingFile(".flake8.mustache", "", ".flake8"));
}
@Override
@@ -284,7 +285,13 @@ public void postProcess() {
System.out.println("# https://opencollective.com/openapi_generator/donate #");
System.out.println("# #");
System.out.println("# This generator's contributed by Nikita Vakula (https://github.com/krjakbrjak)#");
- System.out.println("# Please support his work directly via https://paypal.me/krjakbrjaki \uD83D\uDE4F #");
+ System.out.println("# Please support his work directly via https://paypal.me/krjakbrjak \uD83D\uDE4F #");
System.out.println("################################################################################");
}
+
+ @Override
+ public String toRegularExpression(String pattern) {
+ String regex = super.toRegularExpression(pattern);
+ return StringUtils.substring(regex, 1, -1);
+ }
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RClientCodegen.java
index df86492ffbd8..1d441a98b2f8 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RClientCodegen.java
@@ -306,13 +306,14 @@ public String toModelName(String name) {
// model name cannot use reserved keyword, e.g. return
if (isReservedWord(name)) {
- LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + camelize("model_" + name));
+ LOGGER.warn("{} (reserved word) cannot be used as model name. Renamed to {}", name, camelize("model_" + name));
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
}
// model name starts with number
if (name.matches("^\\d.*")) {
- LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + camelize("model_" + name));
+ LOGGER.warn("{} (model name starts with number) cannot be used as model name. Renamed to {}", name,
+ camelize("model_" + name));
name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
}
@@ -402,7 +403,7 @@ public String toOperationId(String operationId) {
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(sanitizedOperationId)) {
- LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + underscore("call_" + operationId));
+ LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, underscore("call_" + operationId));
sanitizedOperationId = "call_" + sanitizedOperationId;
}
@@ -716,7 +717,7 @@ public String constructExampleCode(CodegenParameter codegenParameter, HashMap Model200Response (after camelize)
}
@@ -495,20 +496,20 @@ public String toOperationId(String operationId) {
// rename to empty_method_name_1 (e.g.) if method name is empty
if (StringUtils.isEmpty(operationId)) {
operationId = underscore("empty_method_name_" + emptyMethodNameCounter++);
- LOGGER.warn("Empty method name (operationId) found. Renamed to " + operationId);
+ LOGGER.warn("Empty method name (operationId) found. Renamed to {}", operationId);
return operationId;
}
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
String newOperationId = underscore("call_" + operationId);
- LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId);
+ LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}
// operationId starts with a number
if (operationId.matches("^\\d.*")) {
- LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + underscore(sanitizeName("call_" + operationId)));
+ LOGGER.warn("{} (starting with a number) cannot be used as method name. Renamed to {}", operationId, underscore(sanitizeName("call_" + operationId)));
operationId = "call_" + operationId;
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RubyOnRailsServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RubyOnRailsServerCodegen.java
index 1cc82c8827b1..adcb79dc2f9e 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RubyOnRailsServerCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RubyOnRailsServerCodegen.java
@@ -238,7 +238,7 @@ public String toModelName(String name) {
// model name cannot use reserved keyword, e.g. return
if (isReservedWord(name)) {
String modelName = camelize("Model" + name);
- LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + modelName);
+ LOGGER.warn("{} (reserved word) cannot be used as model name. Renamed to {}", name, modelName);
return modelName;
}
@@ -252,7 +252,7 @@ public String toModelFilename(String name) {
// model name cannot use reserved keyword, e.g. return
if (isReservedWord(name)) {
String filename = underscore("model_" + name);
- LOGGER.warn(name + " (reserved word) cannot be used as model filename. Renamed to " + filename);
+ LOGGER.warn("{} (reserved word) cannot be used as model filename. Renamed to {}", name, filename);
return filename;
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RubySinatraServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RubySinatraServerCodegen.java
index c81426eb0170..1e51a349e0db 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RubySinatraServerCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RubySinatraServerCodegen.java
@@ -132,7 +132,7 @@ public String getSchemaType(Schema p) {
public String toModelName(String name) {
// model name cannot use reserved keyword, e.g. return
if (isReservedWord(name)) {
- LOGGER.warn(name + " (reserved word) cannot be used as model filename. Renamed to " + camelize("model_" + name));
+ LOGGER.warn("{} (reserved word) cannot be used as model filename. Renamed to {}", name, camelize("model_" + name));
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
}
@@ -145,7 +145,7 @@ public String toModelName(String name) {
public String toModelFilename(String name) {
// model name cannot use reserved keyword, e.g. return
if (isReservedWord(name)) {
- LOGGER.warn(name + " (reserved word) cannot be used as model filename. Renamed to " + underscore("model_" + name));
+ LOGGER.warn("{} (reserved word) cannot be used as model filename. Renamed to {}", name, underscore("model_" + name));
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java
index 2aa6d625e037..b6db793d9aef 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java
@@ -406,13 +406,14 @@ public String toModelFilename(String name) {
// model name cannot use reserved keyword, e.g. return
if (isReservedWord(name)) {
- LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + ("model_" + name));
+ LOGGER.warn("{} (reserved word) cannot be used as model name. Renamed to {}", name, "model_" + name);
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
}
// model name starts with number
if (name.matches("^\\d.*")) {
- LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + ("model_" + name));
+ LOGGER.warn("{} (model name starts with number) cannot be used as model name. Renamed to {}", name,
+ "model_" + name);
name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
}
@@ -454,14 +455,15 @@ public String getTypeDeclaration(Schema p) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
if (inner == null) {
- LOGGER.warn(ap.getName() + "(array property) does not have a proper inner type defined.Default to string");
+ LOGGER.warn("{}(array property) does not have a proper inner type defined.Default to string",
+ ap.getName());
inner = new StringSchema().description("TODO default missing array inner type to string");
}
return "Vec<" + getTypeDeclaration(inner) + ">";
} else if (ModelUtils.isMapSchema(p)) {
Schema inner = getAdditionalProperties(p);
if (inner == null) {
- LOGGER.warn(p.getName() + "(map property) does not have a proper inner type defined. Default to string");
+ LOGGER.warn("{}(map property) does not have a proper inner type defined. Default to string", p.getName());
inner = new StringSchema().description("TODO default missing map inner type to string");
}
return "::std::collections::HashMap";
@@ -502,7 +504,7 @@ public String toOperationId(String operationId) {
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(sanitizedOperationId)) {
- LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + StringUtils.underscore("call_" + operationId));
+ LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, StringUtils.underscore("call_" + operationId));
sanitizedOperationId = "call_" + sanitizedOperationId;
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/Swift5ClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/Swift5ClientCodegen.java
index f06bbd057c61..e8b4ecb4fe80 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/Swift5ClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/Swift5ClientCodegen.java
@@ -70,6 +70,7 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
public static final String MAP_FILE_BINARY_TO_DATA = "mapFileBinaryToData";
protected static final String LIBRARY_ALAMOFIRE = "alamofire";
protected static final String LIBRARY_URLSESSION = "urlsession";
+ protected static final String LIBRARY_VAPOR = "vapor";
protected static final String RESPONSE_LIBRARY_PROMISE_KIT = "PromiseKit";
protected static final String RESPONSE_LIBRARY_RX_SWIFT = "RxSwift";
protected static final String RESPONSE_LIBRARY_RESULT = "Result";
@@ -102,7 +103,7 @@ public Swift5ClientCodegen() {
this.useOneOfInterfaces = true;
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
- .stability(Stability.BETA)
+ .stability(Stability.STABLE)
.build();
outputFolder = "generated-code" + File.separator + "swift";
@@ -297,6 +298,7 @@ public Swift5ClientCodegen() {
supportedLibraries.put(LIBRARY_URLSESSION, "[DEFAULT] HTTP client: URLSession");
supportedLibraries.put(LIBRARY_ALAMOFIRE, "HTTP client: Alamofire");
+ supportedLibraries.put(LIBRARY_VAPOR, "HTTP client: Vapor");
CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, "Library template (sub-template) to use");
libraryOption.setEnum(supportedLibraries);
@@ -499,57 +501,59 @@ public void processOpts() {
additionalProperties.put("apiDocPath", apiDocPath);
additionalProperties.put("modelDocPath", modelDocPath);
- supportingFiles.add(new SupportingFile("Podspec.mustache",
- "",
- projectName + ".podspec"));
- supportingFiles.add(new SupportingFile("Cartfile.mustache",
- "",
- "Cartfile"));
+ if (!getLibrary().equals(LIBRARY_VAPOR)) {
+ supportingFiles.add(new SupportingFile("Podspec.mustache",
+ "",
+ projectName + ".podspec"));
+ supportingFiles.add(new SupportingFile("Cartfile.mustache",
+ "",
+ "Cartfile"));
+ supportingFiles.add(new SupportingFile("CodableHelper.mustache",
+ sourceFolder,
+ "CodableHelper.swift"));
+ supportingFiles.add(new SupportingFile("OpenISO8601DateFormatter.mustache",
+ sourceFolder,
+ "OpenISO8601DateFormatter.swift"));
+ supportingFiles.add(new SupportingFile("JSONDataEncoding.mustache",
+ sourceFolder,
+ "JSONDataEncoding.swift"));
+ supportingFiles.add(new SupportingFile("JSONEncodingHelper.mustache",
+ sourceFolder,
+ "JSONEncodingHelper.swift"));
+ supportingFiles.add(new SupportingFile("git_push.sh.mustache",
+ "",
+ "git_push.sh"));
+ supportingFiles.add(new SupportingFile("SynchronizedDictionary.mustache",
+ sourceFolder,
+ "SynchronizedDictionary.swift"));
+ supportingFiles.add(new SupportingFile("XcodeGen.mustache",
+ "",
+ "project.yml"));
+ supportingFiles.add(new SupportingFile("APIHelper.mustache",
+ sourceFolder,
+ "APIHelper.swift"));
+ supportingFiles.add(new SupportingFile("Models.mustache",
+ sourceFolder,
+ "Models.swift"));
+ }
supportingFiles.add(new SupportingFile("Package.swift.mustache",
"",
"Package.swift"));
- supportingFiles.add(new SupportingFile("APIHelper.mustache",
- sourceFolder,
- "APIHelper.swift"));
supportingFiles.add(new SupportingFile("Configuration.mustache",
sourceFolder,
"Configuration.swift"));
supportingFiles.add(new SupportingFile("Extensions.mustache",
sourceFolder,
"Extensions.swift"));
- supportingFiles.add(new SupportingFile("Models.mustache",
- sourceFolder,
- "Models.swift"));
supportingFiles.add(new SupportingFile("APIs.mustache",
sourceFolder,
"APIs.swift"));
- supportingFiles.add(new SupportingFile("CodableHelper.mustache",
- sourceFolder,
- "CodableHelper.swift"));
- supportingFiles.add(new SupportingFile("OpenISO8601DateFormatter.mustache",
- sourceFolder,
- "OpenISO8601DateFormatter.swift"));
- supportingFiles.add(new SupportingFile("JSONDataEncoding.mustache",
- sourceFolder,
- "JSONDataEncoding.swift"));
- supportingFiles.add(new SupportingFile("JSONEncodingHelper.mustache",
- sourceFolder,
- "JSONEncodingHelper.swift"));
- supportingFiles.add(new SupportingFile("git_push.sh.mustache",
- "",
- "git_push.sh"));
- supportingFiles.add(new SupportingFile("SynchronizedDictionary.mustache",
- sourceFolder,
- "SynchronizedDictionary.swift"));
supportingFiles.add(new SupportingFile("gitignore.mustache",
"",
".gitignore"));
supportingFiles.add(new SupportingFile("README.mustache",
"",
"README.md"));
- supportingFiles.add(new SupportingFile("XcodeGen.mustache",
- "",
- "project.yml"));
switch (getLibrary()) {
case LIBRARY_ALAMOFIRE:
@@ -564,6 +568,9 @@ public void processOpts() {
sourceFolder,
"URLSessionImplementations.swift"));
break;
+ case LIBRARY_VAPOR:
+ additionalProperties.put("useVapor", true);
+ break;
default:
break;
}
diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/modelGeneric.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/modelGeneric.mustache
index 3ecfa611d68b..8dbd9c424e05 100644
--- a/modules/openapi-generator/src/main/resources/csharp-netcore/modelGeneric.mustache
+++ b/modules/openapi-generator/src/main/resources/csharp-netcore/modelGeneric.mustache
@@ -300,6 +300,7 @@
{{/parent}}
{{#vars}}
{{#hasValidation}}
+ {{^isEnum}}
{{#maxLength}}
// {{{name}}} ({{{dataType}}}) maxLength
if(this.{{{name}}} != null && this.{{{name}}}.Length > {{maxLength}})
@@ -343,6 +344,7 @@
{{/isByteArray}}
{{/pattern}}
+ {{/isEnum}}
{{/hasValidation}}
{{/vars}}
yield break;
diff --git a/modules/openapi-generator/src/main/resources/dart/libraries/dio/api.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/api.mustache
index 5182266d24b9..cdfe8be4dd8f 100644
--- a/modules/openapi-generator/src/main/resources/dart/libraries/dio/api.mustache
+++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/api.mustache
@@ -83,14 +83,13 @@ class {{classname}} {
},{{#hasConsumes}}
contentType: '{{#prioritizedContentTypes}}{{#-first}}{{{mediaType}}}{{/-first}}{{/prioritizedContentTypes}}',{{/hasConsumes}}
validateStatus: validateStatus,
- );
+ );{{#hasQueryParams}}
final _queryParameters = {
{{#queryParams}}
- {{^required}}{{^isNullable}}if ({{{paramName}}} != null) {{/isNullable}}{{/required}}r'{{baseName}}': {{paramName}},
+ {{^required}}{{^isNullable}}if ({{{paramName}}} != null) {{/isNullable}}{{/required}}r'{{baseName}}': {{#useBuiltValue}}{{>serialization/built_value/query_param}}{{/useBuiltValue}},
{{/queryParams}}
- };
- {{#hasBodyOrFormParams}}
+ };{{/hasQueryParams}}{{#hasBodyOrFormParams}}
dynamic _bodyData;
@@ -100,20 +99,19 @@ class {{classname}} {
throw DioError(
requestOptions: _options.compose(
_dio.options,
- _path,
- queryParameters: _queryParameters,
+ _path,{{#hasQueryParams}}
+ queryParameters: _queryParameters,{{/hasQueryParams}}
),
type: DioErrorType.other,
error: error,
)..stackTrace = stackTrace;
- }
- {{/hasBodyOrFormParams}}
+ }{{/hasBodyOrFormParams}}
final _response = await _dio.request(
_path,{{#hasBodyOrFormParams}}
data: _bodyData,{{/hasBodyOrFormParams}}
- options: _options,
- queryParameters: _queryParameters,
+ options: _options,{{#hasQueryParams}}
+ queryParameters: _queryParameters,{{/hasQueryParams}}
cancelToken: cancelToken,
onSendProgress: onSendProgress,
onReceiveProgress: onReceiveProgress,
diff --git a/modules/openapi-generator/src/main/resources/dart/libraries/dio/api_util.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/api_util.mustache
deleted file mode 100644
index 4cdc6bcea3c5..000000000000
--- a/modules/openapi-generator/src/main/resources/dart/libraries/dio/api_util.mustache
+++ /dev/null
@@ -1,28 +0,0 @@
-{{>header}}
-import 'dart:convert';
-
-import 'package:built_collection/built_collection.dart';
-import 'package:built_value/serializer.dart';
-
-/// Format the given form parameter object into something that Dio can handle.
-/// Returns primitive or String.
-/// Returns List/Map if the value is BuildList/BuiltMap.
-dynamic encodeFormParameter(Serializers serializers, dynamic value, FullType type) {
- if (value == null) {
- return '';
- }
- if (value is String || value is num || value is bool) {
- return value;
- }
- final serialized = serializers.serialize(
- value as Object,
- specifiedType: type,
- );
- if (serialized is String) {
- return serialized;
- }
- if (value is BuiltList || value is BuiltMap) {
- return serialized;
- }
- return json.encode(serialized);
-}
diff --git a/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/api_util.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/api_util.mustache
new file mode 100644
index 000000000000..fb5ab08aeda0
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/api_util.mustache
@@ -0,0 +1,75 @@
+{{>header}}
+import 'dart:convert';
+import 'dart:typed_data';
+
+import 'package:built_collection/built_collection.dart';
+import 'package:built_value/serializer.dart';
+import 'package:dio/dio.dart';
+import 'package:dio/src/parameter.dart';
+
+/// Format the given form parameter object into something that Dio can handle.
+/// Returns primitive or String.
+/// Returns List/Map if the value is BuildList/BuiltMap.
+dynamic encodeFormParameter(Serializers serializers, dynamic value, FullType type) {
+ if (value == null) {
+ return '';
+ }
+ if (value is String || value is num || value is bool) {
+ return value;
+ }
+ final serialized = serializers.serialize(
+ value as Object,
+ specifiedType: type,
+ );
+ if (serialized is String) {
+ return serialized;
+ }
+ if (value is BuiltList || value is BuiltSet || value is BuiltMap) {
+ return serialized;
+ }
+ return json.encode(serialized);
+}
+
+dynamic encodeQueryParameter(
+ Serializers serializers,
+ dynamic value,
+ FullType type,
+) {
+ if (value == null) {
+ return '';
+ }
+ if (value is String || value is num || value is bool) {
+ return value;
+ }
+ if (value is Uint8List) {
+ // Currently not sure how to serialize this
+ return value;
+ }
+ final serialized = serializers.serialize(
+ value as Object,
+ specifiedType: type,
+ );
+ if (serialized == null) {
+ return '';
+ }
+ if (serialized is String) {
+ return serialized;
+ }
+ return serialized;
+}
+
+ListParam encodeCollectionQueryParameter(
+ Serializers serializers,
+ dynamic value,
+ FullType type, {
+ ListFormat format = ListFormat.multi,
+}) {
+ final serialized = serializers.serialize(
+ value as Object,
+ specifiedType: type,
+ );
+ if (value is BuiltList || value is BuiltSet) {
+ return ListParam(List.of((serialized as Iterable).cast()), format);
+ }
+ throw ArgumentError('Invalid value passed to encodeCollectionQueryParameter');
+}
diff --git a/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/query_param.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/query_param.mustache
new file mode 100644
index 000000000000..3a27e77225e2
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/query_param.mustache
@@ -0,0 +1 @@
+{{#isContainer}}encodeCollectionQueryParameter<{{{baseType}}}>{{/isContainer}}{{^isContainer}}encodeQueryParameter{{/isContainer}}(_serializers, {{{paramName}}}, const FullType({{^isContainer}}{{{dataType}}}){{/isContainer}}{{#isContainer}}Built{{#isMap}}Map{{/isMap}}{{#isArray}}{{#uniqueItems}}Set{{/uniqueItems}}{{^uniqueItems}}List{{/uniqueItems}}{{/isArray}}, [{{#isMap}}FullType(String), {{/isMap}}FullType({{{baseType}}})]), format: ListFormat.{{collectionFormat}}{{/isContainer}})
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/serialize.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/serialize.mustache
index 03d38c93878d..60dcd1773ba0 100644
--- a/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/serialize.mustache
+++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/serialize.mustache
@@ -1,9 +1,18 @@
{{#hasFormParams}}
- _bodyData = {{#isMultipart}}FormData.fromMap({{/isMultipart}}{
+ {{#isMultipart}}
+ _bodyData = FormData.fromMap({
{{#formParams}}
{{^required}}{{^isNullable}}if ({{{paramName}}} != null) {{/isNullable}}{{/required}}r'{{{baseName}}}': {{#isFile}}{{{paramName}}}{{/isFile}}{{^isFile}}encodeFormParameter(_serializers, {{{paramName}}}, const FullType({{^isContainer}}{{{baseType}}}{{/isContainer}}{{#isContainer}}Built{{#isMap}}Map{{/isMap}}{{#isArray}}{{#uniqueItems}}Set{{/uniqueItems}}{{^uniqueItems}}List{{/uniqueItems}}{{/isArray}}, [{{#isMap}}FullType(String), {{/isMap}}FullType({{{baseType}}})]{{/isContainer}})){{/isFile}},
{{/formParams}}
- }{{#isMultipart}}){{/isMultipart}};
+ });
+ {{/isMultipart}}
+ {{^isMultipart}}
+ _bodyData = {
+ {{#formParams}}
+ {{^required}}{{^isNullable}}if ({{{paramName}}} != null) {{/isNullable}}{{/required}}r'{{{baseName}}}': {{>serialization/built_value/query_param}},
+ {{/formParams}}
+ };
+ {{/isMultipart}}
{{/hasFormParams}}
{{#bodyParam}}
{{#isPrimitiveType}}
diff --git a/modules/openapi-generator/src/main/resources/erlang-client/api.mustache b/modules/openapi-generator/src/main/resources/erlang-client/api.mustache
index a2335745bbba..ddb5dee01389 100644
--- a/modules/openapi-generator/src/main/resources/erlang-client/api.mustache
+++ b/modules/openapi-generator/src/main/resources/erlang-client/api.mustache
@@ -3,7 +3,7 @@
-export([{{#operations}}{{#operation}}{{^-first}},
{{/-first}}{{operationId}}/{{arityRequired}}, {{operationId}}/{{arityOptional}}{{/operation}}{{/operations}}]).
--define(BASE_URL, "{{{basePathWithoutHost}}}").
+-define(BASE_URL, <<"{{{basePathWithoutHost}}}">>).
{{#operations}}
{{#operation}}
@@ -21,7 +21,7 @@
Cfg = maps:get(cfg, Optional, application:get_env(kuberl, config, #{})),
Method = {{httpMethod}},
- Path = ["{{{replacedPathName}}}"],
+ Path = [<<"{{{replacedPathName}}}">>],
QS = {{#queryParams.isEmpty}}[]{{/queryParams.isEmpty}}{{^queryParams.isEmpty}}lists:flatten([{{#joinWithComma}}{{#queryParams}}{{#required}}{{#qsEncode}}{{this}}{{/qsEncode}} {{/required}}{{/queryParams}}{{/joinWithComma}}])++{{packageName}}_utils:optional_params([{{#joinWithComma}}{{#queryParams}}{{^required}} '{{baseName}}'{{/required}}{{/queryParams}}{{/joinWithComma}}], _OptionalParams){{/queryParams.isEmpty}},
Headers = {{#headerParams.isEmpty}}[]{{/headerParams.isEmpty}}{{^headerParams.isEmpty}}[{{#headerParams}}{{#required}} {<<"{{baseName}}">>, {{paramName}}}{{/required}}{{/headerParams}}]++{{packageName}}_utils:optional_params([{{#joinWithComma}}{{#headerParams}}{{^required}} '{{baseName}}'{{/required}}{{/headerParams}}{{/joinWithComma}}], _OptionalParams){{/headerParams.isEmpty}},
Body1 = {{^formParams.isEmpty}}{form, [{{#joinWithComma}}{{#formParams}}{{#required}} {<<"{{baseName}}">>, {{paramName}}}{{/required}}{{/formParams}}{{/joinWithComma}}]++{{packageName}}_utils:optional_params([{{#joinWithComma}}{{#formParams}}{{^required}} '{{baseName}}'{{/required}}{{/formParams}}{{/joinWithComma}}], _OptionalParams)}{{/formParams.isEmpty}}{{#formParams.isEmpty}}{{#bodyParams.isEmpty}}[]{{/bodyParams.isEmpty}}{{^bodyParams.isEmpty}}{{#bodyParams}}{{paramName}}{{/bodyParams}}{{/bodyParams.isEmpty}}{{/formParams.isEmpty}},
diff --git a/modules/openapi-generator/src/main/resources/erlang-server/handler.mustache b/modules/openapi-generator/src/main/resources/erlang-server/handler.mustache
index 80314899a382..dc1c47cc20ec 100644
--- a/modules/openapi-generator/src/main/resources/erlang-server/handler.mustache
+++ b/modules/openapi-generator/src/main/resources/erlang-server/handler.mustache
@@ -209,7 +209,7 @@ process_response(Response, Req0, State = #state{operation_id = OperationID}) ->
{stop, Req, State}
end.
--spec handle_request_json(cowboy_req:req(), state()) -> {cowboy_req:resp_body(), cowboy_req:req(), state()}.
+-spec handle_request_json(cowboy_req:req(), state()) -> processed_response().
handle_request_json(
Req0,
@@ -233,7 +233,7 @@ handle_request_json(
Body,
ValidatorState
),
- PreparedBody = jsx:encode(Body),
+ PreparedBody = prepare_body(Code, Body),
Response = {ok, {Code, Headers, PreparedBody}},
process_response(Response, Req1, State);
{error, Reason, Req1} ->
@@ -241,3 +241,8 @@ handle_request_json(
end.
validate_headers(_, Req) -> {true, Req}.
+
+prepare_body(204, Body) when map_size(Body) == 0; length(Body) == 0 ->
+ <<>>;
+prepare_body(_Code, Body) ->
+ jsx:encode(Body).
diff --git a/modules/openapi-generator/src/main/resources/go-server/controller-api.mustache b/modules/openapi-generator/src/main/resources/go-server/controller-api.mustache
index 2c6b5da8b524..0039bf4a69ce 100644
--- a/modules/openapi-generator/src/main/resources/go-server/controller-api.mustache
+++ b/modules/openapi-generator/src/main/resources/go-server/controller-api.mustache
@@ -90,7 +90,7 @@ func (c *{{classname}}Controller) {{nickname}}(w http.ResponseWriter, r *http.Re
}
{{/isInteger}}
{{#isBoolean}}
- {{paramName}}, err := parseBoolParameter(query.Get("{{paramName}}"))
+ {{paramName}}, err := parseBoolParameter(query.Get("{{baseName}}"))
if err != nil {
w.WriteHeader(500)
return
@@ -99,7 +99,7 @@ func (c *{{classname}}Controller) {{nickname}}(w http.ResponseWriter, r *http.Re
{{^isLong}}
{{^isInteger}}
{{^isBoolean}}
- {{paramName}} := {{#isArray}}strings.Split({{/isArray}}query.Get("{{paramName}}"){{#isArray}}, ","){{/isArray}}
+ {{paramName}} := {{#isArray}}strings.Split({{/isArray}}query.Get("{{baseName}}"){{#isArray}}, ","){{/isArray}}
{{/isBoolean}}
{{/isInteger}}
{{/isLong}}
diff --git a/modules/openapi-generator/src/main/resources/powershell/api_client.mustache b/modules/openapi-generator/src/main/resources/powershell/api_client.mustache
index b17371ad1e37..7d45f071b1e6 100644
--- a/modules/openapi-generator/src/main/resources/powershell/api_client.mustache
+++ b/modules/openapi-generator/src/main/resources/powershell/api_client.mustache
@@ -211,6 +211,10 @@ function DeserializeResponse {
[string[]]$ContentTypes
)
+ If ($ContentTypes -eq $null) {
+ $ContentTypes = [string[]]@()
+ }
+
If ([string]::IsNullOrEmpty($ReturnType) -and $ContentTypes.Count -eq 0) { # void response
return $Response
} Elseif ($ReturnType -match '\[\]$') { # array
diff --git a/modules/openapi-generator/src/main/resources/python-fastapi/.flake8.mustache b/modules/openapi-generator/src/main/resources/python-fastapi/.flake8.mustache
new file mode 100644
index 000000000000..9e008c5bb19a
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/python-fastapi/.flake8.mustache
@@ -0,0 +1,3 @@
+[flake8]
+max-line-length = 88
+exclude = .git,__pycache__,__init__.py,.mypy_cache,.pytest_cache,.venv
diff --git a/modules/openapi-generator/src/main/resources/python-fastapi/README.mustache b/modules/openapi-generator/src/main/resources/python-fastapi/README.mustache
index 6528c7920266..ae8428952fdd 100644
--- a/modules/openapi-generator/src/main/resources/python-fastapi/README.mustache
+++ b/modules/openapi-generator/src/main/resources/python-fastapi/README.mustache
@@ -16,9 +16,9 @@ Python >= 3.6
To run the server, please execute the following from the root directory:
-```
- pip3 install -r requirements.txt
- uvicorn main:app --host 0.0.0.0 --port {{serverPort}}
+```bash
+pip3 install -r requirements.txt
+uvicorn main:app --host 0.0.0.0 --port {{serverPort}}
```
and open your browser at `http://localhost:{{serverPort}}/docs/` to see the docs.
@@ -30,3 +30,12 @@ To run the server on a Docker container, please execute the following from the r
```bash
docker-compose up --build
```
+
+## Tests
+
+To run the tests:
+
+```bash
+pip3 install pytest
+PYTHONPATH=src pytest tests
+```
diff --git a/modules/openapi-generator/src/main/resources/python-fastapi/api.mustache b/modules/openapi-generator/src/main/resources/python-fastapi/api.mustache
index 21c091251ad8..04b95fb104a4 100644
--- a/modules/openapi-generator/src/main/resources/python-fastapi/api.mustache
+++ b/modules/openapi-generator/src/main/resources/python-fastapi/api.mustache
@@ -1,8 +1,8 @@
# coding: utf-8
-from typing import Dict, List
+from typing import Dict, List # noqa: F401
-from fastapi import (
+from fastapi import ( # noqa: F401
APIRouter,
Body,
Cookie,
@@ -16,7 +16,7 @@ from fastapi import (
status,
)
-from {{modelPackage}}.extra_models import TokenModel
+from {{modelPackage}}.extra_models import TokenModel # noqa: F401
{{#imports}}
{{import}}
{{/imports}}
@@ -53,7 +53,7 @@ async def {{operationId}}(
),
{{/authMethods}}
{{/hasAuthMethods}}
-) -> {{#returnType}}{{.}}{{/returnType}}{{^returnType}}None{{/returnType}}: # noqa: E501
+) -> {{#returnType}}{{.}}{{/returnType}}{{^returnType}}None{{/returnType}}:
{{#notes}}"""{{.}}"""
...{{/notes}}{{^notes}}...{{/notes}}
{{^-last}}
diff --git a/modules/openapi-generator/src/main/resources/python-fastapi/api_test.mustache b/modules/openapi-generator/src/main/resources/python-fastapi/api_test.mustache
index a3470a2323ee..5a81aa32c604 100644
--- a/modules/openapi-generator/src/main/resources/python-fastapi/api_test.mustache
+++ b/modules/openapi-generator/src/main/resources/python-fastapi/api_test.mustache
@@ -2,10 +2,11 @@
from fastapi.testclient import TestClient
-import json
+{{#vendorExtensions.x-skip-test}}
import pytest
+{{/vendorExtensions.x-skip-test}}
-{{#imports}}{{import}}
+{{#imports}}{{import}} # noqa: F401
{{/imports}}
{{#operations}}
@@ -23,31 +24,31 @@ def test_{{operationId}}(client: TestClient):
{{paramName}} = {{#isContainer}}[{{/isContainer}}{{{example}}}{{#isContainer}}]{{/isContainer}}
{{/bodyParam}}
{{#queryParams}}
- {{#-first}}params = [{{/-first}}{{^-first}} {{/-first}}("{{paramName}}", {{{example}}}){{^-last}},{{/-last}}{{#-last}}]{{/-last}}
- {{/queryParams}}
- headers = { {{#headerParams}}
- '{{paramName}}': {{{example}}},{{/headerParams}}{{#authMethods}}
- {{#isOAuth}}'Authorization': 'Bearer special-key',{{/isOAuth}}{{#isApiKey}}'{{name}}': 'special-key',{{/isApiKey}}{{#isBasicBasic}}'Authorization': 'BasicZm9vOmJhcg==',{{/isBasicBasic}}{{#isBasicBearer}}'Authorization': 'Bearer special-key',{{/isBasicBearer}}{{/authMethods}}
+ {{#-first}}params = [{{/-first}}("{{paramName}}", {{{example}}}){{^-last}}, {{/-last}}{{#-last}}]{{/-last}}{{/queryParams}}
+ headers = {{=<% %>=}}{<%#headerParams%><%={{ }}=%>
+ "{{paramName}}": {{{example}}},{{/headerParams}}{{#authMethods}}
+ {{#isOAuth}}"Authorization": "Bearer special-key",{{/isOAuth}}{{#isApiKey}}"{{name}}": "special-key",{{/isApiKey}}{{#isBasicBasic}}"Authorization": "BasicZm9vOmJhcg==",{{/isBasicBasic}}{{#isBasicBearer}}"Authorization": "Bearer special-key",{{/isBasicBearer}}{{/authMethods}}
}
{{#formParams}}
{{#-first}}
data = {
{{/-first}}
- '{{paramName}}': {{{example}}}{{^-last}},{{/-last}}
+ "{{paramName}}": {{{example}}}{{^-last}},{{/-last}}
{{#-last}}
}
{{/-last}}
{{/formParams}}
response = client.request(
- '{{httpMethod}}',
- '{{{path}}}'{{#pathParams}}{{#-first}}.format({{/-first}}{{baseName}}={{{example}}}{{^-last}}, {{/-last}}{{#-last}}){{/-last}}{{/pathParams}},
+ "{{httpMethod}}",
+ "{{{path}}}"{{#pathParams}}{{#-first}}.format({{/-first}}{{baseName}}={{{example}}}{{^-last}}, {{/-last}}{{#-last}}){{/-last}}{{/pathParams}},
headers=headers,{{#bodyParam}}
json={{paramName}},{{/bodyParam}}{{#formParams}}{{#-first}}
data=data,{{/-first}}{{/formParams}}{{#queryParams}}{{#-first}}
params=params,{{/-first}}{{/queryParams}}
)
- assert response.status_code == 200
+ # uncomment below to assert the status code of the HTTP response
+ #assert response.status_code == 200
{{/operation}}
{{/operations}}
diff --git a/modules/openapi-generator/src/main/resources/python-fastapi/conftest.mustache b/modules/openapi-generator/src/main/resources/python-fastapi/conftest.mustache
index 357ea48c3ab8..e096833deba0 100644
--- a/modules/openapi-generator/src/main/resources/python-fastapi/conftest.mustache
+++ b/modules/openapi-generator/src/main/resources/python-fastapi/conftest.mustache
@@ -1,6 +1,3 @@
-import contextlib
-from typing import Any
-
import pytest
from fastapi import FastAPI
from fastapi.testclient import TestClient
diff --git a/modules/openapi-generator/src/main/resources/python-fastapi/endpoint_argument_definition.mustache b/modules/openapi-generator/src/main/resources/python-fastapi/endpoint_argument_definition.mustache
index 939bfda10a6b..c4bace9973d0 100644
--- a/modules/openapi-generator/src/main/resources/python-fastapi/endpoint_argument_definition.mustache
+++ b/modules/openapi-generator/src/main/resources/python-fastapi/endpoint_argument_definition.mustache
@@ -1 +1 @@
-{{#isPathParam}}{{baseName}}{{/isPathParam}}{{^isPathParam}}{{paramName}}{{/isPathParam}}: {{>param_type}} = {{#isPathParam}}Path{{/isPathParam}}{{#isHeaderParam}}Header{{/isHeaderParam}}{{#isFormParam}}Form{{/isFormParam}}{{#isQueryParam}}Query{{/isQueryParam}}{{#isCookieParam}}Cookie{{/isCookieParam}}{{#isBodyParam}}Body{{/isBodyParam}}(None, description="{{description}}")
+{{#isPathParam}}{{baseName}}{{/isPathParam}}{{^isPathParam}}{{paramName}}{{/isPathParam}}: {{>param_type}} = {{#isPathParam}}Path{{/isPathParam}}{{#isHeaderParam}}Header{{/isHeaderParam}}{{#isFormParam}}Form{{/isFormParam}}{{#isQueryParam}}Query{{/isQueryParam}}{{#isCookieParam}}Cookie{{/isCookieParam}}{{#isBodyParam}}Body{{/isBodyParam}}({{#defaultValue}}{{.}}{{/defaultValue}}{{^defaultValue}}None{{/defaultValue}}, description="{{description}}"{{#isLong}}{{#minimum}}, ge={{minimum}}{{/minimum}}{{#maximum}}, le={{maximum}}{{/maximum}}{{/isLong}}{{#isInteger}}{{#minimum}}, ge={{minimum}}{{/minimum}}{{#maximum}}, le={{maximum}}{{/maximum}}{{/isInteger}}{{#pattern}}, regex=r"{{pattern}}"{{/pattern}}{{#minLength}}, min_length={{minLength}}{{/minLength}}{{#maxLength}}, max_length={{maxLength}}{{/maxLength}})
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/python-fastapi/model.mustache b/modules/openapi-generator/src/main/resources/python-fastapi/model.mustache
index f6a15877fa4f..4c5545e07957 100644
--- a/modules/openapi-generator/src/main/resources/python-fastapi/model.mustache
+++ b/modules/openapi-generator/src/main/resources/python-fastapi/model.mustache
@@ -1,10 +1,11 @@
# coding: utf-8
-from datetime import date, datetime
+from datetime import date, datetime # noqa: F401
-from typing import Dict, List, Optional
+import re # noqa: F401
+from typing import Dict, List, Optional # noqa: F401
-from pydantic import BaseModel, EmailStr, validator
+from pydantic import AnyUrl, BaseModel, EmailStr, validator # noqa: F401
{{#models}}
{{#model}}
{{#pyImports}}
@@ -29,7 +30,44 @@ class {{classname}}(BaseModel):
"""
{{#vars}}
- {{name}}: {{#required}}{{dataType}}{{/required}}{{^required}}Optional[{{dataType}}] = None{{/required}}
+ {{name}}: {{#required}}{{>model_field_type}}{{/required}}{{^required}}Optional[{{>model_field_type}}] = None{{/required}}
+{{/vars}}
+{{#vars}}
+{{#maximum}}
+
+ @validator("{{name}}")
+ def {{name}}_max(cls, value):
+ assert value <= {{maximum}}
+ return value
+{{/maximum}}
+{{#minimum}}
+
+ @validator("{{name}}")
+ def {{name}}_min(cls, value):
+ assert value >= {{minimum}}
+ return value
+{{/minimum}}
+{{#minLength}}
+
+ @validator("{{name}}")
+ def {{name}}_min_length(cls, value):
+ assert len(value) >= {{minLength}}
+ return value
+{{/minLength}}
+{{#maxLength}}
+
+ @validator("{{name}}")
+ def {{name}}_max_length(cls, value):
+ assert len(value) <= {{maxLength}}
+ return value
+{{/maxLength}}
+{{#pattern}}
+
+ @validator("{{name}}")
+ def {{name}}_pattern(cls, value):
+ assert value is not None and re.match(r"{{pattern}}", value)
+ return value
+{{/pattern}}
{{/vars}}
{{/model}}
{{/models}}
diff --git a/modules/openapi-generator/src/main/resources/python-fastapi/model_field_type.mustache b/modules/openapi-generator/src/main/resources/python-fastapi/model_field_type.mustache
new file mode 100644
index 000000000000..c7e36fc47fcc
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/python-fastapi/model_field_type.mustache
@@ -0,0 +1 @@
+{{#isEmail}}EmailStr{{/isEmail}}{{#isUri}}AnyUrl{{/isUri}}{{^isEmail}}{{^isUri}}{{dataType}}{{/isUri}}{{/isEmail}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/python-fastapi/security_api.mustache b/modules/openapi-generator/src/main/resources/python-fastapi/security_api.mustache
index 77bceb11cfa5..4fda1a8f91db 100644
--- a/modules/openapi-generator/src/main/resources/python-fastapi/security_api.mustache
+++ b/modules/openapi-generator/src/main/resources/python-fastapi/security_api.mustache
@@ -2,9 +2,9 @@
from typing import List
-from fastapi import APIRouter, Depends, Response, Security, status
-from fastapi.openapi.models import OAuthFlowImplicit, OAuthFlows
-from fastapi.security import (
+from fastapi import Depends, Security # noqa: F401
+from fastapi.openapi.models import OAuthFlowImplicit, OAuthFlows # noqa: F401
+from fastapi.security import ( # noqa: F401
HTTPAuthorizationCredentials,
HTTPBasic,
HTTPBasicCredentials,
@@ -14,7 +14,7 @@ from fastapi.security import (
OAuth2PasswordBearer,
SecurityScopes,
)
-from fastapi.security.api_key import APIKey, APIKeyCookie, APIKeyHeader, APIKeyQuery
+from fastapi.security.api_key import APIKeyCookie, APIKeyHeader, APIKeyQuery # noqa: F401
from {{modelPackage}}.extra_models import TokenModel
diff --git a/modules/openapi-generator/src/main/resources/swift5/APIHelper.mustache b/modules/openapi-generator/src/main/resources/swift5/APIHelper.mustache
index 94dc810006a6..e535c7df4c44 100644
--- a/modules/openapi-generator/src/main/resources/swift5/APIHelper.mustache
+++ b/modules/openapi-generator/src/main/resources/swift5/APIHelper.mustache
@@ -4,7 +4,8 @@
// https://openapi-generator.tech
//
-import Foundation
+import Foundation{{#useVapor}}
+import Vapor{{/useVapor}}
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} struct APIHelper {
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} static func rejectNil(_ source: [String: Any?]) -> [String: Any]? {
diff --git a/modules/openapi-generator/src/main/resources/swift5/APIs.mustache b/modules/openapi-generator/src/main/resources/swift5/APIs.mustache
index b05f06301797..f931988cf9ff 100644
--- a/modules/openapi-generator/src/main/resources/swift5/APIs.mustache
+++ b/modules/openapi-generator/src/main/resources/swift5/APIs.mustache
@@ -5,18 +5,26 @@
//
import Foundation
+{{#useVapor}}
+import Vapor
+{{/useVapor}}
@available(*, deprecated, renamed: "{{projectName}}")
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} typealias {{projectName}}API = {{projectName}}
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} class {{projectName}} {
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} static var basePath = "{{{basePath}}}"
- {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} static var credential: URLCredential?
- {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} static var customHeaders: [String: String] = [:]{{#useAlamofire}}
+ {{#useVapor}}
+ {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} static var customHeaders: HTTPHeaders = [:]
+ {{/useVapor}}
+ {{^useVapor}}
+ {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} static var customHeaders: [String: String] = [:]
+ {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} static var credential: URLCredential?{{#useAlamofire}}
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} static var requestBuilderFactory: RequestBuilderFactory = AlamofireRequestBuilderFactory(){{/useAlamofire}}{{#useURLSession}}
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} static var requestBuilderFactory: RequestBuilderFactory = URLSessionRequestBuilderFactory(){{/useURLSession}}
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} static var apiResponseQueue: DispatchQueue = .main
-}
+ {{/useVapor}}
+}{{^useVapor}}
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} class RequestBuilder {
var credential: URLCredential?
@@ -63,4 +71,4 @@ import Foundation
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} protocol RequestBuilderFactory {
func getNonDecodableBuilder() -> RequestBuilder.Type
func getBuilder() -> RequestBuilder.Type
-}
+}{{/useVapor}}
diff --git a/modules/openapi-generator/src/main/resources/swift5/Configuration.mustache b/modules/openapi-generator/src/main/resources/swift5/Configuration.mustache
index a154850602e5..d6bbdc0ae264 100644
--- a/modules/openapi-generator/src/main/resources/swift5/Configuration.mustache
+++ b/modules/openapi-generator/src/main/resources/swift5/Configuration.mustache
@@ -4,7 +4,8 @@
// https://openapi-generator.tech
//
-import Foundation
+import Foundation{{#useVapor}}
+import Vapor{{/useVapor}}
{{#swiftUseApiNamespace}}
@available(*, deprecated, renamed: "{{projectName}}.Configuration")
@@ -13,11 +14,15 @@ import Foundation
extension {{projectName}} {
{{/swiftUseApiNamespace}}
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} class Configuration {
+ {{#useVapor}}{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} static var apiClient: Vapor.Client? = nil
+ {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} static var apiWrapper: (inout Vapor.ClientRequest) throws -> () = { _ in }
+ {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} static var contentConfiguration = ContentConfiguration.default(){{/useVapor}}{{^useVapor}}
// This value is used to configure the date formatter that is used to serialize dates into JSON format.
// You must set it prior to encoding any dates, and it will only be read once.
@available(*, unavailable, message: "To set a different date format, use CodableHelper.dateFormatter instead.")
- {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} static var dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ"
+ {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} static var dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ"{{/useVapor}}
}
{{#swiftUseApiNamespace}}
}
+
{{/swiftUseApiNamespace}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/swift5/Extensions.mustache b/modules/openapi-generator/src/main/resources/swift5/Extensions.mustache
index a4d5dd4b3058..e81a205164fd 100644
--- a/modules/openapi-generator/src/main/resources/swift5/Extensions.mustache
+++ b/modules/openapi-generator/src/main/resources/swift5/Extensions.mustache
@@ -8,7 +8,8 @@ import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif{{#usePromiseKit}}
-import PromiseKit{{/usePromiseKit}}
+import PromiseKit{{/usePromiseKit}}{{#useVapor}}
+import Vapor{{/useVapor}}{{^useVapor}}
extension Bool: JSONEncodable {
func encodeToJSON() -> Any { return self as Any }
@@ -94,7 +95,7 @@ extension UUID: JSONEncodable {
func encodeToJSON() -> Any {
return self.uuidString
}
-}{{#generateModelAdditionalProperties}}
+}{{/useVapor}}{{#generateModelAdditionalProperties}}
extension String: CodingKey {
@@ -180,13 +181,13 @@ extension KeyedDecodingContainerProtocol {
return map
}
-}{{/generateModelAdditionalProperties}}
+}{{/generateModelAdditionalProperties}}{{^useVapor}}
extension HTTPURLResponse {
var isStatusCodeSuccessful: Bool {
return Array(200 ..< 300).contains(statusCode)
}
-}{{#usePromiseKit}}
+}{{/useVapor}}{{#usePromiseKit}}
extension RequestBuilder {
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} func execute() -> Promise> {
@@ -201,4 +202,39 @@ extension RequestBuilder {
}
return deferred.promise
}
-}{{/usePromiseKit}}
+}{{/usePromiseKit}}{{#useVapor}}
+
+extension UUID: Content { }
+
+extension URL: Content { }
+
+extension Bool: Content { }
+
+extension Set: ResponseEncodable where Element: Content {
+ public func encodeResponse(for request: Vapor.Request) -> EventLoopFuture {
+ let response = Vapor.Response()
+ do {
+ try response.content.encode(Array(self))
+ } catch {
+ return request.eventLoop.makeFailedFuture(error)
+ }
+ return request.eventLoop.makeSucceededFuture(response)
+ }
+}
+
+extension Set: RequestDecodable where Element: Content {
+ public static func decodeRequest(_ request: Vapor.Request) -> EventLoopFuture {
+ do {
+ let content = try request.content.decode([Element].self)
+ return request.eventLoop.makeSucceededFuture(Set(content))
+ } catch {
+ return request.eventLoop.makeFailedFuture(error)
+ }
+ }
+}
+
+extension Set: Content where Element: Content { }
+
+extension AnyCodable: Content {}
+{{/useVapor}}
+
diff --git a/modules/openapi-generator/src/main/resources/swift5/Package.swift.mustache b/modules/openapi-generator/src/main/resources/swift5/Package.swift.mustache
index 5dc55ffef832..5b106288b3cd 100644
--- a/modules/openapi-generator/src/main/resources/swift5/Package.swift.mustache
+++ b/modules/openapi-generator/src/main/resources/swift5/Package.swift.mustache
@@ -5,10 +5,15 @@ import PackageDescription
let package = Package(
name: "{{projectName}}",
platforms: [
+ {{#useVapor}}
+ .macOS(.v10_15),
+ {{/useVapor}}
+ {{^useVapor}}
.iOS(.v9),
.macOS(.v10_11),
.tvOS(.v9),
.watchOS(.v3),
+ {{/useVapor}}
],
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
@@ -23,6 +28,9 @@ let package = Package(
{{#useAlamofire}}
.package(url: "https://github.com/Alamofire/Alamofire.git", from: "4.9.1"),
{{/useAlamofire}}
+ {{#useVapor}}
+ .package(url: "https://github.com/vapor/vapor.git", from: "4.0.0")
+ {{/useVapor}}
{{#usePromiseKit}}
.package(url: "https://github.com/mxcl/PromiseKit.git", from: "6.15.3"),
{{/usePromiseKit}}
@@ -35,7 +43,7 @@ let package = Package(
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "{{projectName}}",
- dependencies: ["AnyCodable", {{#useAlamofire}}"Alamofire", {{/useAlamofire}}{{#usePromiseKit}}"PromiseKit", {{/usePromiseKit}}{{#useRxSwift}}"RxSwift"{{/useRxSwift}}],
+ dependencies: ["AnyCodable", {{#useVapor}}"Vapor", {{/useVapor}}{{#useAlamofire}}"Alamofire", {{/useAlamofire}}{{#usePromiseKit}}"PromiseKit", {{/usePromiseKit}}{{#useRxSwift}}"RxSwift"{{/useRxSwift}}],
path: "{{#swiftPackagePath}}{{swiftPackagePath}}{{/swiftPackagePath}}{{^swiftPackagePath}}{{#useSPMFileStructure}}Sources/{{projectName}}{{/useSPMFileStructure}}{{^useSPMFileStructure}}{{projectName}}/Classes{{/useSPMFileStructure}}{{/swiftPackagePath}}"
),
]
diff --git a/modules/openapi-generator/src/main/resources/swift5/README.mustache b/modules/openapi-generator/src/main/resources/swift5/README.mustache
index 4e15bc40b0bc..2fc73bcdbc16 100644
--- a/modules/openapi-generator/src/main/resources/swift5/README.mustache
+++ b/modules/openapi-generator/src/main/resources/swift5/README.mustache
@@ -19,6 +19,13 @@ For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
## Installation
+{{#useVapor}}
+Add the following entry in your Package.swift:
+
+> .package(path: "./{{{projectName}}}")
+
+{{/useVapor}}
+{{^useVapor}}
### Carthage
Run `carthage update`
@@ -27,7 +34,7 @@ Run `carthage update`
Run `pod install`
-## Documentation for API Endpoints
+{{/useVapor}}## Documentation for API Endpoints
All URIs are relative to *{{basePath}}*
diff --git a/modules/openapi-generator/src/main/resources/swift5/api.mustache b/modules/openapi-generator/src/main/resources/swift5/api.mustache
index 92643fdf2686..7d84971ab983 100644
--- a/modules/openapi-generator/src/main/resources/swift5/api.mustache
+++ b/modules/openapi-generator/src/main/resources/swift5/api.mustache
@@ -10,21 +10,26 @@ import PromiseKit{{/usePromiseKit}}{{#useRxSwift}}
import RxSwift{{/useRxSwift}}{{#useCombine}}
#if canImport(Combine)
import Combine
-#endif{{/useCombine}}{{#swiftUseApiNamespace}}
+#endif{{/useCombine}}{{#useVapor}}
+import Vapor{{/useVapor}}
+#if canImport(AnyCodable)
+import AnyCodable
+#endif{{#swiftUseApiNamespace}}
extension {{projectName}} {
{{/swiftUseApiNamespace}}
{{#description}}
-/** {{description}} */{{/description}}
+/** {{{description}}} */{{/description}}
{{#objcCompatible}}@objc {{/objcCompatible}}{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} class {{classname}}{{#objcCompatible}} : NSObject{{/objcCompatible}} {
{{#operation}}
+
{{#allParams}}
{{#isEnum}}
/**
* enum for parameter {{paramName}}
*/
- {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} enum {{enumName}}_{{operationId}}: {{^isContainer}}{{{dataType}}}{{/isContainer}}{{#isContainer}}String{{/isContainer}}, CaseIterable {
+ {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} enum {{enumName}}_{{operationId}}: {{^isContainer}}{{{dataType}}}{{/isContainer}}{{#isContainer}}String{{/isContainer}}, CaseIterable{{#useVapor}}, Content{{/useVapor}} {
{{#allowableValues}}
{{#enumVars}}
case {{name}} = {{{value}}}
@@ -34,6 +39,7 @@ extension {{projectName}} {
{{/isEnum}}
{{/allParams}}
+{{^useVapor}}
{{^usePromiseKit}}
{{^useRxSwift}}
{{^useResult}}
@@ -69,6 +75,7 @@ extension {{projectName}} {
{{/useResult}}
{{/useRxSwift}}
{{/usePromiseKit}}
+{{/useVapor}}
{{#usePromiseKit}}
/**
{{#summary}}
@@ -196,6 +203,126 @@ extension {{projectName}} {
}
}
{{/useResult}}
+{{#useVapor}}
+ /**
+ {{#summary}}
+ {{{summary}}}
+ {{/summary}}
+ {{httpMethod}} {{{path}}}{{#notes}}
+ {{{notes}}}{{/notes}}{{#subresourceOperation}}
+ subresourceOperation: {{subresourceOperation}}{{/subresourceOperation}}{{#defaultResponse}}
+ defaultResponse: {{defaultResponse}}{{/defaultResponse}}
+ {{#authMethods}}
+ - {{#isBasic}}BASIC{{/isBasic}}{{#isOAuth}}OAuth{{/isOAuth}}{{#isApiKey}}API Key{{/isApiKey}}:
+ - type: {{type}}{{#keyParamName}} {{keyParamName}} {{#isKeyInQuery}}(QUERY){{/isKeyInQuery}}{{#isKeyInHeaer}}(HEADER){{/isKeyInHeaer}}{{/keyParamName}}
+ - name: {{name}}
+ {{/authMethods}}
+ {{#hasResponseHeaders}}
+ - responseHeaders: [{{#responseHeaders}}{{{baseName}}}({{{dataType}}}){{^-last}}, {{/-last}}{{/responseHeaders}}]
+ {{/hasResponseHeaders}}
+ {{#externalDocs}}
+ - externalDocs: {{externalDocs}}
+ {{/externalDocs}}
+ {{#allParams}}
+ - parameter {{paramName}}: ({{#isFormParam}}form{{/isFormParam}}{{#isQueryParam}}query{{/isQueryParam}}{{#isPathParam}}path{{/isPathParam}}{{#isHeaderParam}}header{{/isHeaderParam}}{{#isBodyParam}}body{{/isBodyParam}}) {{{description}}} {{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}
+ {{/allParams}}
+ - returns: `EventLoopFuture` of `ClientResponse` {{{description}}}
+ */
+ {{#isDeprecated}}
+ @available(*, deprecated, message: "This operation is deprecated.")
+ {{/isDeprecated}}
+ {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} class func {{operationId}}Raw({{#allParams}}{{paramName}}: {{#isEnum}}{{#isArray}}[{{enumName}}_{{operationId}}]{{/isArray}}{{^isArray}}{{#isContainer}}{{{dataType}}}{{/isContainer}}{{^isContainer}}{{{datatypeWithEnum}}}_{{operationId}}{{/isContainer}}{{/isArray}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{^required}}? = nil{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{#hasParams}}, {{/hasParams}}headers: HTTPHeaders = {{projectName}}.customHeaders, beforeSend: (inout ClientRequest) throws -> () = { _ in }) -> EventLoopFuture {
+ {{^pathParams}}let{{/pathParams}}{{#pathParams}}{{#-first}}var{{/-first}}{{/pathParams}} path = "{{{path}}}"{{#pathParams}}
+ let {{paramName}}PreEscape = String(describing: {{#isEnum}}{{paramName}}{{#isContainer}}{{{dataType}}}{{/isContainer}}{{^isContainer}}.rawValue{{/isContainer}}{{/isEnum}}{{^isEnum}}{{paramName}}{{/isEnum}})
+ let {{paramName}}PostEscape = {{paramName}}PreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
+ path = path.replacingOccurrences(of: "{{=<% %>=}}{<%baseName%>}<%={{ }}=%>", with: {{paramName}}PostEscape, options: .literal, range: nil){{/pathParams}}
+ let URLString = {{projectName}}.basePath + path
+
+ guard let apiClient = {{#swiftUseApiNamespace}}{{projectName}}.{{/swiftUseApiNamespace}}Configuration.apiClient else {
+ fatalError("Configuration.apiClient is not set.")
+ }
+
+ return apiClient.send(.{{httpMethod}}, headers: headers, to: URI(string: URLString)) { request in
+ try {{#swiftUseApiNamespace}}{{projectName}}.{{/swiftUseApiNamespace}}Configuration.apiWrapper(&request)
+ {{#hasHeaderParams}}{{#headerParams}}
+ request.headers.add(name: "{{baseName}}", value: {{#isArray}}{{paramName}}{{^required}}?{{/required}}.map { $0{{#isEnum}}.rawValue{{/isEnum}}.description }.description{{/isArray}}{{^isArray}}{{#isEnum}}{{paramName}}{{^required}}?{{/required}}.rawValue.description{{/isEnum}}{{^isEnum}}{{paramName}}{{^required}}?{{/required}}.description{{/isEnum}}{{/isArray}}{{^required}} ?? ""{{/required}})
+ {{/headerParams}}{{/hasHeaderParams}}
+ {{#hasQueryParams}}struct QueryParams: Content {
+ {{#queryParams}}
+ var {{paramName}}: {{#isEnum}}{{#isArray}}[{{enumName}}_{{operationId}}]{{/isArray}}{{^isArray}}{{#isContainer}}{{{dataType}}}{{/isContainer}}{{^isContainer}}{{{datatypeWithEnum}}}_{{operationId}}{{/isContainer}}{{/isArray}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{^required}}?{{/required}}
+ {{/queryParams}}
+ }
+ try request.query.encode(QueryParams({{#queryParams}}{{paramName}}: {{paramName}}{{^-last}}, {{/-last}}{{/queryParams}})){{/hasQueryParams}}
+ {{#hasBodyParam}}
+ {{#bodyParam}}{{#required}}{{#isBinary}}request.body = ByteBuffer(data: {{paramName}}){{/isBinary}}{{^isBinary}}{{#isFile}}request.body = ByteBuffer(data: {{paramName}}){{/isFile}}try request.content.encode({{paramName}}, using: Configuration.contentConfiguration.requireEncoder(for: {{{dataType}}}.defaultContentType)){{/isBinary}}{{/required}}{{^required}}if let body = {{paramName}} {
+
+ {{#isBinary}}request.body = ByteBuffer(data: body){{/isBinary}}{{^isBinary}}{{#isFile}}request.body = ByteBuffer(data: body){{/isFile}}try request.content.encode(body, using: Configuration.contentConfiguration.requireEncoder(for: {{{dataType}}}.defaultContentType)){{/isBinary}}
+ }{{/required}}{{/bodyParam}}
+ {{/hasBodyParam}}
+ {{#hasFormParams}}struct FormParams: Content {
+ static let defaultContentType = Vapor.HTTPMediaType.formData
+ {{#formParams}}
+ var {{paramName}}: {{#isEnum}}{{#isArray}}[{{enumName}}_{{operationId}}]{{/isArray}}{{^isArray}}{{#isContainer}}{{{dataType}}}{{/isContainer}}{{^isContainer}}{{{datatypeWithEnum}}}_{{operationId}}{{/isContainer}}{{/isArray}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{^required}}?{{/required}}
+ {{/formParams}}
+ }
+ try request.content.encode(FormParams({{#formParams}}{{paramName}}: {{paramName}}{{^-last}}, {{/-last}}{{/formParams}}), using: Configuration.contentConfiguration.requireEncoder(for: FormParams.defaultContentType)){{/hasFormParams}}
+ try beforeSend(&request)
+ }
+ }
+
+ {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} enum {{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}} {
+ {{#responses}}
+ case http{{code}}({{#dataType}}value: {{{dataType}}}, {{/dataType}}raw: ClientResponse)
+ {{/responses}}
+ {{^hasDefaultResponse}}
+ case http0(raw: ClientResponse)
+ {{/hasDefaultResponse}}
+ }
+
+ /**
+ {{#summary}}
+ {{{summary}}}
+ {{/summary}}
+ {{httpMethod}} {{{path}}}{{#notes}}
+ {{{notes}}}{{/notes}}{{#subresourceOperation}}
+ subresourceOperation: {{subresourceOperation}}{{/subresourceOperation}}{{#defaultResponse}}
+ defaultResponse: {{defaultResponse}}{{/defaultResponse}}
+ {{#authMethods}}
+ - {{#isBasic}}BASIC{{/isBasic}}{{#isOAuth}}OAuth{{/isOAuth}}{{#isApiKey}}API Key{{/isApiKey}}:
+ - type: {{type}}{{#keyParamName}} {{keyParamName}} {{#isKeyInQuery}}(QUERY){{/isKeyInQuery}}{{#isKeyInHeaer}}(HEADER){{/isKeyInHeaer}}{{/keyParamName}}
+ - name: {{name}}
+ {{/authMethods}}
+ {{#hasResponseHeaders}}
+ - responseHeaders: [{{#responseHeaders}}{{{baseName}}}({{{dataType}}}){{^-last}}, {{/-last}}{{/responseHeaders}}]
+ {{/hasResponseHeaders}}
+ {{#externalDocs}}
+ - externalDocs: {{externalDocs}}
+ {{/externalDocs}}
+ {{#allParams}}
+ - parameter {{paramName}}: ({{#isFormParam}}form{{/isFormParam}}{{#isQueryParam}}query{{/isQueryParam}}{{#isPathParam}}path{{/isPathParam}}{{#isHeaderParam}}header{{/isHeaderParam}}{{#isBodyParam}}body{{/isBodyParam}}) {{{description}}} {{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}
+ {{/allParams}}
+ - returns: `EventLoopFuture` of `{{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}` {{{description}}}
+ */
+ {{#isDeprecated}}
+ @available(*, deprecated, message: "This operation is deprecated.")
+ {{/isDeprecated}}
+ {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} class func {{operationId}}({{#allParams}}{{paramName}}: {{#isEnum}}{{#isArray}}[{{enumName}}_{{operationId}}]{{/isArray}}{{^isArray}}{{#isContainer}}{{{dataType}}}{{/isContainer}}{{^isContainer}}{{{datatypeWithEnum}}}_{{operationId}}{{/isContainer}}{{/isArray}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{^required}}? = nil{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{#hasParams}}, {{/hasParams}}headers: HTTPHeaders = {{projectName}}.customHeaders, beforeSend: (inout ClientRequest) throws -> () = { _ in }) -> EventLoopFuture<{{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}> {
+ return {{operationId}}Raw({{#allParams}}{{paramName}}: {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#hasParams}}, {{/hasParams}}headers: headers, beforeSend: beforeSend).flatMapThrowing { response -> {{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}} in
+ switch response.status.code {
+ {{#responses}}
+ {{#isDefault}}default{{/isDefault}}{{^isDefault}}case {{code}}{{/isDefault}}:
+ return .http{{code}}({{#dataType}}value: {{#isBinary}}Data(buffer: response.body ?? ByteBuffer()){{/isBinary}}{{^isBinary}}{{#isFile}}Data(buffer: response.body ?? ByteBuffer()){{/isFile}}{{^isFile}}try response.content.decode({{{dataType}}}.self, using: Configuration.contentConfiguration.requireDecoder(for: {{{dataType}}}.defaultContentType)){{/isFile}}{{/isBinary}}, {{/dataType}}raw: response)
+ {{/responses}}
+ {{^hasDefaultResponse}}
+ default:
+ return .http0(raw: response)
+ {{/hasDefaultResponse}}
+ }
+ }
+ }
+
+{{/useVapor}}
+{{^useVapor}}
/**
{{#summary}}
@@ -268,7 +395,7 @@ extension {{projectName}} {
return requestBuilder.init(method: "{{httpMethod}}", URLString: (urlComponents?.string ?? URLString), parameters: parameters, headers: headerParameters)
}
-
+{{/useVapor}}
{{/operation}}
}
{{#swiftUseApiNamespace}}
diff --git a/modules/openapi-generator/src/main/resources/swift5/api_doc.mustache b/modules/openapi-generator/src/main/resources/swift5/api_doc.mustache
index f57a93153c66..93b51e32535d 100644
--- a/modules/openapi-generator/src/main/resources/swift5/api_doc.mustache
+++ b/modules/openapi-generator/src/main/resources/swift5/api_doc.mustache
@@ -14,7 +14,9 @@ Method | HTTP request | Description
```swift
{{^usePromiseKit}}
{{^useRxSwift}}
+{{^useVapor}}
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} class func {{operationId}}({{#allParams}}{{paramName}}: {{#isEnum}}{{#isContainer}}{{{dataType}}}{{/isContainer}}{{^isContainer}}{{{datatypeWithEnum}}}_{{operationId}}{{/isContainer}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{^required}}? = nil{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{#hasParams}}, {{/hasParams}}completion: @escaping (_ data: {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}?, _ error: Error?) -> Void)
+{{/useVapor}}
{{/useRxSwift}}
{{/usePromiseKit}}
{{#usePromiseKit}}
@@ -23,6 +25,9 @@ Method | HTTP request | Description
{{#useRxSwift}}
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} class func {{operationId}}({{#allParams}}{{paramName}}: {{#isEnum}}{{#isContainer}}{{{dataType}}}{{/isContainer}}{{^isContainer}}{{{datatypeWithEnum}}}_{{operationId}}{{/isContainer}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{^required}}? = nil{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) -> Observable<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}>
{{/useRxSwift}}
+{{#useVapor}}
+ {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} class func {{operationId}}({{#allParams}}{{paramName}}: {{#isEnum}}{{#isContainer}}{{{dataType}}}{{/isContainer}}{{^isContainer}}{{{datatypeWithEnum}}}_{{operationId}}{{/isContainer}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{^required}}? = nil{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{#hasParams}}, {{/hasParams}}headers: HTTPHeaders = {{projectName}}.customHeaders, beforeSend: (inout ClientRequest) throws -> () = { _ in }) -> EventLoopFuture<{{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}>
+{{/useVapor}}
```
{{{summary}}}{{#notes}}
@@ -39,6 +44,7 @@ import {{{projectName}}}
{{^usePromiseKit}}
{{^useRxSwift}}
+{{^useVapor}}
{{#summary}}
// {{{.}}}
{{/summary}}
@@ -52,6 +58,7 @@ import {{{projectName}}}
dump(response)
}
}
+{{/useVapor}}
{{/useRxSwift}}
{{/usePromiseKit}}
{{#usePromiseKit}}
@@ -69,6 +76,27 @@ import {{{projectName}}}
{{#useRxSwift}}
// TODO RxSwift sample code not yet implemented. To contribute, please open a ticket via http://github.com/OpenAPITools/openapi-generator/issues/new
{{/useRxSwift}}
+{{#useVapor}}
+{{#summary}}
+// {{{.}}}
+{{/summary}}
+{{classname}}.{{{operationId}}}({{#allParams}}{{paramName}}: {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}).whenComplete { result in
+ switch result {
+ case .failure(let error):
+ // process error
+ case .success(let response):
+ switch response {
+ // process decoded response value or raw ClientResponse
+ {{#responses}}
+ case .http{{code}}(let value, let raw):
+ {{/responses}}
+ {{^hasDefaultResponse}}
+ case .http0(let value, let raw):
+ {{/hasDefaultResponse}}
+ }
+ }
+}
+{{/useVapor}}
```
### Parameters
@@ -80,7 +108,23 @@ Name | Type | Description | Notes
### Return type
+{{#useVapor}}
+#### {{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}
+
+```swift
+{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} enum {{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}} {
+ {{#responses}}
+ case http{{code}}(value: {{#dataType}}{{dataType}}?{{/dataType}}{{^dataType}}Void?{{/dataType}}, raw: ClientResponse)
+ {{/responses}}
+ {{^hasDefaultResponse}}
+ case http0(value: {{#returnType}}{{returnType}}?{{/returnType}}{{^returnType}}Void?{{/returnType}}, raw: ClientResponse)
+ {{/hasDefaultResponse}}
+}
+```
+{{/useVapor}}
+{{^useVapor}}
{{#returnType}}{{#returnTypeIsPrimitive}}**{{{returnType}}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{{returnType}}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}Void (empty response body){{/returnType}}
+{{/useVapor}}
### Authorization
diff --git a/modules/openapi-generator/src/main/resources/swift5/model.mustache b/modules/openapi-generator/src/main/resources/swift5/model.mustache
index f9107398cfa3..47df79b7c7d2 100644
--- a/modules/openapi-generator/src/main/resources/swift5/model.mustache
+++ b/modules/openapi-generator/src/main/resources/swift5/model.mustache
@@ -8,7 +8,8 @@
import Foundation
#if canImport(AnyCodable)
import AnyCodable
-#endif
+#endif{{#useVapor}}
+import Vapor{{/useVapor}}
{{#swiftUseApiNamespace}}
@available(*, deprecated, renamed: "{{projectName}}.{{classname}}")
diff --git a/modules/openapi-generator/src/main/resources/swift5/modelEnum.mustache b/modules/openapi-generator/src/main/resources/swift5/modelEnum.mustache
index b10347d63db3..4d868682a1e3 100644
--- a/modules/openapi-generator/src/main/resources/swift5/modelEnum.mustache
+++ b/modules/openapi-generator/src/main/resources/swift5/modelEnum.mustache
@@ -1,7 +1,7 @@
-{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} enum {{classname}}: {{dataType}}, Codable, CaseIterable {
+{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} enum {{classname}}: {{dataType}}, {{#useVapor}}Content, Hashable{{/useVapor}}{{^useVapor}}Codable{{/useVapor}}, CaseIterable {
{{#allowableValues}}
{{#enumVars}}
- case {{name}} = {{{value}}}
+ case {{{name}}} = {{{value}}}
{{/enumVars}}
{{/allowableValues}}
}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/swift5/modelInlineEnumDeclaration.mustache b/modules/openapi-generator/src/main/resources/swift5/modelInlineEnumDeclaration.mustache
index 1c749e0b6cd9..039bae3cb73d 100644
--- a/modules/openapi-generator/src/main/resources/swift5/modelInlineEnumDeclaration.mustache
+++ b/modules/openapi-generator/src/main/resources/swift5/modelInlineEnumDeclaration.mustache
@@ -1,7 +1,7 @@
- {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} enum {{enumName}}: {{^isContainer}}{{dataType}}{{/isContainer}}{{#isContainer}}String{{/isContainer}}, Codable, CaseIterable {
+ {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} enum {{enumName}}: {{^isContainer}}{{dataType}}{{/isContainer}}{{#isContainer}}String{{/isContainer}}, {{#useVapor}}Content, Hashable{{/useVapor}}{{^useVapor}}Codable{{/useVapor}}, CaseIterable {
{{#allowableValues}}
{{#enumVars}}
- case {{name}} = {{{value}}}
+ case {{{name}}} = {{{value}}}
{{/enumVars}}
{{/allowableValues}}
}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/swift5/modelObject.mustache b/modules/openapi-generator/src/main/resources/swift5/modelObject.mustache
index da0d44247fc0..450d95f1f765 100644
--- a/modules/openapi-generator/src/main/resources/swift5/modelObject.mustache
+++ b/modules/openapi-generator/src/main/resources/swift5/modelObject.mustache
@@ -1,4 +1,4 @@
-{{^objcCompatible}}{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} {{#useClasses}}final class{{/useClasses}}{{^useClasses}}struct{{/useClasses}} {{classname}}: Codable{{#vendorExtensions.x-swift-hashable}}, Hashable{{/vendorExtensions.x-swift-hashable}} {
+{{^objcCompatible}}{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} {{#useClasses}}final class{{/useClasses}}{{^useClasses}}struct{{/useClasses}} {{{classname}}}: {{#useVapor}}Content{{/useVapor}}{{^useVapor}}Codable{{/useVapor}}{{#vendorExtensions.x-swift-hashable}}, Hashable{{/vendorExtensions.x-swift-hashable}} {
{{/objcCompatible}}{{#objcCompatible}}@objc {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} class {{classname}}: NSObject, Codable {
{{/objcCompatible}}
@@ -9,12 +9,12 @@
{{/allVars}}
{{#allVars}}
{{#isEnum}}
- {{#description}}/** {{description}} */
+ {{#description}}/** {{{description}}} */
{{/description}}{{#deprecated}}@available(*, deprecated, message: "This property is deprecated.")
{{/deprecated}}{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} {{#readonlyProperties}}private(set) {{/readonlyProperties}}var {{{name}}}: {{{datatypeWithEnum}}}{{#required}}{{#isNullable}}?{{/isNullable}}{{/required}}{{^required}}?{{/required}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}}
{{/isEnum}}
{{^isEnum}}
- {{#description}}/** {{description}} */
+ {{#description}}/** {{{description}}} */
{{/description}}{{#deprecated}}@available(*, deprecated, message: "This property is deprecated.")
{{/deprecated}}{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} {{#readonlyProperties}}private(set) {{/readonlyProperties}}var {{{name}}}: {{{datatype}}}{{#required}}{{#isNullable}}?{{/isNullable}}{{/required}}{{^required}}?{{/required}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}}
{{#objcCompatible}}
@@ -102,4 +102,4 @@
{{/allVars}}
{{#generateModelAdditionalProperties}}{{#additionalPropertiesType}}hasher.combine(additionalProperties.hashValue){{/additionalPropertiesType}}{{/generateModelAdditionalProperties}}
}{{/vendorExtensions.x-swift-hashable}}{{/useClasses}}{{/objcCompatible}}
-}
\ No newline at end of file
+}
diff --git a/modules/openapi-generator/src/main/resources/swift5/modelOneOf.mustache b/modules/openapi-generator/src/main/resources/swift5/modelOneOf.mustache
index 8aeddcc3c123..fae34faa975e 100644
--- a/modules/openapi-generator/src/main/resources/swift5/modelOneOf.mustache
+++ b/modules/openapi-generator/src/main/resources/swift5/modelOneOf.mustache
@@ -1,4 +1,4 @@
-public enum {{classname}}: Codable {
+public enum {{classname}}: {{#useVapor}}Content{{/useVapor}}{{^useVapor}}Codable{{/useVapor}} {
{{#oneOf}}
case type{{.}}({{.}})
{{/oneOf}}
diff --git a/modules/openapi-generator/src/main/resources/typescript-angular/api.service.mustache b/modules/openapi-generator/src/main/resources/typescript-angular/api.service.mustache
index 8f66fcf6f9e9..4fe3186f1adf 100644
--- a/modules/openapi-generator/src/main/resources/typescript-angular/api.service.mustache
+++ b/modules/openapi-generator/src/main/resources/typescript-angular/api.service.mustache
@@ -93,11 +93,16 @@ export class {{classname}} {
{{/hasSomeFormParams}}
private addToHttpParams(httpParams: HttpParams, value: any, key?: string): HttpParams {
+ {{#isQueryParamObjectFormatJson}}
+ httpParams = this.addToHttpParamsRecursive(httpParams, value, key);
+ {{/isQueryParamObjectFormatJson}}
+ {{^isQueryParamObjectFormatJson}}
if (typeof value === "object" && value instanceof Date === false) {
httpParams = this.addToHttpParamsRecursive(httpParams, value);
} else {
httpParams = this.addToHttpParamsRecursive(httpParams, value, key);
}
+ {{/isQueryParamObjectFormatJson}}
return httpParams;
}
diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache
index 8466deb2853e..851b9ce3831e 100644
--- a/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache
+++ b/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache
@@ -167,7 +167,7 @@ export class {{classname}} extends runtime.BaseAPI {
{{#isBasicBearer}}
if (this.configuration && this.configuration.accessToken) {
const token = this.configuration.accessToken;
- const tokenString = typeof token === 'function' ? token("{{name}}", [{{#scopes}}"{{{scope}}}"{{^-last}}, {{/-last}}{{/scopes}}]) : token;
+ const tokenString = await token("{{name}}", [{{#scopes}}"{{{scope}}}"{{^-last}}, {{/-last}}{{/scopes}}]);
if (tokenString) {
headerParameters["Authorization"] = `Bearer ${tokenString}`;
@@ -192,11 +192,7 @@ export class {{classname}} extends runtime.BaseAPI {
{{#isOAuth}}
if (this.configuration && this.configuration.accessToken) {
// oauth required
- if (typeof this.configuration.accessToken === 'function') {
- headerParameters["Authorization"] = this.configuration.accessToken("{{name}}", [{{#scopes}}"{{{scope}}}"{{^-last}}, {{/-last}}{{/scopes}}]);
- } else {
- headerParameters["Authorization"] = this.configuration.accessToken;
- }
+ headerParameters["Authorization"] = await this.configuration.accessToken("{{name}}", [{{#scopes}}"{{{scope}}}"{{^-last}}, {{/-last}}{{/scopes}}]);
}
{{/isOAuth}}
diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache
index d0c29b93a755..e0498e0e316a 100644
--- a/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache
+++ b/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache
@@ -124,7 +124,7 @@ export interface ConfigurationParameters {
username?: string; // parameter for basic security
password?: string; // parameter for basic security
apiKey?: string | ((name: string) => string); // parameter for apiKey security
- accessToken?: string | ((name?: string, scopes?: string[]) => string); // parameter for oauth2 security
+ accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string | Promise); // parameter for oauth2 security
headers?: HTTPHeaders; //header params we want to use on every request
credentials?: RequestCredentials; //value for the credentials param we want to use on each request
}
@@ -164,10 +164,10 @@ export class Configuration {
return undefined;
}
- get accessToken(): ((name: string, scopes?: string[]) => string) | undefined {
+ get accessToken(): ((name?: string, scopes?: string[]) => string | Promise) | undefined {
const accessToken = this.configuration.accessToken;
if (accessToken) {
- return typeof accessToken === 'function' ? accessToken : () => accessToken;
+ return typeof accessToken === 'function' ? accessToken : async () => accessToken;
}
return undefined;
}
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptAngularClientOptionsProvider.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptAngularClientOptionsProvider.java
index eb8d90a468b8..aa67286b9786 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptAngularClientOptionsProvider.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptAngularClientOptionsProvider.java
@@ -34,6 +34,7 @@ public class TypeScriptAngularClientOptionsProvider implements OptionsProvider {
public static final String ENSURE_UNIQUE_PARAMS_VALUE = "true";
public static final String ENUM_PROPERTY_NAMING_VALUE = "PascalCase";
public static final String MODEL_PROPERTY_NAMING_VALUE = "camelCase";
+ public static final String PARAM_NAMING_VALUE = "camelCase";
private static final String NPM_NAME = "npmName";
private static final String NPM_VERSION = "1.1.2";
private static final String NPM_REPOSITORY = "https://registry.npmjs.org";
@@ -63,6 +64,7 @@ public Map createOptions() {
.put(CodegenConstants.ENSURE_UNIQUE_PARAMS, ENSURE_UNIQUE_PARAMS_VALUE)
.put(CodegenConstants.ENUM_PROPERTY_NAMING, ENUM_PROPERTY_NAMING_VALUE)
.put(CodegenConstants.MODEL_PROPERTY_NAMING, MODEL_PROPERTY_NAMING_VALUE)
+ .put(CodegenConstants.PARAM_NAMING, PARAM_NAMING_VALUE)
.put(CodegenConstants.SUPPORTS_ES6, SUPPORTS_ES6_VALUE)
.put(AbstractTypeScriptClientCodegen.NULL_SAFE_ADDITIONAL_PROPS, NULL_SAFE_ADDITIONAL_PROPS_VALUE)
.put(CodegenConstants.ENUM_NAME_SUFFIX, ENUM_NAME_SUFFIX)
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptAngularJsClientOptionsProvider.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptAngularJsClientOptionsProvider.java
index 2c56e0c1268d..1b9c8a58e174 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptAngularJsClientOptionsProvider.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptAngularJsClientOptionsProvider.java
@@ -31,6 +31,7 @@ public class TypeScriptAngularJsClientOptionsProvider implements OptionsProvider
public static final String SORT_MODEL_PROPERTIES_VALUE = "false";
public static final String ENSURE_UNIQUE_PARAMS_VALUE = "true";
public static final String MODEL_PROPERTY_NAMING_VALUE = "camelCase";
+ public static final String PARAM_NAMING_VALUE = "camelCase";
public static final String ENUM_PROPERTY_NAMING_VALUE = "PascalCase";
public static final String ALLOW_UNICODE_IDENTIFIERS_VALUE = "false";
public static final String PREPEND_FORM_OR_BODY_PARAMETERS_VALUE = "true";
@@ -51,6 +52,7 @@ public Map createOptions() {
.put(CodegenConstants.ENSURE_UNIQUE_PARAMS, ENSURE_UNIQUE_PARAMS_VALUE)
.put(CodegenConstants.ENUM_PROPERTY_NAMING, ENUM_PROPERTY_NAMING_VALUE)
.put(CodegenConstants.MODEL_PROPERTY_NAMING, MODEL_PROPERTY_NAMING_VALUE)
+ .put(CodegenConstants.PARAM_NAMING, PARAM_NAMING_VALUE)
.put(CodegenConstants.ALLOW_UNICODE_IDENTIFIERS, ALLOW_UNICODE_IDENTIFIERS_VALUE)
.put(CodegenConstants.PREPEND_FORM_OR_BODY_PARAMETERS, PREPEND_FORM_OR_BODY_PARAMETERS_VALUE)
.put(CodegenConstants.LEGACY_DISCRIMINATOR_BEHAVIOR, "true")
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptAureliaClientOptionsProvider.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptAureliaClientOptionsProvider.java
index cae9790d8dad..939a0fad979b 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptAureliaClientOptionsProvider.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptAureliaClientOptionsProvider.java
@@ -33,6 +33,7 @@ public class TypeScriptAureliaClientOptionsProvider implements OptionsProvider {
public static final String ENUM_NAME_SUFFIX = "Enum";
public static final String ENUM_PROPERTY_NAMING_VALUE = "PascalCase";
public static final String MODEL_PROPERTY_NAMING_VALUE = "camelCase";
+ public static final String PARAM_NAMING_VALUE = "camelCase";
private static final String NPM_NAME = "npmName";
private static final String NPM_VERSION = "1.0.0";
public static final String ALLOW_UNICODE_IDENTIFIERS_VALUE = "false";
@@ -51,6 +52,7 @@ public Map createOptions() {
.put(CodegenConstants.ENSURE_UNIQUE_PARAMS, ENSURE_UNIQUE_PARAMS_VALUE)
.put(CodegenConstants.ENUM_PROPERTY_NAMING, ENUM_PROPERTY_NAMING_VALUE)
.put(CodegenConstants.MODEL_PROPERTY_NAMING, MODEL_PROPERTY_NAMING_VALUE)
+ .put(CodegenConstants.PARAM_NAMING, PARAM_NAMING_VALUE)
.put(CodegenConstants.SUPPORTS_ES6, String.valueOf(SUPPORTS_ES6_VALUE))
.put(AbstractTypeScriptClientCodegen.NULL_SAFE_ADDITIONAL_PROPS, String.valueOf(NULL_SAFE_ADDITIONAL_PROPS_VALUE))
.put(CodegenConstants.ENUM_NAME_SUFFIX, ENUM_NAME_SUFFIX)
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptFetchClientOptionsProvider.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptFetchClientOptionsProvider.java
index be8e06e79fe2..d4aecd9852ec 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptFetchClientOptionsProvider.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptFetchClientOptionsProvider.java
@@ -32,6 +32,7 @@ public class TypeScriptFetchClientOptionsProvider implements OptionsProvider {
public static final Boolean NULL_SAFE_ADDITIONAL_PROPS_VALUE = false;
public static final String ENUM_NAME_SUFFIX = "Enum";
public static final String MODEL_PROPERTY_NAMING_VALUE = "camelCase";
+ public static final String PARAM_NAMING_VALUE = "camelCase";
public static final String ENUM_PROPERTY_NAMING_VALUE = "PascalCase";
private static final String NMP_NAME = "npmName";
private static final String NMP_VERSION = "1.0.0";
@@ -54,6 +55,7 @@ public Map createOptions() {
.put(CodegenConstants.ENSURE_UNIQUE_PARAMS, ENSURE_UNIQUE_PARAMS_VALUE)
.put(CodegenConstants.ENUM_PROPERTY_NAMING, ENUM_PROPERTY_NAMING_VALUE)
.put(CodegenConstants.MODEL_PROPERTY_NAMING, MODEL_PROPERTY_NAMING_VALUE)
+ .put(CodegenConstants.PARAM_NAMING, PARAM_NAMING_VALUE)
.put(CodegenConstants.SUPPORTS_ES6, String.valueOf(SUPPORTS_ES6_VALUE))
.put(AbstractTypeScriptClientCodegen.NULL_SAFE_ADDITIONAL_PROPS, String.valueOf(NULL_SAFE_ADDITIONAL_PROPS_VALUE))
.put(CodegenConstants.ENUM_NAME_SUFFIX, ENUM_NAME_SUFFIX)
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptNestjsClientOptionsProvider.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptNestjsClientOptionsProvider.java
index ee49aa17dd84..d86f586e15c3 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptNestjsClientOptionsProvider.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptNestjsClientOptionsProvider.java
@@ -33,6 +33,7 @@ public class TypeScriptNestjsClientOptionsProvider implements OptionsProvider {
public static final String ENSURE_UNIQUE_PARAMS_VALUE = "true";
public static final String ENUM_PROPERTY_NAMING_VALUE = "PascalCase";
public static final String MODEL_PROPERTY_NAMING_VALUE = "camelCase";
+ public static final String PARAM_NAMING_VALUE = "camelCase";
private static final String NMP_NAME = "npmName";
private static final String NMP_VERSION = "1.1.2";
private static final String NPM_REPOSITORY = "https://registry.npmjs.org";
@@ -59,6 +60,7 @@ public Map createOptions() {
.put(CodegenConstants.ENSURE_UNIQUE_PARAMS, ENSURE_UNIQUE_PARAMS_VALUE)
.put(CodegenConstants.ENUM_PROPERTY_NAMING, ENUM_PROPERTY_NAMING_VALUE)
.put(CodegenConstants.MODEL_PROPERTY_NAMING, MODEL_PROPERTY_NAMING_VALUE)
+ .put(CodegenConstants.PARAM_NAMING, PARAM_NAMING_VALUE)
.put(CodegenConstants.SUPPORTS_ES6, SUPPORTS_ES6_VALUE)
.put(AbstractTypeScriptClientCodegen.NULL_SAFE_ADDITIONAL_PROPS, NULL_SAFE_ADDITIONAL_PROPS_VALUE)
.put(CodegenConstants.ENUM_NAME_SUFFIX, ENUM_NAME_SUFFIX)
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptNodeClientOptionsProvider.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptNodeClientOptionsProvider.java
index 0600f14838cc..fb2b6a741dc5 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptNodeClientOptionsProvider.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptNodeClientOptionsProvider.java
@@ -33,6 +33,7 @@ public class TypeScriptNodeClientOptionsProvider implements OptionsProvider {
public static final String SORT_MODEL_PROPERTIES_VALUE = "false";
public static final String ENSURE_UNIQUE_PARAMS_VALUE = "true";
public static final String MODEL_PROPERTY_NAMING_VALUE = "camelCase";
+ public static final String PARAM_NAMING_VALUE = "camelCase";
public static final String ENUM_PROPERTY_NAMING_VALUE = "PascalCase";
public static final String NMP_NAME = "npmName";
public static final String NMP_VERSION = "1.1.2";
@@ -57,6 +58,7 @@ public Map createOptions() {
.put(CodegenConstants.ENSURE_UNIQUE_PARAMS, ENSURE_UNIQUE_PARAMS_VALUE)
.put(CodegenConstants.ENUM_PROPERTY_NAMING, ENUM_PROPERTY_NAMING_VALUE)
.put(CodegenConstants.MODEL_PROPERTY_NAMING, MODEL_PROPERTY_NAMING_VALUE)
+ .put(CodegenConstants.PARAM_NAMING, PARAM_NAMING_VALUE)
.put(TypeScriptAngularClientCodegen.NPM_NAME, NMP_NAME)
.put(TypeScriptAngularClientCodegen.NPM_VERSION, NMP_VERSION)
.put(TypeScriptAngularClientCodegen.SNAPSHOT, Boolean.FALSE.toString())
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/SharedTypeScriptTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/SharedTypeScriptTest.java
index 9062d738689b..f4e024142a52 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/SharedTypeScriptTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/SharedTypeScriptTest.java
@@ -12,6 +12,8 @@
import java.io.File;
import java.io.IOException;
import java.util.List;
+import java.util.Map;
+import java.util.HashMap;
public class SharedTypeScriptTest {
@Test
@@ -69,4 +71,25 @@ public void oldImportsStillPresentTest() throws IOException {
FileUtils.deleteDirectory(new File("src/test/resources/oldImportsStillPresentTest/"));
}
+
+ /*
+ #8000
+ Test that primatives are not returned by toModelImportMap
+ */
+ @Test
+ public void toModelImportMapTest() {
+ TypeScriptAxiosClientCodegen codegen = new TypeScriptAxiosClientCodegen();
+
+ Map types = new HashMap() {{
+ put("Schema & AnotherSchema", new String[]{ "Schema", "AnotherSchema" });
+ put("Schema | AnotherSchema", new String[]{ "Schema", "AnotherSchema" });
+ put("Schema & object", new String[]{ "Schema" });
+ put("Schema | object", new String[]{ "Schema" });
+ }};
+
+ for (Map.Entry entry : types.entrySet()) {
+ String[] mapped = codegen.toModelImportMap(entry.getKey()).values().toArray(new String[0]);
+ Assert.assertEquals(mapped, entry.getValue());
+ }
+ }
}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/aurelia/TypeScriptAureliaClientOptionsTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/aurelia/TypeScriptAureliaClientOptionsTest.java
index c8e6a379abd8..cd247de1190c 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/aurelia/TypeScriptAureliaClientOptionsTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/aurelia/TypeScriptAureliaClientOptionsTest.java
@@ -42,6 +42,7 @@ protected CodegenConfig getCodegenConfig() {
protected void verifyOptions() {
verify(clientCodegen).setSortParamsByRequiredFlag(Boolean.valueOf(TypeScriptAureliaClientOptionsProvider.SORT_PARAMS_VALUE));
verify(clientCodegen).setModelPropertyNaming(TypeScriptAureliaClientOptionsProvider.MODEL_PROPERTY_NAMING_VALUE);
+ verify(clientCodegen).setParamNaming(TypeScriptAureliaClientOptionsProvider.PARAM_NAMING_VALUE);
verify(clientCodegen).setSupportsES6(TypeScriptAureliaClientOptionsProvider.SUPPORTS_ES6_VALUE);
verify(clientCodegen).setPrependFormOrBodyParameters(Boolean.valueOf(TypeScriptAureliaClientOptionsProvider.PREPEND_FORM_OR_BODY_PARAMETERS_VALUE));
}
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/fetch/TypeScriptFetchClientOptionsTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/fetch/TypeScriptFetchClientOptionsTest.java
index 6bc2631f6e60..33ef4b99bd49 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/fetch/TypeScriptFetchClientOptionsTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/fetch/TypeScriptFetchClientOptionsTest.java
@@ -42,6 +42,7 @@ protected CodegenConfig getCodegenConfig() {
protected void verifyOptions() {
verify(clientCodegen).setSortParamsByRequiredFlag(Boolean.valueOf(TypeScriptFetchClientOptionsProvider.SORT_PARAMS_VALUE));
verify(clientCodegen).setModelPropertyNaming(TypeScriptFetchClientOptionsProvider.MODEL_PROPERTY_NAMING_VALUE);
+ verify(clientCodegen).setParamNaming(TypeScriptFetchClientOptionsProvider.PARAM_NAMING_VALUE);
verify(clientCodegen).setSupportsES6(TypeScriptFetchClientOptionsProvider.SUPPORTS_ES6_VALUE);
verify(clientCodegen).setPrependFormOrBodyParameters(Boolean.valueOf(TypeScriptFetchClientOptionsProvider.PREPEND_FORM_OR_BODY_PARAMETERS_VALUE));
verify(clientCodegen).setTypescriptThreePlus(Boolean.valueOf(TypeScriptFetchClientOptionsProvider.TYPESCRIPT_THREE_PLUS));
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/typescriptangular/TypeScriptAngularClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/typescriptangular/TypeScriptAngularClientCodegenTest.java
index 059e5004ad4e..07e2216710b3 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/typescriptangular/TypeScriptAngularClientCodegenTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/typescriptangular/TypeScriptAngularClientCodegenTest.java
@@ -231,4 +231,31 @@ public void testKebabCasedModelFilenames() {
Assert.assertEquals(codegen.toModelImport(modelName), "model/foo-response-links");
Assert.assertEquals(codegen.toModelFilename(modelName), "./foo-response-links");
}
+
+ @Test
+ public void testToParamNaming() {
+ TypeScriptAngularClientCodegen codegen = new TypeScriptAngularClientCodegen();
+ // unspecified option should default to camelcase
+ codegen.processOpts();
+ Assert.assertEquals(codegen.toParamName("valid_id"), "validId");
+ Assert.assertEquals(codegen.toParamName("illegal-id+"), "illegalId");
+
+ codegen = new TypeScriptAngularClientCodegen();
+ codegen.additionalProperties().put(CodegenConstants.PARAM_NAMING, CodegenConstants.PARAM_NAMING_TYPE.original.name());
+ codegen.processOpts();
+ Assert.assertEquals(codegen.toParamName("valid_id"), "valid_id");
+ Assert.assertEquals(codegen.toParamName("illegal-id+"), "illegal_id");
+
+ codegen = new TypeScriptAngularClientCodegen();
+ codegen.additionalProperties().put(CodegenConstants.PARAM_NAMING, CodegenConstants.PARAM_NAMING_TYPE.snake_case.name());
+ codegen.processOpts();
+ Assert.assertEquals(codegen.toParamName("valid_ID"), "valid_id");
+ Assert.assertEquals(codegen.toParamName("Illegal-Id+"), "illegal_id");
+
+ codegen = new TypeScriptAngularClientCodegen();
+ codegen.additionalProperties().put(CodegenConstants.PARAM_NAMING, CodegenConstants.PARAM_NAMING_TYPE.PascalCase.name());
+ codegen.processOpts();
+ Assert.assertEquals(codegen.toParamName("valid_id"), "ValidId");
+ Assert.assertEquals(codegen.toParamName("illegal-id+"), "IllegalId");
+ }
}
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/typescriptangular/TypeScriptAngularClientOptionsTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/typescriptangular/TypeScriptAngularClientOptionsTest.java
index 9bc5eafb1bd7..5359b81e6a52 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/typescriptangular/TypeScriptAngularClientOptionsTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/typescriptangular/TypeScriptAngularClientOptionsTest.java
@@ -46,5 +46,6 @@ protected void verifyOptions() {
verify(clientCodegen).setStringEnums(Boolean.parseBoolean(TypeScriptAngularClientOptionsProvider.STRING_ENUMS_VALUE));
verify(clientCodegen).setPrependFormOrBodyParameters(Boolean.valueOf(TypeScriptAngularClientOptionsProvider.PREPEND_FORM_OR_BODY_PARAMETERS_VALUE));
verify(clientCodegen).setQueryParamObjectFormat(TypeScriptAngularClientOptionsProvider.QUERY_PARAM_OBJECT_FORMAT_VALUE);
+ verify(clientCodegen).setParamNaming(TypeScriptAngularClientOptionsProvider.PARAM_NAMING_VALUE);
}
}
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/typescriptangularjs/TypeScriptAngularJsClientOptionsTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/typescriptangularjs/TypeScriptAngularJsClientOptionsTest.java
index f966d40b21cd..54710992d911 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/typescriptangularjs/TypeScriptAngularJsClientOptionsTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/typescriptangularjs/TypeScriptAngularJsClientOptionsTest.java
@@ -42,6 +42,7 @@ protected CodegenConfig getCodegenConfig() {
protected void verifyOptions() {
verify(clientCodegen).setSortParamsByRequiredFlag(Boolean.valueOf(TypeScriptAngularJsClientOptionsProvider.SORT_PARAMS_VALUE));
verify(clientCodegen).setModelPropertyNaming(TypeScriptAngularJsClientOptionsProvider.MODEL_PROPERTY_NAMING_VALUE);
+ verify(clientCodegen).setParamNaming(TypeScriptAngularJsClientOptionsProvider.PARAM_NAMING_VALUE);
verify(clientCodegen).setSupportsES6(Boolean.valueOf(TypeScriptAngularJsClientOptionsProvider.SUPPORTS_ES6_VALUE));
verify(clientCodegen).setPrependFormOrBodyParameters(Boolean.valueOf(TypeScriptAngularJsClientOptionsProvider.PREPEND_FORM_OR_BODY_PARAMETERS_VALUE));
}
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/typescriptnestjs/TypeScriptNestjsClientOptionsTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/typescriptnestjs/TypeScriptNestjsClientOptionsTest.java
index a2d137537fbe..5f2138a66c29 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/typescriptnestjs/TypeScriptNestjsClientOptionsTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/typescriptnestjs/TypeScriptNestjsClientOptionsTest.java
@@ -42,6 +42,7 @@ protected CodegenConfig getCodegenConfig() {
protected void verifyOptions() {
verify(clientCodegen).setSortParamsByRequiredFlag(Boolean.valueOf(TypeScriptNestjsClientOptionsProvider.SORT_PARAMS_VALUE));
verify(clientCodegen).setModelPropertyNaming(TypeScriptNestjsClientOptionsProvider.MODEL_PROPERTY_NAMING_VALUE);
+ verify(clientCodegen).setParamNaming(TypeScriptNestjsClientOptionsProvider.PARAM_NAMING_VALUE);
verify(clientCodegen).setSupportsES6(Boolean.valueOf(TypeScriptNestjsClientOptionsProvider.SUPPORTS_ES6_VALUE));
verify(clientCodegen).setStringEnums(Boolean.parseBoolean(TypeScriptNestjsClientOptionsProvider.STRING_ENUMS_VALUE));
verify(clientCodegen).setPrependFormOrBodyParameters(Boolean.valueOf(TypeScriptNestjsClientOptionsProvider.PREPEND_FORM_OR_BODY_PARAMETERS_VALUE));
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/typescriptnode/TypeScriptNodeClientOptionsTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/typescriptnode/TypeScriptNodeClientOptionsTest.java
index bf7e05099258..414c63dd279a 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/typescriptnode/TypeScriptNodeClientOptionsTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/typescriptnode/TypeScriptNodeClientOptionsTest.java
@@ -42,6 +42,7 @@ protected CodegenConfig getCodegenConfig() {
protected void verifyOptions() {
verify(clientCodegen).setSortParamsByRequiredFlag(Boolean.valueOf(TypeScriptNodeClientOptionsProvider.SORT_PARAMS_VALUE));
verify(clientCodegen).setModelPropertyNaming(TypeScriptNodeClientOptionsProvider.MODEL_PROPERTY_NAMING_VALUE);
+ verify(clientCodegen).setParamNaming(TypeScriptNodeClientOptionsProvider.PARAM_NAMING_VALUE);
verify(clientCodegen).setSupportsES6(Boolean.valueOf(TypeScriptNodeClientOptionsProvider.SUPPORTS_ES6_VALUE));
verify(clientCodegen).setPrependFormOrBodyParameters(Boolean.valueOf(TypeScriptNodeClientOptionsProvider.PREPEND_FORM_OR_BODY_PARAMETERS_VALUE));
}
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/yaml/YamlGeneratorTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/yaml/YamlGeneratorTest.java
index c264a8a251c3..cc4e74ade5dd 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/yaml/YamlGeneratorTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/yaml/YamlGeneratorTest.java
@@ -17,6 +17,7 @@
package org.openapitools.codegen.yaml;
+import io.swagger.v3.oas.models.OpenAPI;
import org.openapitools.codegen.ClientOptInput;
import org.openapitools.codegen.DefaultGenerator;
import org.openapitools.codegen.TestUtils;
@@ -85,4 +86,36 @@ public void testGeneratePingOtherOutputFile() throws Exception {
output.deleteOnExit();
}
+
+ @Test
+ public void testIssue9086() throws Exception {
+ Map properties = new HashMap<>();
+ properties.put(OpenAPIYamlGenerator.OUTPUT_NAME, "issue_9086.yaml");
+
+ File output = Files.createTempDirectory("issue_9086").toFile();
+ output.deleteOnExit();
+
+ final CodegenConfigurator configurator = new CodegenConfigurator()
+ .setGeneratorName("openapi-yaml")
+ .setAdditionalProperties(properties)
+ .setInputSpec("src/test/resources/2_0/issue_9086.yaml")
+ .setOutputDir(output.getAbsolutePath().replace("\\", "/"));
+
+ final ClientOptInput clientOptInput = configurator.toClientOptInput();
+ DefaultGenerator generator = new DefaultGenerator();
+ List files = generator.opts(clientOptInput).generate();
+ Assert.assertEquals(files.size(), 5);
+ TestUtils.ensureContainsFile(files, output, "issue_9086.yaml");
+
+ TestUtils.ensureContainsFile(files, output, "README.md");
+ TestUtils.ensureContainsFile(files, output, ".openapi-generator-ignore");
+ TestUtils.ensureContainsFile(files, output, ".openapi-generator/FILES");
+ TestUtils.ensureContainsFile(files, output, ".openapi-generator/VERSION");
+
+ OpenAPI generated = TestUtils.parseSpec(new File(output, "issue_9086.yaml").getPath());
+ OpenAPI expected = TestUtils.parseSpec("src/test/resources/2_0/issue_9086_expected.yaml");
+
+ // use #toString because the equals methods is a little stricter than necessary for this test
+ Assert.assertEquals(expected.toString(), generated.toString());
+ }
}
diff --git a/modules/openapi-generator/src/test/resources/2_0/issue_9086.yaml b/modules/openapi-generator/src/test/resources/2_0/issue_9086.yaml
new file mode 100644
index 000000000000..3210031ade33
--- /dev/null
+++ b/modules/openapi-generator/src/test/resources/2_0/issue_9086.yaml
@@ -0,0 +1,34 @@
+swagger: '2.0'
+info:
+ title: 'Buggy Api'
+ version: '1.0'
+consumes:
+ - application/json
+paths:
+ /foo/bar:
+ post:
+ responses:
+ '200':
+ description: ok
+ schema:
+ type: object
+ additionalProperties: false
+ properties:
+ n:
+ type: number
+ example: 1.23
+ /foo/bar2:
+ post:
+ responses:
+ '200':
+ description: ok
+ schema:
+ $ref: '#/definitions/bar2'
+definitions:
+ bar2:
+ type: object
+ additionalProperties: false
+ properties:
+ n:
+ type: number
+ example: 4.56
diff --git a/modules/openapi-generator/src/test/resources/2_0/issue_9086_expected.yaml b/modules/openapi-generator/src/test/resources/2_0/issue_9086_expected.yaml
new file mode 100644
index 000000000000..cce682ee0536
--- /dev/null
+++ b/modules/openapi-generator/src/test/resources/2_0/issue_9086_expected.yaml
@@ -0,0 +1,40 @@
+openapi: 3.0.1
+info:
+ title: 'Buggy Api'
+ version: '1.0'
+paths:
+ /foo/bar:
+ post:
+ responses:
+ '200':
+ description: ok
+ content:
+ '*/*':
+ schema:
+ $ref: '#/components/schemas/inline_response_200'
+
+ /foo/bar2:
+ post:
+ responses:
+ '200':
+ description: ok
+ content:
+ '*/*':
+ schema:
+ $ref: '#/components/schemas/bar2'
+components:
+ schemas:
+ bar2:
+ type: object
+ example: { n: 4.56 }
+ properties:
+ n:
+ type: number
+ example: 4.56
+ inline_response_200:
+ type: object
+ example: { n: 1.23 }
+ properties:
+ n:
+ type: number
+ example: 1.23
diff --git a/pom.xml b/pom.xml
index b968a4769008..a78fee85d3c4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1187,6 +1187,7 @@
samples/server/petstore/python-aiohttp
samples/server/petstore/python-aiohttp-srclayout
+ samples/server/petstore/python-fastapi
samples/server/petstore/python-flask