-
curl -X {{vendorExtensions.x-codegen-http-method-upper-case}}{{#authMethods}}\
-{{#isApiKey}}{{#isKeyInHeader}}-H "{{keyParamName}}: [[apiKey]]"{{/isKeyInHeader}}{{/isApiKey}}{{^isBasicBearer}}{{#isBasic}} -H "Authorization: Basic [[basicHash]]"{{/isBasic}}{{/isBasicBearer}}{{#isBasicBearer}} -H "Authorization: Bearer [[accessToken]]"{{/isBasicBearer}}{{/authMethods}}{{#hasProduces}}\
- -H "Accept: {{#produces}}{{{mediaType}}}{{^-last}},{{/-last}}{{/produces}}"{{/hasProduces}}{{#hasConsumes}}\
- -H "Content-Type: {{#consumes}}{{{mediaType}}}{{^-last}},{{/-last}}{{/consumes}}"{{/hasConsumes}}\
- "{{basePath}}{{path}}{{#hasQueryParams}}?{{#queryParams}}{{^-first}}&{{/-first}}{{baseName}}={{vendorExtensions.x-eg}}{{/queryParams}}{{/hasQueryParams}}"
+
{{>sample_curl}}
{{>sample_java}}
diff --git a/modules/openapi-generator/src/main/resources/htmlDocs2/sample_curl.mustache b/modules/openapi-generator/src/main/resources/htmlDocs2/sample_curl.mustache
new file mode 100644
index 00000000000..616db848841
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/htmlDocs2/sample_curl.mustache
@@ -0,0 +1,6 @@
+curl -X {{vendorExtensions.x-codegen-http-method-upper-case}}{{#authMethods}} \
+{{#isApiKey}}{{#isKeyInHeader}}-H "{{keyParamName}}: [[apiKey]]"{{/isKeyInHeader}}{{/isApiKey}}{{^isBasicBearer}}{{#isBasic}} -H "Authorization: Basic [[basicHash]]"{{/isBasic}}{{/isBasicBearer}}{{#isBasicBearer}} -H "Authorization: Bearer [[accessToken]]"{{/isBasicBearer}}{{/authMethods}}{{#hasProduces}} \
+ -H "Accept: {{#produces}}{{{mediaType}}}{{^-last}},{{/-last}}{{/produces}}"{{/hasProduces}}{{#hasConsumes}} \
+ -H "Content-Type: {{#consumes}}{{{mediaType}}}{{^-last}},{{/-last}}{{/consumes}}"{{/hasConsumes}} \
+ "{{basePath}}{{path}}{{#hasQueryParams}}?{{#queryParams}}{{^-first}}&{{/-first}}{{baseName}}={{{example}}}{{/queryParams}}{{/hasQueryParams}}"{{#requestBodyExamples}} \
+ -d '{{example}}'{{/requestBodyExamples}}
diff --git a/modules/openapi-generator/src/main/resources/java-micronaut-client/configuration/git/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/java-micronaut-client/configuration/git/git_push.sh.mustache
index 228d338ebdb..a2c45bc6a62 100644
--- a/modules/openapi-generator/src/main/resources/java-micronaut-client/configuration/git/git_push.sh.mustache
+++ b/modules/openapi-generator/src/main/resources/java-micronaut-client/configuration/git/git_push.sh.mustache
@@ -38,14 +38,14 @@ git add .
git commit -m "$release_note"
# Sets the new remote
-git_remote=`git remote`
+git_remote=$(git remote)
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/data_class_opt_var.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/data_class_opt_var.mustache
index 2929c361b1a..b1d925af613 100644
--- a/modules/openapi-generator/src/main/resources/kotlin-client/data_class_opt_var.mustache
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/data_class_opt_var.mustache
@@ -18,4 +18,4 @@
{{#deprecated}}
@Deprecated(message = "This property is deprecated.")
{{/deprecated}}
- {{#multiplatform}}@SerialName(value = "{{{vendorExtensions.x-base-name-literal}}}") {{/multiplatform}}{{#isInherited}}override {{/isInherited}}{{>modelMutable}} {{{name}}}: {{#isArray}}{{#isList}}{{#uniqueItems}}kotlin.collections.Set{{/uniqueItems}}{{^uniqueItems}}kotlin.collections.List{{/uniqueItems}}{{/isList}}{{^isList}}kotlin.Array{{/isList}}<{{^items.isEnum}}{{^items.isPrimitiveType}}{{^items.isModel}}{{#kotlinx_serialization}}@Contextual {{/kotlinx_serialization}}{{/items.isModel}}{{/items.isPrimitiveType}}{{{items.dataType}}}{{/items.isEnum}}{{#items.isEnum}}{{classname}}.{{{nameInCamelCase}}}{{/items.isEnum}}>{{/isArray}}{{^isEnum}}{{^isArray}}{{{dataType}}}{{/isArray}}{{/isEnum}}{{#isEnum}}{{^isArray}}{{classname}}.{{{nameInCamelCase}}}{{/isArray}}{{/isEnum}}? = {{defaultvalue}}{{^defaultvalue}}null{{/defaultvalue}}
\ No newline at end of file
+ {{#multiplatform}}@SerialName(value = "{{{vendorExtensions.x-base-name-literal}}}") {{/multiplatform}}{{#isInherited}}override {{/isInherited}}{{>modelMutable}} {{{name}}}: {{#isArray}}{{#isList}}{{#uniqueItems}}kotlin.collections.Set{{/uniqueItems}}{{^uniqueItems}}kotlin.collections.List{{/uniqueItems}}{{/isList}}{{^isList}}kotlin.Array{{/isList}}<{{^items.isEnum}}{{^items.isPrimitiveType}}{{^items.isModel}}{{#kotlinx_serialization}}@Contextual {{/kotlinx_serialization}}{{/items.isModel}}{{/items.isPrimitiveType}}{{{items.dataType}}}{{/items.isEnum}}{{#items.isEnum}}{{classname}}.{{{nameInCamelCase}}}{{/items.isEnum}}>{{/isArray}}{{^isEnum}}{{^isArray}}{{{dataType}}}{{/isArray}}{{/isEnum}}{{#isEnum}}{{^isArray}}{{classname}}.{{{nameInCamelCase}}}{{/isArray}}{{/isEnum}}? = {{defaultValue}}{{^defaultValue}}null{{/defaultValue}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-okhttp/infrastructure/ApiClient.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-okhttp/infrastructure/ApiClient.kt.mustache
index 742a69012ed..70a44277235 100644
--- a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-okhttp/infrastructure/ApiClient.kt.mustache
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-okhttp/infrastructure/ApiClient.kt.mustache
@@ -26,9 +26,19 @@ import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.Request
import okhttp3.Headers
import okhttp3.MultipartBody
+import okhttp3.Call
+import okhttp3.Callback
+import okhttp3.Response
+{{#jvm-okhttp3}}
+import okhttp3.internal.Util.EMPTY_REQUEST
+{{/jvm-okhttp3}}
+{{#jvm-okhttp4}}
+import okhttp3.internal.EMPTY_REQUEST
+{{/jvm-okhttp4}}
import java.io.BufferedWriter
import java.io.File
import java.io.FileWriter
+import java.io.IOException
import java.net.URLConnection
{{^threetenbp}}
import java.time.LocalDate
@@ -39,6 +49,11 @@ import java.time.OffsetTime
{{/threetenbp}}
import java.util.Date
import java.util.Locale
+{{#useCoroutines}}
+import kotlin.coroutines.resume
+import kotlin.coroutines.resumeWithException
+import kotlinx.coroutines.suspendCancellableCoroutine
+{{/useCoroutines}}
{{#kotlinx_serialization}}
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.encodeToString
@@ -152,25 +167,49 @@ import com.squareup.moshi.adapter
}.build()
}
{{#jvm-okhttp3}}
- mediaType == JsonMediaType -> RequestBody.create(
- {{#moshi}}
- MediaType.parse(mediaType), Serializer.moshi.adapter(T::class.java).toJson(content)
- {{/moshi}}
- {{#gson}}
- MediaType.parse(mediaType), Serializer.gson.toJson(content, T::class.java)
- {{/gson}}
- {{#jackson}}
- MediaType.parse(mediaType), Serializer.jacksonObjectMapper.writeValueAsString(content)
- {{/jackson}}
- {{#kotlinx_serialization}}
- MediaType.parse(mediaType), Serializer.jvmJson.encodeToString(content)
- {{/kotlinx_serialization}}
- )
+ mediaType == JsonMediaType -> {
+ if (content == null) {
+ EMPTY_REQUEST
+ } else {
+ RequestBody.create(
+ {{#moshi}}
+ MediaType.parse(mediaType), Serializer.moshi.adapter(T::class.java).toJson(content)
+ {{/moshi}}
+ {{#gson}}
+ MediaType.parse(mediaType), Serializer.gson.toJson(content, T::class.java)
+ {{/gson}}
+ {{#jackson}}
+ MediaType.parse(mediaType), Serializer.jacksonObjectMapper.writeValueAsString(content)
+ {{/jackson}}
+ {{#kotlinx_serialization}}
+ MediaType.parse(mediaType), Serializer.jvmJson.encodeToString(content)
+ {{/kotlinx_serialization}}
+ )
+ }
+ }
{{/jvm-okhttp3}}
{{#jvm-okhttp4}}
- mediaType == JsonMediaType -> {{#moshi}}Serializer.moshi.adapter(T::class.java).toJson(content){{/moshi}}{{#gson}}Serializer.gson.toJson(content, T::class.java){{/gson}}{{#jackson}}Serializer.jacksonObjectMapper.writeValueAsString(content){{/jackson}}{{#kotlinx_serialization}}Serializer.jvmJson.encodeToString(content){{/kotlinx_serialization}}.toRequestBody(
- mediaType.toMediaTypeOrNull()
- )
+ mediaType == JsonMediaType -> {
+ if (content == null) {
+ EMPTY_REQUEST
+ } else {
+ {{#moshi}}
+ Serializer.moshi.adapter(T::class.java).toJson(content)
+ {{/moshi}}
+ {{#gson}}
+ Serializer.gson.toJson(content, T::class.java)
+ {{/gson}}
+ {{#jackson}}
+ Serializer.jacksonObjectMapper.writeValueAsString(content)
+ {{/jackson}}
+ {{#kotlinx_serialization}}
+ Serializer.jvmJson.encodeToString(content)
+ {{/kotlinx_serialization}}
+ .toRequestBody(
+ mediaType.toMediaTypeOrNull()
+ )
+ }
+ }
{{/jvm-okhttp4}}
mediaType == XmlMediaType -> throw UnsupportedOperationException("xml not currently supported.")
// TODO: this should be extended with other serializers
@@ -271,7 +310,7 @@ import com.squareup.moshi.adapter
}
{{/hasAuthMethods}}
- protected inline fun
request(requestConfig: RequestConfig): ApiInfrastructureResponse {
+ protected {{#useCoroutines}}suspend {{/useCoroutines}}inline fun request(requestConfig: RequestConfig): ApiInfrastructureResponse {
{{#jvm-okhttp3}}
val httpUrl = HttpUrl.parse(baseUrl) ?: throw IllegalStateException("baseUrl is invalid.")
{{/jvm-okhttp3}}
@@ -326,7 +365,24 @@ import com.squareup.moshi.adapter
headers.forEach { header -> addHeader(header.key, header.value) }
}.build()
+ {{#useCoroutines}}
+ val response: Response = suspendCancellableCoroutine { continuation ->
+ val call = client.newCall(request)
+ continuation.invokeOnCancellation { call.cancel() }
+ call.enqueue(object : Callback {
+ override fun onFailure(call: Call, e: IOException) {
+ continuation.resumeWithException(e)
+ }
+ override fun onResponse(call: Call, response: Response) {
+ continuation.resume(response)
+ }
+ })
+ }
+ {{/useCoroutines}}
+ {{^useCoroutines}}
val response = client.newCall(request).execute()
+ {{/useCoroutines}}
+
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.getDefault())
// TODO: handle specific mapping types. e.g. Map>
diff --git a/modules/openapi-generator/src/main/resources/kotlin-server-deprecated/data_class_opt_var.mustache b/modules/openapi-generator/src/main/resources/kotlin-server-deprecated/data_class_opt_var.mustache
index 89e3b61240a..a8595b2b7f3 100644
--- a/modules/openapi-generator/src/main/resources/kotlin-server-deprecated/data_class_opt_var.mustache
+++ b/modules/openapi-generator/src/main/resources/kotlin-server-deprecated/data_class_opt_var.mustache
@@ -1,4 +1,4 @@
{{#description}}
/* {{{.}}} */
{{/description}}
- {{>modelMutable}} {{{name}}}: {{#isEnum}}{{classname}}.{{nameInCamelCase}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}? = {{defaultvalue}}{{^defaultvalue}}null{{/defaultvalue}}
\ No newline at end of file
+ {{>modelMutable}} {{{name}}}: {{#isEnum}}{{classname}}.{{nameInCamelCase}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}? = {{defaultValue}}{{^defaultValue}}null{{/defaultValue}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/kotlin-server/data_class_opt_var.mustache b/modules/openapi-generator/src/main/resources/kotlin-server/data_class_opt_var.mustache
index 89e3b61240a..a8595b2b7f3 100644
--- a/modules/openapi-generator/src/main/resources/kotlin-server/data_class_opt_var.mustache
+++ b/modules/openapi-generator/src/main/resources/kotlin-server/data_class_opt_var.mustache
@@ -1,4 +1,4 @@
{{#description}}
/* {{{.}}} */
{{/description}}
- {{>modelMutable}} {{{name}}}: {{#isEnum}}{{classname}}.{{nameInCamelCase}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}? = {{defaultvalue}}{{^defaultvalue}}null{{/defaultvalue}}
\ No newline at end of file
+ {{>modelMutable}} {{{name}}}: {{#isEnum}}{{classname}}.{{nameInCamelCase}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}? = {{defaultValue}}{{^defaultValue}}null{{/defaultValue}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/interfaceOptVar.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/interfaceOptVar.mustache
index 0c560f12cff..354922c426f 100644
--- a/modules/openapi-generator/src/main/resources/kotlin-spring/interfaceOptVar.mustache
+++ b/modules/openapi-generator/src/main/resources/kotlin-spring/interfaceOptVar.mustache
@@ -1,3 +1,3 @@
{{#swaggerAnnotations}}
@ApiModelProperty({{#example}}example = "{{{.}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}{{#isReadOnly}}readOnly = {{{isReadOnly}}}, {{/isReadOnly}}value = "{{{description}}}"){{/swaggerAnnotations}}
- {{>modelMutable}} {{{name}}}: {{#isEnum}}{{classname}}.{{nameInCamelCase}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}? {{^discriminator}}= {{defaultvalue}}{{^defaultvalue}}null{{/defaultvalue}}{{/discriminator}}
\ No newline at end of file
+ {{>modelMutable}} {{{name}}}: {{#isEnum}}{{classname}}.{{nameInCamelCase}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}? {{^discriminator}}= {{defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/discriminator}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/kotlin-vertx-server/data_class_opt_var.mustache b/modules/openapi-generator/src/main/resources/kotlin-vertx-server/data_class_opt_var.mustache
index 89e3b61240a..a8595b2b7f3 100644
--- a/modules/openapi-generator/src/main/resources/kotlin-vertx-server/data_class_opt_var.mustache
+++ b/modules/openapi-generator/src/main/resources/kotlin-vertx-server/data_class_opt_var.mustache
@@ -1,4 +1,4 @@
{{#description}}
/* {{{.}}} */
{{/description}}
- {{>modelMutable}} {{{name}}}: {{#isEnum}}{{classname}}.{{nameInCamelCase}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}? = {{defaultvalue}}{{^defaultvalue}}null{{/defaultvalue}}
\ No newline at end of file
+ {{>modelMutable}} {{{name}}}: {{#isEnum}}{{classname}}.{{nameInCamelCase}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}? = {{defaultValue}}{{^defaultValue}}null{{/defaultValue}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/ktorm-schema/data_class_bind_field_opt.mustache b/modules/openapi-generator/src/main/resources/ktorm-schema/data_class_bind_field_opt.mustache
index 4fae4293de5..6489b2bcc3c 100644
--- a/modules/openapi-generator/src/main/resources/ktorm-schema/data_class_bind_field_opt.mustache
+++ b/modules/openapi-generator/src/main/resources/ktorm-schema/data_class_bind_field_opt.mustache
@@ -1 +1 @@
-{{#vendorExtensions}}{{#x-ktorm-schema}}{{#columnDefinition}} {{{name}}} = row[{{{name}}}] {{#defaultvalue}}?: {{{.}}}{{/defaultvalue}} /* {{{colKotlinType}}}? */{{/columnDefinition}}{{/x-ktorm-schema}}{{/vendorExtensions}}{{#description}} /* {{{.}}} */{{/description}}
\ No newline at end of file
+{{#vendorExtensions}}{{#x-ktorm-schema}}{{#columnDefinition}} {{{name}}} = row[{{{name}}}] {{#defaultValue}}?: {{{.}}}{{/defaultValue}} /* {{{colKotlinType}}}? */{{/columnDefinition}}{{/x-ktorm-schema}}{{/vendorExtensions}}{{#description}} /* {{{.}}} */{{/description}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/lua/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/lua/git_push.sh.mustache
index 305f9c115ce..0e3776ae6dd 100755
--- a/modules/openapi-generator/src/main/resources/lua/git_push.sh.mustache
+++ b/modules/openapi-generator/src/main/resources/lua/git_push.sh.mustache
@@ -38,14 +38,14 @@ git add .
git commit -m "$release_note"
# Sets the new remote
-git_remote=`git remote`
+git_remote=$(git remote)
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
diff --git a/modules/openapi-generator/src/main/resources/objc/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/objc/git_push.sh.mustache
index 305f9c115ce..0e3776ae6dd 100644
--- a/modules/openapi-generator/src/main/resources/objc/git_push.sh.mustache
+++ b/modules/openapi-generator/src/main/resources/objc/git_push.sh.mustache
@@ -38,14 +38,14 @@ git add .
git commit -m "$release_note"
# Sets the new remote
-git_remote=`git remote`
+git_remote=$(git remote)
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
diff --git a/modules/openapi-generator/src/main/resources/perl/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/perl/git_push.sh.mustache
index 305f9c115ce..0e3776ae6dd 100755
--- a/modules/openapi-generator/src/main/resources/perl/git_push.sh.mustache
+++ b/modules/openapi-generator/src/main/resources/perl/git_push.sh.mustache
@@ -38,14 +38,14 @@ git add .
git commit -m "$release_note"
# Sets the new remote
-git_remote=`git remote`
+git_remote=$(git remote)
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
diff --git a/modules/openapi-generator/src/main/resources/php-symfony/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/php-symfony/git_push.sh.mustache
index 305f9c115ce..0e3776ae6dd 100755
--- a/modules/openapi-generator/src/main/resources/php-symfony/git_push.sh.mustache
+++ b/modules/openapi-generator/src/main/resources/php-symfony/git_push.sh.mustache
@@ -38,14 +38,14 @@ git add .
git commit -m "$release_note"
# Sets the new remote
-git_remote=`git remote`
+git_remote=$(git remote)
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
diff --git a/modules/openapi-generator/src/main/resources/php/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/php/git_push.sh.mustache
index 305f9c115ce..0e3776ae6dd 100755
--- a/modules/openapi-generator/src/main/resources/php/git_push.sh.mustache
+++ b/modules/openapi-generator/src/main/resources/php/git_push.sh.mustache
@@ -38,14 +38,14 @@ git add .
git commit -m "$release_note"
# Sets the new remote
-git_remote=`git remote`
+git_remote=$(git remote)
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
diff --git a/modules/openapi-generator/src/main/resources/protobuf-schema/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/protobuf-schema/git_push.sh.mustache
index 81aaba42129..0c82a773770 100755
--- a/modules/openapi-generator/src/main/resources/protobuf-schema/git_push.sh.mustache
+++ b/modules/openapi-generator/src/main/resources/protobuf-schema/git_push.sh.mustache
@@ -32,14 +32,14 @@ git add .
git commit -m "$release_note"
# Sets the new remote
-git_remote=`git remote`
+git_remote=$(git remote)
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@github.com/${git_user_id}/${git_repo_id}.git
fi
fi
diff --git a/modules/openapi-generator/src/main/resources/python-flask/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/python-flask/git_push.sh.mustache
index 305f9c115ce..0e3776ae6dd 100755
--- a/modules/openapi-generator/src/main/resources/python-flask/git_push.sh.mustache
+++ b/modules/openapi-generator/src/main/resources/python-flask/git_push.sh.mustache
@@ -38,14 +38,14 @@ git add .
git commit -m "$release_note"
# Sets the new remote
-git_remote=`git remote`
+git_remote=$(git remote)
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
diff --git a/modules/openapi-generator/src/main/resources/python-legacy/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/python-legacy/git_push.sh.mustache
index 305f9c115ce..0e3776ae6dd 100755
--- a/modules/openapi-generator/src/main/resources/python-legacy/git_push.sh.mustache
+++ b/modules/openapi-generator/src/main/resources/python-legacy/git_push.sh.mustache
@@ -38,14 +38,14 @@ git add .
git commit -m "$release_note"
# Sets the new remote
-git_remote=`git remote`
+git_remote=$(git remote)
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
diff --git a/modules/openapi-generator/src/main/resources/python/api.mustache b/modules/openapi-generator/src/main/resources/python/api.mustache
index 573224455a9..841ac8bb855 100644
--- a/modules/openapi-generator/src/main/resources/python/api.mustache
+++ b/modules/openapi-generator/src/main/resources/python/api.mustache
@@ -18,7 +18,6 @@ from {{packageName}}.model_utils import ( # noqa: F401
{{/imports}}
-{{#operations}}
class {{classname}}(object):
"""NOTE: This class is auto generated by OpenAPI Generator
Ref: https://openapi-generator.tech
@@ -30,102 +29,9 @@ class {{classname}}(object):
if api_client is None:
api_client = ApiClient()
self.api_client = api_client
+{{#operations}}
{{#operation}}
-
- def __{{operationId}}(
- self,
-{{#requiredParams}}
-{{^defaultValue}}
- {{paramName}},
-{{/defaultValue}}
-{{/requiredParams}}
-{{#requiredParams}}
-{{#defaultValue}}
- {{paramName}}={{{defaultValue}}},
-{{/defaultValue}}
-{{/requiredParams}}
- **kwargs
- ):
- """{{{summary}}}{{^summary}}{{operationId}}{{/summary}} # noqa: E501
-
-{{#notes}}
- {{{.}}} # noqa: E501
-{{/notes}}
- This method makes a synchronous HTTP request by default. To make an
- asynchronous HTTP request, please pass async_req=True
-
- >>> thread = api.{{operationId}}({{#requiredParams}}{{^defaultValue}}{{paramName}}, {{/defaultValue}}{{/requiredParams}}{{#requiredParams}}{{#defaultValue}}{{paramName}}={{{defaultValue}}}, {{/defaultValue}}{{/requiredParams}}async_req=True)
- >>> result = thread.get()
-
-{{#requiredParams}}
-{{#-last}}
- Args:
-{{/-last}}
-{{/requiredParams}}
-{{#requiredParams}}
-{{^defaultValue}}
- {{paramName}} ({{dataType}}):{{#description}} {{{.}}}{{/description}}
-{{/defaultValue}}
-{{/requiredParams}}
-{{#requiredParams}}
-{{#defaultValue}}
- {{paramName}} ({{dataType}}):{{#description}} {{{.}}}.{{/description}} defaults to {{{defaultValue}}}, must be one of [{{{defaultValue}}}]
-{{/defaultValue}}
-{{/requiredParams}}
-
- Keyword Args:{{#optionalParams}}
- {{paramName}} ({{dataType}}):{{#description}} {{{.}}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{.}}}{{/defaultValue}}{{/optionalParams}}
- _return_http_data_only (bool): response data without head status
- code and headers. Default is True.
- _preload_content (bool): if False, the urllib3.HTTPResponse object
- will be returned without reading/decoding response data.
- Default is True.
- _request_timeout (int/float/tuple): timeout setting for this request. If
- one number provided, it will be total request timeout. It can also
- be a pair (tuple) of (connection, read) timeouts.
- Default is None.
- _check_input_type (bool): specifies if type checking
- should be done one the data sent to the server.
- Default is True.
- _check_return_type (bool): specifies if type checking
- should be done one the data received from the server.
- Default is True.
- _host_index (int/None): specifies the index of the server
- that we want to use.
- Default is read from the configuration.
- async_req (bool): execute request asynchronously
-
- Returns:
- {{returnType}}{{^returnType}}None{{/returnType}}
- If the method is called asynchronously, returns the request
- thread.
- """
- kwargs['async_req'] = kwargs.get(
- 'async_req', False
- )
- kwargs['_return_http_data_only'] = kwargs.get(
- '_return_http_data_only', True
- )
- kwargs['_preload_content'] = kwargs.get(
- '_preload_content', True
- )
- kwargs['_request_timeout'] = kwargs.get(
- '_request_timeout', None
- )
- kwargs['_check_input_type'] = kwargs.get(
- '_check_input_type', True
- )
- kwargs['_check_return_type'] = kwargs.get(
- '_check_return_type', True
- )
- kwargs['_host_index'] = kwargs.get('_host_index')
-{{#requiredParams}}
- kwargs['{{paramName}}'] = \
- {{paramName}}
-{{/requiredParams}}
- return self.call_with_http_info(**kwargs)
-
- self.{{operationId}} = _Endpoint(
+ self.{{operationId}}_endpoint = _Endpoint(
settings={
'response_type': {{#returnType}}({{{.}}},){{/returnType}}{{^returnType}}None{{/returnType}},
{{#authMethods}}
@@ -299,8 +205,105 @@ class {{classname}}(object):
'content_type': [],
{{/hasConsumes}}
},
- api_client=api_client,
- callable=__{{operationId}}
+ api_client=api_client
)
{{/operation}}
{{/operations}}
+
+{{#operations}}
+{{#operation}}
+ def {{operationId}}(
+ self,
+{{#requiredParams}}
+{{^defaultValue}}
+ {{paramName}},
+{{/defaultValue}}
+{{/requiredParams}}
+{{#requiredParams}}
+{{#defaultValue}}
+ {{paramName}}={{{defaultValue}}},
+{{/defaultValue}}
+{{/requiredParams}}
+ **kwargs
+ ):
+ """{{{summary}}}{{^summary}}{{operationId}}{{/summary}} # noqa: E501
+
+{{#notes}}
+ {{{.}}} # noqa: E501
+{{/notes}}
+ This method makes a synchronous HTTP request by default. To make an
+ asynchronous HTTP request, please pass async_req=True
+
+ >>> thread = api.{{operationId}}({{#requiredParams}}{{^defaultValue}}{{paramName}}, {{/defaultValue}}{{/requiredParams}}{{#requiredParams}}{{#defaultValue}}{{paramName}}={{{defaultValue}}}, {{/defaultValue}}{{/requiredParams}}async_req=True)
+ >>> result = thread.get()
+
+{{#requiredParams}}
+{{#-last}}
+ Args:
+{{/-last}}
+{{/requiredParams}}
+{{#requiredParams}}
+{{^defaultValue}}
+ {{paramName}} ({{dataType}}):{{#description}} {{{.}}}{{/description}}
+{{/defaultValue}}
+{{/requiredParams}}
+{{#requiredParams}}
+{{#defaultValue}}
+ {{paramName}} ({{dataType}}):{{#description}} {{{.}}}.{{/description}} defaults to {{{defaultValue}}}, must be one of [{{{defaultValue}}}]
+{{/defaultValue}}
+{{/requiredParams}}
+
+ Keyword Args:{{#optionalParams}}
+ {{paramName}} ({{dataType}}):{{#description}} {{{.}}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{.}}}{{/defaultValue}}{{/optionalParams}}
+ _return_http_data_only (bool): response data without head status
+ code and headers. Default is True.
+ _preload_content (bool): if False, the urllib3.HTTPResponse object
+ will be returned without reading/decoding response data.
+ Default is True.
+ _request_timeout (int/float/tuple): timeout setting for this request. If
+ one number provided, it will be total request timeout. It can also
+ be a pair (tuple) of (connection, read) timeouts.
+ Default is None.
+ _check_input_type (bool): specifies if type checking
+ should be done one the data sent to the server.
+ Default is True.
+ _check_return_type (bool): specifies if type checking
+ should be done one the data received from the server.
+ Default is True.
+ _host_index (int/None): specifies the index of the server
+ that we want to use.
+ Default is read from the configuration.
+ async_req (bool): execute request asynchronously
+
+ Returns:
+ {{returnType}}{{^returnType}}None{{/returnType}}
+ If the method is called asynchronously, returns the request
+ thread.
+ """
+ kwargs['async_req'] = kwargs.get(
+ 'async_req', False
+ )
+ kwargs['_return_http_data_only'] = kwargs.get(
+ '_return_http_data_only', True
+ )
+ kwargs['_preload_content'] = kwargs.get(
+ '_preload_content', True
+ )
+ kwargs['_request_timeout'] = kwargs.get(
+ '_request_timeout', None
+ )
+ kwargs['_check_input_type'] = kwargs.get(
+ '_check_input_type', True
+ )
+ kwargs['_check_return_type'] = kwargs.get(
+ '_check_return_type', True
+ )
+ kwargs['_host_index'] = kwargs.get('_host_index')
+{{#requiredParams}}
+ kwargs['{{paramName}}'] = \
+ {{paramName}}
+{{/requiredParams}}
+ return self.{{operationId}}_endpoint.call_with_http_info(**kwargs)
+
+{{/operation}}
+{{/operations}}
diff --git a/modules/openapi-generator/src/main/resources/python/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/python/git_push.sh.mustache
index 305f9c115ce..0e3776ae6dd 100755
--- a/modules/openapi-generator/src/main/resources/python/git_push.sh.mustache
+++ b/modules/openapi-generator/src/main/resources/python/git_push.sh.mustache
@@ -38,14 +38,14 @@ git add .
git commit -m "$release_note"
# Sets the new remote
-git_remote=`git remote`
+git_remote=$(git remote)
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
diff --git a/modules/openapi-generator/src/main/resources/python/model_templates/methods_shared.mustache b/modules/openapi-generator/src/main/resources/python/model_templates/methods_shared.mustache
index 43bcf6fd0d5..eddad2533af 100644
--- a/modules/openapi-generator/src/main/resources/python/model_templates/methods_shared.mustache
+++ b/modules/openapi-generator/src/main/resources/python/model_templates/methods_shared.mustache
@@ -12,4 +12,23 @@
def __getattr__(self, attr):
"""get the value of an attribute using dot notation: `instance.attr`"""
- return self.{{#attrNoneIfUnset}}get{{/attrNoneIfUnset}}{{^attrNoneIfUnset}}__getitem__{{/attrNoneIfUnset}}(attr)
\ No newline at end of file
+ return self.{{#attrNoneIfUnset}}get{{/attrNoneIfUnset}}{{^attrNoneIfUnset}}__getitem__{{/attrNoneIfUnset}}(attr)
+
+ def __copy__(self):
+ cls = self.__class__
+ if self.get("_spec_property_naming", False):
+ return cls._new_from_openapi_data(**self.__dict__)
+ else:
+ return new_cls.__new__(cls, **self.__dict__)
+
+ def __deepcopy__(self, memo):
+ cls = self.__class__
+
+ if self.get("_spec_property_naming", False):
+ new_inst = cls._new_from_openapi_data()
+ else:
+ new_inst = cls.__new__(cls)
+
+ for k, v in self.__dict__.items():
+ setattr(new_inst, k, deepcopy(v, memo))
+ return new_inst
diff --git a/modules/openapi-generator/src/main/resources/python/model_utils.mustache b/modules/openapi-generator/src/main/resources/python/model_utils.mustache
index 6be57468da7..24dd544ce05 100644
--- a/modules/openapi-generator/src/main/resources/python/model_utils.mustache
+++ b/modules/openapi-generator/src/main/resources/python/model_utils.mustache
@@ -1,6 +1,7 @@
{{>partial_header}}
from datetime import date, datetime # noqa: F401
+from copy import deepcopy
import inspect
import io
import os
@@ -223,8 +224,13 @@ class OpenApiModel(object):
self_inst = super(OpenApiModel, cls).__new__(cls)
self_inst.__init__(*args, **kwargs)
- new_inst = new_cls.__new__(new_cls, *args, **kwargs)
- new_inst.__init__(*args, **kwargs)
+ if kwargs.get("_spec_property_naming", False):
+ # when true, implies new is from deserialization
+ new_inst = new_cls._new_from_openapi_data(*args, **kwargs)
+ else:
+ new_inst = new_cls.__new__(new_cls, *args, **kwargs)
+ new_inst.__init__(*args, **kwargs)
+
return new_inst
diff --git a/modules/openapi-generator/src/main/resources/r/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/r/git_push.sh.mustache
index 305f9c115ce..0e3776ae6dd 100755
--- a/modules/openapi-generator/src/main/resources/r/git_push.sh.mustache
+++ b/modules/openapi-generator/src/main/resources/r/git_push.sh.mustache
@@ -38,14 +38,14 @@ git add .
git commit -m "$release_note"
# Sets the new remote
-git_remote=`git remote`
+git_remote=$(git remote)
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
diff --git a/modules/openapi-generator/src/main/resources/ruby-client/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/ruby-client/git_push.sh.mustache
index 305f9c115ce..0e3776ae6dd 100755
--- a/modules/openapi-generator/src/main/resources/ruby-client/git_push.sh.mustache
+++ b/modules/openapi-generator/src/main/resources/ruby-client/git_push.sh.mustache
@@ -38,14 +38,14 @@ git add .
git commit -m "$release_note"
# Sets the new remote
-git_remote=`git remote`
+git_remote=$(git remote)
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
diff --git a/modules/openapi-generator/src/main/resources/rust/Cargo.mustache b/modules/openapi-generator/src/main/resources/rust/Cargo.mustache
index 43c8d17fadc..53c02a6f286 100644
--- a/modules/openapi-generator/src/main/resources/rust/Cargo.mustache
+++ b/modules/openapi-generator/src/main/resources/rust/Cargo.mustache
@@ -22,7 +22,6 @@ reqwest = "~0.9"
{{#supportAsync}}
[dependencies.reqwest]
version = "^0.11"
-default-features = false
features = ["json", "multipart"]
{{/supportAsync}}
{{/reqwest}}
diff --git a/modules/openapi-generator/src/main/resources/rust/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/rust/git_push.sh.mustache
index 305f9c115ce..0e3776ae6dd 100755
--- a/modules/openapi-generator/src/main/resources/rust/git_push.sh.mustache
+++ b/modules/openapi-generator/src/main/resources/rust/git_push.sh.mustache
@@ -38,14 +38,14 @@ git add .
git commit -m "$release_note"
# Sets the new remote
-git_remote=`git remote`
+git_remote=$(git remote)
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
diff --git a/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache b/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache
index 8945ebaf689..c37112258ba 100644
--- a/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache
+++ b/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache
@@ -81,6 +81,8 @@ pub enum {{{operationIdCamelCase}}}Error {
{{/notes}}
{{#vendorExtensions.x-group-parameters}}
pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration: &configuration::Configuration{{#allParams}}{{#-first}}, params: {{{operationIdCamelCase}}}Params{{/-first}}{{/allParams}}) -> Result<{{#supportMultipleResponses}}ResponseContent<{{{operationIdCamelCase}}}Success>{{/supportMultipleResponses}}{{^supportMultipleResponses}}{{^returnType}}(){{/returnType}}{{{returnType}}}{{/supportMultipleResponses}}, Error<{{{operationIdCamelCase}}}Error>> {
+ let local_var_configuration = configuration;
+
// unbox the parameters
{{#allParams}}
let {{paramName}} = params.{{paramName}};
@@ -89,11 +91,12 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration:
{{/vendorExtensions.x-group-parameters}}
{{^vendorExtensions.x-group-parameters}}
pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration: &configuration::Configuration, {{#allParams}}{{{paramName}}}: {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isString}}{{#isArray}}Vec<{{/isArray}}&str{{#isArray}}>{{/isArray}}{{/isString}}{{#isUuid}}{{#isArray}}Vec<{{/isArray}}&str{{#isArray}}>{{/isArray}}{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}{{#isBodyParam}}crate::models::{{/isBodyParam}}{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) -> Result<{{#supportMultipleResponses}}ResponseContent<{{{operationIdCamelCase}}}Success>{{/supportMultipleResponses}}{{^supportMultipleResponses}}{{^returnType}}(){{/returnType}}{{{returnType}}}{{/supportMultipleResponses}}, Error<{{{operationIdCamelCase}}}Error>> {
+ let local_var_configuration = configuration;
{{/vendorExtensions.x-group-parameters}}
- let local_var_client = &configuration.client;
+ let local_var_client = &local_var_configuration.client;
- let local_var_uri_str = format!("{}{{{path}}}", configuration.base_path{{#pathParams}}, {{{baseName}}}={{#isString}}crate::apis::urlencode({{/isString}}{{{paramName}}}{{^required}}.unwrap(){{/required}}{{#required}}{{#isNullable}}.unwrap(){{/isNullable}}{{/required}}{{#isArray}}.join(",").as_ref(){{/isArray}}{{#isString}}){{/isString}}{{/pathParams}});
+ let local_var_uri_str = format!("{}{{{path}}}", local_var_configuration.base_path{{#pathParams}}, {{{baseName}}}={{#isString}}crate::apis::urlencode({{/isString}}{{{paramName}}}{{^required}}.unwrap(){{/required}}{{#required}}{{#isNullable}}.unwrap(){{/isNullable}}{{/required}}{{#isArray}}.join(",").as_ref(){{/isArray}}{{#isString}}){{/isString}}{{/pathParams}});
let mut local_var_req_builder = local_var_client.request(reqwest::Method::{{{httpMethod}}}, local_var_uri_str.as_str());
{{#queryParams}}
@@ -110,7 +113,7 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration:
{{#authMethods}}
{{#isApiKey}}
{{#isKeyInQuery}}
- if let Some(ref local_var_apikey) = configuration.api_key {
+ if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
@@ -122,7 +125,7 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration:
{{/isApiKey}}
{{/authMethods}}
{{/hasAuthMethods}}
- if let Some(ref local_var_user_agent) = configuration.user_agent {
+ if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
{{#hasHeaderParams}}
@@ -149,7 +152,7 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration:
{{#authMethods}}
{{#isApiKey}}
{{#isKeyInHeader}}
- if let Some(ref local_var_apikey) = configuration.api_key {
+ if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
@@ -161,18 +164,18 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration:
{{/isApiKey}}
{{#isBasic}}
{{#isBasicBasic}}
- if let Some(ref local_var_auth_conf) = configuration.basic_auth {
+ if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
};
{{/isBasicBasic}}
{{#isBasicBearer}}
- if let Some(ref local_var_token) = configuration.bearer_access_token {
+ if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
{{/isBasicBearer}}
{{/isBasic}}
{{#isOAuth}}
- if let Some(ref local_var_token) = configuration.oauth_access_token {
+ if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
{{/isOAuth}}
@@ -208,18 +211,18 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration:
{{^isFile}}
{{#required}}
{{^isNullable}}
- local_var_form = local_var_form.text("{{{baseName}}}", {{{paramName}}}{{#isArray}}.join(","){{/isArray}}.to_string());
+ local_var_form = local_var_form.text("{{{baseName}}}", {{{paramName}}}{{#isArray}}.into_iter().map(|p| p.to_string()).collect::>().join(","){{/isArray}}.to_string());
{{/isNullable}}
{{#isNullable}}
match {{{paramName}}} {
- Some(local_var_param_value) => { local_var_form = local_var_form.text("{{{baseName}}}", local_var_param_value{{#isArray}}.join(","){{/isArray}}.to_string()); },
+ Some(local_var_param_value) => { local_var_form = local_var_form.text("{{{baseName}}}", local_var_param_value{{#isArray}}.into_iter().map(|p| p.to_string()).collect::>().join(","){{/isArray}}.to_string()); },
None => { local_var_form = local_var_form.text("{{{baseName}}}", ""); },
}
{{/isNullable}}
{{/required}}
{{^required}}
if let Some(local_var_param_value) = {{{paramName}}} {
- local_var_form = local_var_form.text("{{{baseName}}}", local_var_param_value{{#isArray}}.join(","){{/isArray}}.to_string());
+ local_var_form = local_var_form.text("{{{baseName}}}", local_var_param_value{{#isArray}}.into_iter().map(|p| p.to_string()).collect::>().join(","){{/isArray}}.to_string());
}
{{/required}}
{{/isFile}}
@@ -252,18 +255,18 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration:
{{^isFile}}
{{#required}}
{{^isNullable}}
- local_var_form_params.insert("{{{baseName}}}", {{{paramName}}}{{#isArray}}.join(","){{/isArray}}.to_string());
+ local_var_form_params.insert("{{{baseName}}}", {{{paramName}}}{{#isArray}}.into_iter().map(|p| p.to_string()).collect::>().join(","){{/isArray}}.to_string());
{{/isNullable}}
{{#isNullable}}
match {{{paramName}}} {
- Some(local_var_param_value) => { local_var_form_params.insert("{{{baseName}}}", local_var_param_value{{#isArray}}.join(","){{/isArray}}.to_string()); },
+ Some(local_var_param_value) => { local_var_form_params.insert("{{{baseName}}}", local_var_param_value{{#isArray}}.into_iter().map(|p| p.to_string()).collect::>().join(","){{/isArray}}.to_string()); },
None => { local_var_form_params.insert("{{{baseName}}}", ""); },
}
{{/isNullable}}
{{/required}}
{{^required}}
if let Some(local_var_param_value) = {{{paramName}}} {
- local_var_form_params.insert("{{{baseName}}}", local_var_param_value{{#isArray}}.join(","){{/isArray}}.to_string());
+ local_var_form_params.insert("{{{baseName}}}", local_var_param_value{{#isArray}}.into_iter().map(|p| p.to_string()).collect::>().join(","){{/isArray}}.to_string());
}
{{/required}}
{{/isFile}}
diff --git a/modules/openapi-generator/src/main/resources/scala-httpclient/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/scala-httpclient/git_push.sh.mustache
index 305f9c115ce..0e3776ae6dd 100755
--- a/modules/openapi-generator/src/main/resources/scala-httpclient/git_push.sh.mustache
+++ b/modules/openapi-generator/src/main/resources/scala-httpclient/git_push.sh.mustache
@@ -38,14 +38,14 @@ git add .
git commit -m "$release_note"
# Sets the new remote
-git_remote=`git remote`
+git_remote=$(git remote)
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
diff --git a/modules/openapi-generator/src/main/resources/swift4/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/swift4/git_push.sh.mustache
index 305f9c115ce..0e3776ae6dd 100755
--- a/modules/openapi-generator/src/main/resources/swift4/git_push.sh.mustache
+++ b/modules/openapi-generator/src/main/resources/swift4/git_push.sh.mustache
@@ -38,14 +38,14 @@ git add .
git commit -m "$release_note"
# Sets the new remote
-git_remote=`git remote`
+git_remote=$(git remote)
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
diff --git a/modules/openapi-generator/src/main/resources/swift5/APIs.mustache b/modules/openapi-generator/src/main/resources/swift5/APIs.mustache
index f931988cf9f..5066c60a6a8 100644
--- a/modules/openapi-generator/src/main/resources/swift5/APIs.mustache
+++ b/modules/openapi-generator/src/main/resources/swift5/APIs.mustache
@@ -4,15 +4,19 @@
// https://openapi-generator.tech
//
-import Foundation
-{{#useVapor}}
+import Foundation{{#useVapor}}
import Vapor
-{{/useVapor}}
+{{/useVapor}}{{^removeMigrationProjectNameClass}}
-@available(*, deprecated, renamed: "{{projectName}}")
-{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} typealias {{projectName}}API = {{projectName}}
+// We reverted the change of {{projectName}}API to {{projectName}} introduced in https://github.com/OpenAPITools/openapi-generator/pull/9624
+// Because it was causing the following issue https://github.com/OpenAPITools/openapi-generator/issues/9953
+// If you are affected by this issue, please consider removing the following two lines,
+// By setting the option removeMigrationProjectNameClass to true in the generator
+@available(*, deprecated, renamed: "{{projectName}}API")
+{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} typealias {{projectName}} = {{projectName}}API
+{{/removeMigrationProjectNameClass}}
-{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} class {{projectName}} {
+{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} class {{projectName}}API {
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} static var basePath = "{{{basePath}}}"
{{#useVapor}}
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} static var customHeaders: HTTPHeaders = [:]
@@ -44,7 +48,7 @@ import Vapor
self.parameters = parameters
self.headers = headers
- addHeaders({{projectName}}.customHeaders)
+ addHeaders({{projectName}}API.customHeaders)
}
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} func addHeaders(_ aHeaders: [String: String]) {
@@ -53,7 +57,7 @@ import Vapor
}
}
- {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} func execute(_ apiResponseQueue: DispatchQueue = {{projectName}}.apiResponseQueue, _ completion: @escaping (_ result: Swift.Result, Error>) -> Void) { }
+ {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} func execute(_ apiResponseQueue: DispatchQueue = {{projectName}}API.apiResponseQueue, _ completion: @escaping (_ result: Swift.Result, Error>) -> Void) { }
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} func addHeader(name: String, value: String) -> Self {
if !value.isEmpty {
@@ -63,7 +67,7 @@ import Vapor
}
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} func addCredential() -> Self {
- credential = {{projectName}}.credential
+ credential = {{projectName}}API.credential
return self
}
}
diff --git a/modules/openapi-generator/src/main/resources/swift5/Cartfile.mustache b/modules/openapi-generator/src/main/resources/swift5/Cartfile.mustache
index 4ef8c318306..ddc84910bba 100644
--- a/modules/openapi-generator/src/main/resources/swift5/Cartfile.mustache
+++ b/modules/openapi-generator/src/main/resources/swift5/Cartfile.mustache
@@ -1,4 +1,4 @@
-{{#useAlamofire}}github "Alamofire/Alamofire" ~> 5.4.3{{/useAlamofire}}{{#usePromiseKit}}
+github "Flight-School/AnyCodable" ~> 0.6.1{{#useAlamofire}}
+github "Alamofire/Alamofire" ~> 5.4.3{{/useAlamofire}}{{#usePromiseKit}}
github "mxcl/PromiseKit" ~> 6.15.3{{/usePromiseKit}}{{#useRxSwift}}
github "ReactiveX/RxSwift" ~> 6.2.0{{/useRxSwift}}
-github "Flight-School/AnyCodable" ~> 0.6.1
diff --git a/modules/openapi-generator/src/main/resources/swift5/Configuration.mustache b/modules/openapi-generator/src/main/resources/swift5/Configuration.mustache
index d6bbdc0ae26..d563d11b4ac 100644
--- a/modules/openapi-generator/src/main/resources/swift5/Configuration.mustache
+++ b/modules/openapi-generator/src/main/resources/swift5/Configuration.mustache
@@ -8,10 +8,10 @@ import Foundation{{#useVapor}}
import Vapor{{/useVapor}}
{{#swiftUseApiNamespace}}
-@available(*, deprecated, renamed: "{{projectName}}.Configuration")
-{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} typealias Configuration = {{projectName}}.Configuration
+@available(*, deprecated, renamed: "{{projectName}}API.Configuration")
+{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} typealias Configuration = {{projectName}}API.Configuration
-extension {{projectName}} {
+extension {{projectName}}API {
{{/swiftUseApiNamespace}}
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} class Configuration {
{{#useVapor}}{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} static var apiClient: Vapor.Client? = nil
diff --git a/modules/openapi-generator/src/main/resources/swift5/Extensions.mustache b/modules/openapi-generator/src/main/resources/swift5/Extensions.mustache
index d7316c9b8c3..7f5d8b582f7 100644
--- a/modules/openapi-generator/src/main/resources/swift5/Extensions.mustache
+++ b/modules/openapi-generator/src/main/resources/swift5/Extensions.mustache
@@ -235,5 +235,4 @@ extension Set: RequestDecodable where Element: Content {
extension Set: Content where Element: Content { }
-extension AnyCodable: Content {}
-{{/useVapor}}
+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 fe7665124f4..c84db4b5c77 100644
--- a/modules/openapi-generator/src/main/resources/swift5/Package.swift.mustache
+++ b/modules/openapi-generator/src/main/resources/swift5/Package.swift.mustache
@@ -35,15 +35,15 @@ let package = Package(
{{#useAlamofire}}
.package(url: "https://github.com/Alamofire/Alamofire", from: "5.4.3"),
{{/useAlamofire}}
- {{#useVapor}}
- .package(url: "https://github.com/vapor/vapor", from: "4.0.0")
- {{/useVapor}}
{{#usePromiseKit}}
.package(url: "https://github.com/mxcl/PromiseKit", from: "6.15.3"),
{{/usePromiseKit}}
{{#useRxSwift}}
.package(url: "https://github.com/ReactiveX/RxSwift", from: "6.2.0"),
{{/useRxSwift}}
+ {{#useVapor}}
+ .package(url: "https://github.com/vapor/vapor", from: "4.0.0")
+ {{/useVapor}}
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
diff --git a/modules/openapi-generator/src/main/resources/swift5/Podspec.mustache b/modules/openapi-generator/src/main/resources/swift5/Podspec.mustache
index b07a1d50736..29bd02cefde 100644
--- a/modules/openapi-generator/src/main/resources/swift5/Podspec.mustache
+++ b/modules/openapi-generator/src/main/resources/swift5/Podspec.mustache
@@ -33,14 +33,14 @@ Pod::Spec.new do |s|
s.documentation_url = '{{.}}'
{{/podDocumentationURL}}
s.source_files = '{{swiftPackagePath}}{{^swiftPackagePath}}{{#useSPMFileStructure}}Sources/{{projectName}}{{/useSPMFileStructure}}{{^useSPMFileStructure}}{{projectName}}/Classes{{/useSPMFileStructure}}{{/swiftPackagePath}}/**/*.swift'
+ s.dependency 'AnyCodable-FlightSchool', '~> 0.6.1'
+ {{#useAlamofire}}
+ s.dependency 'Alamofire', '~> 5.4.3'
+ {{/useAlamofire}}
{{#usePromiseKit}}
s.dependency 'PromiseKit/CorePromise', '~> 6.15.3'
{{/usePromiseKit}}
{{#useRxSwift}}
s.dependency 'RxSwift', '~> 6.2.0'
{{/useRxSwift}}
- {{#useAlamofire}}
- s.dependency 'Alamofire', '~> 5.4.3'
- {{/useAlamofire}}
- s.dependency 'AnyCodable-FlightSchool', '~> 0.6.1'
end
diff --git a/modules/openapi-generator/src/main/resources/swift5/XcodeGen.mustache b/modules/openapi-generator/src/main/resources/swift5/XcodeGen.mustache
index 49e47f72312..31f01b8bedd 100644
--- a/modules/openapi-generator/src/main/resources/swift5/XcodeGen.mustache
+++ b/modules/openapi-generator/src/main/resources/swift5/XcodeGen.mustache
@@ -13,6 +13,6 @@ targets:
scheme: {}
dependencies:
- carthage: AnyCodable{{#useAlamofire}}
- - carthage: Alamofire{{/useAlamofire}}{{#useRxSwift}}
- - carthage: RxSwift{{/useRxSwift}}{{#usePromiseKit}}
- - carthage: PromiseKit{{/usePromiseKit}}
+ - carthage: Alamofire{{/useAlamofire}}{{#usePromiseKit}}
+ - carthage: PromiseKit{{/usePromiseKit}}{{#useRxSwift}}
+ - carthage: RxSwift{{/useRxSwift}}
diff --git a/modules/openapi-generator/src/main/resources/swift5/api.mustache b/modules/openapi-generator/src/main/resources/swift5/api.mustache
index 27d60d7fb5b..b3d89985a46 100644
--- a/modules/openapi-generator/src/main/resources/swift5/api.mustache
+++ b/modules/openapi-generator/src/main/resources/swift5/api.mustache
@@ -16,7 +16,7 @@ import Vapor{{/useVapor}}
import AnyCodable
#endif{{#swiftUseApiNamespace}}
-extension {{projectName}} {
+extension {{projectName}}API {
{{/swiftUseApiNamespace}}
{{#description}}
@@ -55,7 +55,7 @@ extension {{projectName}} {
{{#isDeprecated}}
@available(*, deprecated, message: "This operation is deprecated.")
{{/isDeprecated}}
- {{#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}}apiResponseQueue: DispatchQueue = {{projectName}}.apiResponseQueue, completion: @escaping ((_ data: {{{returnType}}}{{^returnType}}Void{{/returnType}}?, _ error: Error?) -> Void)) {
+ {{#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}}apiResponseQueue: DispatchQueue = {{projectName}}API.apiResponseQueue, completion: @escaping ((_ data: {{{returnType}}}{{^returnType}}Void{{/returnType}}?, _ error: Error?) -> Void)) {
{{operationId}}WithRequestBuilder({{#allParams}}{{paramName}}: {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}).execute(apiResponseQueue) { result -> Void in
switch result {
{{#returnType}}
@@ -88,7 +88,7 @@ extension {{projectName}} {
{{#isDeprecated}}
@available(*, deprecated, message: "This operation is deprecated.")
{{/isDeprecated}}
- {{#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}}apiResponseQueue: DispatchQueue = {{projectName}}.apiResponseQueue) -> Promise<{{{returnType}}}{{^returnType}}Void{{/returnType}}> {
+ {{#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}}apiResponseQueue: DispatchQueue = {{projectName}}API.apiResponseQueue) -> Promise<{{{returnType}}}{{^returnType}}Void{{/returnType}}> {
let deferred = Promise<{{{returnType}}}{{^returnType}}Void{{/returnType}}>.pending()
{{operationId}}WithRequestBuilder({{#allParams}}{{paramName}}: {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}).execute(apiResponseQueue) { result -> Void in
switch result {
@@ -119,7 +119,7 @@ extension {{projectName}} {
{{#isDeprecated}}
@available(*, deprecated, message: "This operation is deprecated.")
{{/isDeprecated}}
- {{#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}}apiResponseQueue: DispatchQueue = {{projectName}}.apiResponseQueue) -> Observable<{{{returnType}}}{{^returnType}}Void{{/returnType}}> {
+ {{#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}}apiResponseQueue: DispatchQueue = {{projectName}}API.apiResponseQueue) -> Observable<{{{returnType}}}{{^returnType}}Void{{/returnType}}> {
return Observable.create { observer -> Disposable in
{{operationId}}WithRequestBuilder({{#allParams}}{{paramName}}: {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}).execute(apiResponseQueue) { result -> Void in
switch result {
@@ -154,7 +154,7 @@ extension {{projectName}} {
@available(*, deprecated, message: "This operation is deprecated.")
{{/isDeprecated}}
@available(OSX 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
- {{#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}}apiResponseQueue: DispatchQueue = {{projectName}}.apiResponseQueue) -> AnyPublisher<{{{returnType}}}{{^returnType}}Void{{/returnType}}, Error> {
+ {{#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}}apiResponseQueue: DispatchQueue = {{projectName}}API.apiResponseQueue) -> AnyPublisher<{{{returnType}}}{{^returnType}}Void{{/returnType}}, Error> {
return Future<{{{returnType}}}{{^returnType}}Void{{/returnType}}, Error>.init { promise in
{{operationId}}WithRequestBuilder({{#allParams}}{{paramName}}: {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}).execute(apiResponseQueue) { result -> Void in
switch result {
@@ -186,7 +186,7 @@ extension {{projectName}} {
{{#isDeprecated}}
@available(*, deprecated, message: "This operation is deprecated.")
{{/isDeprecated}}
- open 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}}apiResponseQueue: DispatchQueue = {{projectName}}.apiResponseQueue, completion: @escaping ((_ result: Swift.Result<{{{returnType}}}{{^returnType}}Void{{/returnType}}, Error>) -> Void)) {
+ open 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}}apiResponseQueue: DispatchQueue = {{projectName}}API.apiResponseQueue, completion: @escaping ((_ result: Swift.Result<{{{returnType}}}{{^returnType}}Void{{/returnType}}, Error>) -> Void)) {
{{operationId}}WithRequestBuilder({{#allParams}}{{paramName}}: {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}).execute(apiResponseQueue) { result -> Void in
switch result {
{{#returnType}}
@@ -231,19 +231,19 @@ extension {{projectName}} {
{{#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 {
+ {{#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}}API.customHeaders, beforeSend: (inout ClientRequest) throws -> () = { _ in }) -> EventLoopFuture {
{{^pathParams}}let{{/pathParams}}{{#pathParams}}{{#-first}}var{{/-first}}{{/pathParams}} localVariablePath = "{{{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) ?? ""
localVariablePath = localVariablePath.replacingOccurrences(of: "{{=<% %>=}}{<%baseName%>}<%={{ }}=%>", with: {{paramName}}PostEscape, options: .literal, range: nil){{/pathParams}}
- let localVariableURLString = {{projectName}}.basePath + localVariablePath
+ let localVariableURLString = {{projectName}}API.basePath + localVariablePath
- guard let localVariableApiClient = {{#swiftUseApiNamespace}}{{projectName}}.{{/swiftUseApiNamespace}}Configuration.apiClient else {
+ guard let localVariableApiClient = {{#swiftUseApiNamespace}}{{projectName}}API.{{/swiftUseApiNamespace}}Configuration.apiClient else {
fatalError("Configuration.apiClient is not set.")
}
return localVariableApiClient.send(.{{httpMethod}}, headers: headers, to: URI(string: localVariableURLString)) { localVariableRequest in
- try {{#swiftUseApiNamespace}}{{projectName}}.{{/swiftUseApiNamespace}}Configuration.apiWrapper(&localVariableRequest)
+ try {{#swiftUseApiNamespace}}{{projectName}}API.{{/swiftUseApiNamespace}}Configuration.apiWrapper(&localVariableRequest)
{{#hasHeaderParams}}{{#headerParams}}
localVariableRequest.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}}
@@ -311,7 +311,7 @@ extension {{projectName}} {
{{#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}}> {
+ {{#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}}API.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}}
@@ -361,7 +361,7 @@ extension {{projectName}} {
let {{paramName}}PreEscape = "\({{#isEnum}}{{paramName}}{{#isContainer}}{{{dataType}}}{{/isContainer}}{{^isContainer}}.rawValue{{/isContainer}}{{/isEnum}}{{^isEnum}}APIHelper.mapValueToPathItem({{paramName}}){{/isEnum}})"
let {{paramName}}PostEscape = {{paramName}}PreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
localVariablePath = localVariablePath.replacingOccurrences(of: "{{=<% %>=}}{<%baseName%>}<%={{ }}=%>", with: {{paramName}}PostEscape, options: .literal, range: nil){{/pathParams}}
- let localVariableURLString = {{projectName}}.basePath + localVariablePath
+ let localVariableURLString = {{projectName}}API.basePath + localVariablePath
{{#bodyParam}}
let localVariableParameters = JSONEncodingHelper.encodingParameters(forEncodableObject: {{paramName}})
{{/bodyParam}}
@@ -396,7 +396,7 @@ extension {{projectName}} {
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
- let localVariableRequestBuilder: RequestBuilder<{{{returnType}}}{{^returnType}}Void{{/returnType}}>.Type = {{projectName}}.requestBuilderFactory.{{#returnType}}getBuilder(){{/returnType}}{{^returnType}}getNonDecodableBuilder(){{/returnType}}
+ let localVariableRequestBuilder: RequestBuilder<{{{returnType}}}{{^returnType}}Void{{/returnType}}>.Type = {{projectName}}API.requestBuilderFactory.{{#returnType}}getBuilder(){{/returnType}}{{^returnType}}getNonDecodableBuilder(){{/returnType}}
return localVariableRequestBuilder.init(method: "{{httpMethod}}", URLString: (localVariableUrlComponents?.string ?? localVariableURLString), parameters: localVariableParameters, headers: localVariableHeaderParameters)
}
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 3327e1615bf..7d7c58f1dc4 100644
--- a/modules/openapi-generator/src/main/resources/swift5/api_doc.mustache
+++ b/modules/openapi-generator/src/main/resources/swift5/api_doc.mustache
@@ -26,7 +26,7 @@ Method | HTTP request | Description
{{#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}}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}}>
+ {{#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}}API.customHeaders, beforeSend: (inout ClientRequest) throws -> () = { _ in }) -> EventLoopFuture<{{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}>
{{/useVapor}}
```
diff --git a/modules/openapi-generator/src/main/resources/swift5/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/swift5/git_push.sh.mustache
index 305f9c115ce..0e3776ae6dd 100755
--- a/modules/openapi-generator/src/main/resources/swift5/git_push.sh.mustache
+++ b/modules/openapi-generator/src/main/resources/swift5/git_push.sh.mustache
@@ -38,14 +38,14 @@ git add .
git commit -m "$release_note"
# Sets the new remote
-git_remote=`git remote`
+git_remote=$(git remote)
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
diff --git a/modules/openapi-generator/src/main/resources/swift5/libraries/alamofire/AlamofireImplementations.mustache b/modules/openapi-generator/src/main/resources/swift5/libraries/alamofire/AlamofireImplementations.mustache
index 89291f2106d..47305a4f629 100644
--- a/modules/openapi-generator/src/main/resources/swift5/libraries/alamofire/AlamofireImplementations.mustache
+++ b/modules/openapi-generator/src/main/resources/swift5/libraries/alamofire/AlamofireImplementations.mustache
@@ -78,7 +78,7 @@ private var managerStore = SynchronizedDictionary()
return manager.request(URLString, method: method, parameters: parameters, encoding: encoding, headers: HTTPHeaders(headers))
}
- override {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} func execute(_ apiResponseQueue: DispatchQueue = {{projectName}}.apiResponseQueue, _ completion: @escaping (_ result: Swift.Result, Error>) -> Void) {
+ override {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} func execute(_ apiResponseQueue: DispatchQueue = {{projectName}}API.apiResponseQueue, _ completion: @escaping (_ result: Swift.Result, Error>) -> Void) {
let managerId = UUID().uuidString
// Create a new manager for each request to customize its request header
let manager = createAlamofireSession()
diff --git a/modules/openapi-generator/src/main/resources/swift5/libraries/urlsession/URLSessionImplementations.mustache b/modules/openapi-generator/src/main/resources/swift5/libraries/urlsession/URLSessionImplementations.mustache
index 819a27f9c6e..040ff4ed38d 100644
--- a/modules/openapi-generator/src/main/resources/swift5/libraries/urlsession/URLSessionImplementations.mustache
+++ b/modules/openapi-generator/src/main/resources/swift5/libraries/urlsession/URLSessionImplementations.mustache
@@ -93,7 +93,7 @@ private var urlSessionStore = SynchronizedDictionary()
return modifiedRequest
}
- override {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} func execute(_ apiResponseQueue: DispatchQueue = {{projectName}}.apiResponseQueue, _ completion: @escaping (_ result: Swift.Result, Error>) -> Void) {
+ override {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} func execute(_ apiResponseQueue: DispatchQueue = {{projectName}}API.apiResponseQueue, _ completion: @escaping (_ result: Swift.Result, Error>) -> Void) {
let urlSessionId = UUID().uuidString
// Create a new manager for each request to customize its request header
let urlSession = createURLSession()
@@ -250,7 +250,7 @@ private var urlSessionStore = SynchronizedDictionary()
for (key, value) in headers {
httpHeaders[key] = value
}
- for (key, value) in {{projectName}}.customHeaders {
+ for (key, value) in {{projectName}}API.customHeaders {
httpHeaders[key] = value
}
return httpHeaders
diff --git a/modules/openapi-generator/src/main/resources/swift5/model.mustache b/modules/openapi-generator/src/main/resources/swift5/model.mustache
index 80f382f39a3..b6a725d0526 100644
--- a/modules/openapi-generator/src/main/resources/swift5/model.mustache
+++ b/modules/openapi-generator/src/main/resources/swift5/model.mustache
@@ -12,10 +12,10 @@ import AnyCodable
import Vapor{{/useVapor}}
{{#swiftUseApiNamespace}}
-@available(*, deprecated, renamed: "{{projectName}}.{{classname}}")
-{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} typealias {{classname}} = {{projectName}}.{{classname}}
+@available(*, deprecated, renamed: "{{projectName}}API.{{classname}}")
+{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} typealias {{classname}} = {{projectName}}API.{{classname}}
-extension {{projectName}} {
+extension {{projectName}}API {
{{/swiftUseApiNamespace}}
{{#description}}
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 84160ac4167..2ff5a17bb29 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
@@ -3,7 +3,8 @@
import { Inject, Injectable, Optional } from '@angular/core';
import { HttpClient, HttpHeaders, HttpParams,
- HttpResponse, HttpEvent, HttpParameterCodec } from '@angular/common/http';
+ HttpResponse, HttpEvent, HttpParameterCodec{{#httpContextInOptions}}, HttpContext {{/httpContextInOptions}}
+ } from '@angular/common/http';
import { CustomHttpParameterCodec } from '../encoder';
import { Observable } from 'rxjs';
@@ -162,10 +163,10 @@ export class {{classname}} {
* @deprecated
{{/isDeprecated}}
*/
- public {{nickname}}({{^useSingleRequestParameter}}{{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}{{/useSingleRequestParameter}}{{#useSingleRequestParameter}}{{#allParams.0}}requestParameters: {{#prefixParameterInterfaces}}{{classname}}{{/prefixParameterInterfaces}}{{operationIdCamelCase}}RequestParams, {{/allParams.0}}{{/useSingleRequestParameter}}observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: {{#produces}}'{{mediaType}}'{{^-last}} | {{/-last}}{{/produces}}{{^produces}}undefined{{/produces}}}): Observable<{{#returnType}}{{{returnType}}}{{#isResponseTypeFile}}|undefined{{/isResponseTypeFile}}{{/returnType}}{{^returnType}}any{{/returnType}}>;
- public {{nickname}}({{^useSingleRequestParameter}}{{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}{{/useSingleRequestParameter}}{{#useSingleRequestParameter}}{{#allParams.0}}requestParameters: {{#prefixParameterInterfaces}}{{classname}}{{/prefixParameterInterfaces}}{{operationIdCamelCase}}RequestParams, {{/allParams.0}}{{/useSingleRequestParameter}}observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: {{#produces}}'{{mediaType}}'{{^-last}} | {{/-last}}{{/produces}}{{^produces}}undefined{{/produces}}}): Observable>;
- public {{nickname}}({{^useSingleRequestParameter}}{{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}{{/useSingleRequestParameter}}{{#useSingleRequestParameter}}{{#allParams.0}}requestParameters: {{#prefixParameterInterfaces}}{{classname}}{{/prefixParameterInterfaces}}{{operationIdCamelCase}}RequestParams, {{/allParams.0}}{{/useSingleRequestParameter}}observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: {{#produces}}'{{mediaType}}'{{^-last}} | {{/-last}}{{/produces}}{{^produces}}undefined{{/produces}}}): Observable>;
- public {{nickname}}({{^useSingleRequestParameter}}{{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}{{/useSingleRequestParameter}}{{#useSingleRequestParameter}}{{#allParams.0}}requestParameters: {{#prefixParameterInterfaces}}{{classname}}{{/prefixParameterInterfaces}}{{operationIdCamelCase}}RequestParams, {{/allParams.0}}{{/useSingleRequestParameter}}observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: {{#produces}}'{{mediaType}}'{{^-last}} | {{/-last}}{{/produces}}{{^produces}}undefined{{/produces}}}): Observable {
+ public {{nickname}}({{^useSingleRequestParameter}}{{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}{{/useSingleRequestParameter}}{{#useSingleRequestParameter}}{{#allParams.0}}requestParameters: {{#prefixParameterInterfaces}}{{classname}}{{/prefixParameterInterfaces}}{{operationIdCamelCase}}RequestParams, {{/allParams.0}}{{/useSingleRequestParameter}}observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: {{#produces}}'{{mediaType}}'{{^-last}} | {{/-last}}{{/produces}}{{^produces}}undefined{{/produces}},{{#httpContextInOptions}} context?: HttpContext{{/httpContextInOptions}}}): Observable<{{#returnType}}{{{returnType}}}{{#isResponseTypeFile}}|undefined{{/isResponseTypeFile}}{{/returnType}}{{^returnType}}any{{/returnType}}>;
+ public {{nickname}}({{^useSingleRequestParameter}}{{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}{{/useSingleRequestParameter}}{{#useSingleRequestParameter}}{{#allParams.0}}requestParameters: {{#prefixParameterInterfaces}}{{classname}}{{/prefixParameterInterfaces}}{{operationIdCamelCase}}RequestParams, {{/allParams.0}}{{/useSingleRequestParameter}}observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: {{#produces}}'{{mediaType}}'{{^-last}} | {{/-last}}{{/produces}}{{^produces}}undefined{{/produces}},{{#httpContextInOptions}} context?: HttpContext{{/httpContextInOptions}}}): Observable>;
+ public {{nickname}}({{^useSingleRequestParameter}}{{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}{{/useSingleRequestParameter}}{{#useSingleRequestParameter}}{{#allParams.0}}requestParameters: {{#prefixParameterInterfaces}}{{classname}}{{/prefixParameterInterfaces}}{{operationIdCamelCase}}RequestParams, {{/allParams.0}}{{/useSingleRequestParameter}}observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: {{#produces}}'{{mediaType}}'{{^-last}} | {{/-last}}{{/produces}}{{^produces}}undefined{{/produces}},{{#httpContextInOptions}} context?: HttpContext{{/httpContextInOptions}}}): Observable>;
+ public {{nickname}}({{^useSingleRequestParameter}}{{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}{{/useSingleRequestParameter}}{{#useSingleRequestParameter}}{{#allParams.0}}requestParameters: {{#prefixParameterInterfaces}}{{classname}}{{/prefixParameterInterfaces}}{{operationIdCamelCase}}RequestParams, {{/allParams.0}}{{/useSingleRequestParameter}}observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: {{#produces}}'{{mediaType}}'{{^-last}} | {{/-last}}{{/produces}}{{^produces}}undefined{{/produces}},{{#httpContextInOptions}} context?: HttpContext{{/httpContextInOptions}}}): Observable {
{{#allParams}}
{{#useSingleRequestParameter}}
const {{paramName}} = requestParameters.{{paramName}};
@@ -266,6 +267,13 @@ export class {{classname}} {
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
}
+{{#httpContextInOptions}}
+ let localVarHttpContext: HttpContext | undefined = options && options.context;
+ if (localVarHttpContext === undefined) {
+ localVarHttpContext = new HttpContext();
+ }
+{{/httpContextInOptions}}
+
{{#bodyParam}}
{{- duplicated below, don't forget to change}}
// to determine the Content-Type header
@@ -348,6 +356,9 @@ export class {{classname}} {
return this.httpClient.{{httpMethod}}{{^isResponseFile}}<{{#returnType}}{{{returnType}}}{{#isResponseTypeFile}}|undefined{{/isResponseTypeFile}}{{/returnType}}{{^returnType}}any{{/returnType}}>{{/isResponseFile}}(`${this.configuration.basePath}{{{path}}}`,{{#isBodyAllowed}}
{{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}{{#hasFormParams}}localVarConvertFormParamsToString ? localVarFormParams.toString() : localVarFormParams{{/hasFormParams}}{{^hasFormParams}}null{{/hasFormParams}}{{/bodyParam}},{{/isBodyAllowed}}
{
+ {{#httpContextInOptions}}
+ context: localVarHttpContext,
+ {{/httpContextInOptions}}
{{#hasQueryParams}}
params: localVarQueryParameters,
{{/hasQueryParams}}
diff --git a/modules/openapi-generator/src/main/resources/typescript-angular/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/typescript-angular/git_push.sh.mustache
index 305f9c115ce..0e3776ae6dd 100755
--- a/modules/openapi-generator/src/main/resources/typescript-angular/git_push.sh.mustache
+++ b/modules/openapi-generator/src/main/resources/typescript-angular/git_push.sh.mustache
@@ -38,14 +38,14 @@ git add .
git commit -m "$release_note"
# Sets the new remote
-git_remote=`git remote`
+git_remote=$(git remote)
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
diff --git a/modules/openapi-generator/src/main/resources/typescript-angularjs/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/typescript-angularjs/git_push.sh.mustache
index 305f9c115ce..0e3776ae6dd 100755
--- a/modules/openapi-generator/src/main/resources/typescript-angularjs/git_push.sh.mustache
+++ b/modules/openapi-generator/src/main/resources/typescript-angularjs/git_push.sh.mustache
@@ -38,14 +38,14 @@ git add .
git commit -m "$release_note"
# Sets the new remote
-git_remote=`git remote`
+git_remote=$(git remote)
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
diff --git a/modules/openapi-generator/src/main/resources/typescript-aurelia/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/typescript-aurelia/git_push.sh.mustache
index 305f9c115ce..0e3776ae6dd 100755
--- a/modules/openapi-generator/src/main/resources/typescript-aurelia/git_push.sh.mustache
+++ b/modules/openapi-generator/src/main/resources/typescript-aurelia/git_push.sh.mustache
@@ -38,14 +38,14 @@ git add .
git commit -m "$release_note"
# Sets the new remote
-git_remote=`git remote`
+git_remote=$(git remote)
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
diff --git a/modules/openapi-generator/src/main/resources/typescript-axios/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/typescript-axios/git_push.sh.mustache
index 305f9c115ce..0e3776ae6dd 100755
--- a/modules/openapi-generator/src/main/resources/typescript-axios/git_push.sh.mustache
+++ b/modules/openapi-generator/src/main/resources/typescript-axios/git_push.sh.mustache
@@ -38,14 +38,14 @@ git add .
git commit -m "$release_note"
# Sets the new remote
-git_remote=`git remote`
+git_remote=$(git remote)
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
diff --git a/modules/openapi-generator/src/main/resources/typescript-axios/package.mustache b/modules/openapi-generator/src/main/resources/typescript-axios/package.mustache
index 6c6114ebcf0..266e9de70b7 100644
--- a/modules/openapi-generator/src/main/resources/typescript-axios/package.mustache
+++ b/modules/openapi-generator/src/main/resources/typescript-axios/package.mustache
@@ -18,7 +18,7 @@
"prepublishOnly": "npm run build"
},
"dependencies": {
- "axios": "^0.21.1"
+ "axios": "^0.21.4"
},
"devDependencies": {
"@types/node": "^12.11.5",
diff --git a/modules/openapi-generator/src/main/resources/typescript-inversify/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/typescript-inversify/git_push.sh.mustache
index 305f9c115ce..0e3776ae6dd 100755
--- a/modules/openapi-generator/src/main/resources/typescript-inversify/git_push.sh.mustache
+++ b/modules/openapi-generator/src/main/resources/typescript-inversify/git_push.sh.mustache
@@ -38,14 +38,14 @@ git add .
git commit -m "$release_note"
# Sets the new remote
-git_remote=`git remote`
+git_remote=$(git remote)
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
diff --git a/modules/openapi-generator/src/main/resources/typescript-jquery/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/typescript-jquery/git_push.sh.mustache
index 305f9c115ce..0e3776ae6dd 100755
--- a/modules/openapi-generator/src/main/resources/typescript-jquery/git_push.sh.mustache
+++ b/modules/openapi-generator/src/main/resources/typescript-jquery/git_push.sh.mustache
@@ -38,14 +38,14 @@ git add .
git commit -m "$release_note"
# Sets the new remote
-git_remote=`git remote`
+git_remote=$(git remote)
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
diff --git a/modules/openapi-generator/src/main/resources/typescript-nestjs/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/typescript-nestjs/git_push.sh.mustache
index 305f9c115ce..0e3776ae6dd 100755
--- a/modules/openapi-generator/src/main/resources/typescript-nestjs/git_push.sh.mustache
+++ b/modules/openapi-generator/src/main/resources/typescript-nestjs/git_push.sh.mustache
@@ -38,14 +38,14 @@ git add .
git commit -m "$release_note"
# Sets the new remote
-git_remote=`git remote`
+git_remote=$(git remote)
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
diff --git a/modules/openapi-generator/src/main/resources/typescript-node/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/typescript-node/git_push.sh.mustache
index 305f9c115ce..0e3776ae6dd 100755
--- a/modules/openapi-generator/src/main/resources/typescript-node/git_push.sh.mustache
+++ b/modules/openapi-generator/src/main/resources/typescript-node/git_push.sh.mustache
@@ -38,14 +38,14 @@ git add .
git commit -m "$release_note"
# Sets the new remote
-git_remote=`git remote`
+git_remote=$(git remote)
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
diff --git a/modules/openapi-generator/src/main/resources/typescript/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/typescript/git_push.sh.mustache
index 81aaba42129..0c82a773770 100755
--- a/modules/openapi-generator/src/main/resources/typescript/git_push.sh.mustache
+++ b/modules/openapi-generator/src/main/resources/typescript/git_push.sh.mustache
@@ -32,14 +32,14 @@ git add .
git commit -m "$release_note"
# Sets the new remote
-git_remote=`git remote`
+git_remote=$(git remote)
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@github.com/${git_user_id}/${git_repo_id}.git
fi
fi
diff --git a/modules/openapi-generator/src/main/resources/wsdl-schema/wsdl-converter.mustache b/modules/openapi-generator/src/main/resources/wsdl-schema/wsdl-converter.mustache
index d3bc158cd59..0de132567bf 100644
--- a/modules/openapi-generator/src/main/resources/wsdl-schema/wsdl-converter.mustache
+++ b/modules/openapi-generator/src/main/resources/wsdl-schema/wsdl-converter.mustache
@@ -30,7 +30,7 @@
{{/apiInfo}}
{{#models}}
{{#model}}
- {{^vendorExtensions.x-is-openapimodel-enum}}
+ {{^isEnum}}
{{#description}}
@@ -65,6 +65,10 @@
{{/vendorExtensions.x-prop-has-minormax}}
{{^vendorExtensions.x-prop-has-minormax}}
+ {{#vendorExtensions.x-oneof-schemas}}
+
+ {{/vendorExtensions.x-oneof-schemas}}
+ {{^vendorExtensions.x-oneof-schemas}}
{{#isContainer}}
{{/isContainer}}
@@ -77,11 +81,12 @@
{{/description}}
+ {{/vendorExtensions.x-oneof-schemas}}
{{/vendorExtensions.x-prop-has-minormax}}
{{/vars}}
- {{/vendorExtensions.x-is-openapimodel-enum}}
+ {{/isEnum}}
{{/model}}
{{/models}}
{{#models}}
@@ -206,7 +211,7 @@
{{#message}}
-
+
{{message}}
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/ArchUnitRulesTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/ArchUnitRulesTest.java
new file mode 100644
index 00000000000..0a9d7a95abf
--- /dev/null
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/ArchUnitRulesTest.java
@@ -0,0 +1,52 @@
+package org.openapitools.codegen;
+
+import com.tngtech.archunit.core.domain.JavaClasses;
+import com.tngtech.archunit.core.domain.JavaModifier;
+import com.tngtech.archunit.core.importer.ClassFileImporter;
+import com.tngtech.archunit.lang.ArchRule;
+import org.junit.Test;
+import org.slf4j.Logger;
+
+import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.*;
+
+public class ArchUnitRulesTest {
+
+ @Test
+ public void testLoggersAreNotPublicFinalAndNotStatic() {
+ final JavaClasses importedClasses = new ClassFileImporter()
+ .importPackages("org.openapitools.codegen.languages");
+
+ ArchUnitRulesTest.LOGGERS_SHOULD_BE_NOT_PUBLIC_NOT_STATIC_AND_FINAL.check(importedClasses);
+ }
+
+ @Test
+ public void abstractClassesAreAbstract() {
+ final JavaClasses importedClasses = new ClassFileImporter()
+ .importPackages("org.openapitools.codegen.languages");
+
+ ArchUnitRulesTest.ABSTRACT_CLASS_MUST_BE_ABSTRACT.check(importedClasses);
+ }
+
+ /**
+ * Making loggers not static decreases memory consumption when running generator:
+ * https://github.com/OpenAPITools/openapi-generator/pull/8799
+ */
+ public static final ArchRule LOGGERS_SHOULD_BE_NOT_PUBLIC_NOT_STATIC_AND_FINAL =
+ fields()
+ .that()
+ .haveRawType(Logger.class)
+ .should().notBePublic()
+ .andShould().notBeStatic()
+ .andShould().beFinal()
+ .because("Code generators are most often used once per program lifetime, " +
+ "so making them all static will cause higher memory consumption. " +
+ "See PR #8799");
+
+
+ public static final ArchRule ABSTRACT_CLASS_MUST_BE_ABSTRACT =
+ classes()
+ .that()
+ .haveSimpleNameContaining("Abstract").or().haveSimpleNameContaining("abstract")
+ .should()
+ .haveModifier(JavaModifier.ABSTRACT);
+}
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/AbstractJavaCodegenExampleValuesTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/AbstractJavaCodegenExampleValuesTest.java
new file mode 100644
index 00000000000..d9f451a462e
--- /dev/null
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/AbstractJavaCodegenExampleValuesTest.java
@@ -0,0 +1,157 @@
+/*
+ * Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
+ * Copyright 2018 SmartBear Software
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openapitools.codegen.java;
+
+import org.openapitools.codegen.CodegenParameter;
+import org.openapitools.codegen.CodegenProperty;
+import org.openapitools.codegen.CodegenType;
+import org.openapitools.codegen.languages.AbstractJavaCodegen;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import java.util.Arrays;
+import java.util.Collections;
+
+public class AbstractJavaCodegenExampleValuesTest {
+
+ private final AbstractJavaCodegen fakeJavaCodegen = new P_AbstractJavaCodegen();
+
+ @Test
+ void referencedEnumTakeFirstName() {
+ final CodegenParameter p = new CodegenParameter();
+ p.allowableValues = Collections.singletonMap("values", Arrays.asList("first", "second"));
+ p.dataType = "WrappedEnum";
+
+ fakeJavaCodegen.setParameterExampleValue(p);
+ Assert.assertEquals(p.example, "WrappedEnum.fromValue(\"first\")");
+ }
+
+ @Test
+ void inlineEnum() {
+ final CodegenParameter p = new CodegenParameter();
+ p.allowableValues = Collections.singletonMap("values", Arrays.asList("first", "second"));
+ p.isEnum = true;
+ p.dataType = "String";
+
+ fakeJavaCodegen.setParameterExampleValue(p);
+ Assert.assertEquals(p.example, "\"first\"");
+ }
+
+ @Test
+ void inlineEnumArray() {
+ final CodegenParameter p = new CodegenParameter();
+ p.allowableValues = Collections.singletonMap("values", Arrays.asList("first", "second"));
+ p.isEnum = true;
+ p.isArray = true;
+ p.dataType = "List";
+ p.items = new CodegenProperty();
+
+ fakeJavaCodegen.setParameterExampleValue(p);
+ Assert.assertEquals(p.example, "Arrays.asList()");
+ }
+
+ @Test
+ void dateDefault() {
+ final CodegenParameter p = new CodegenParameter();
+ p.isDate = true;
+ p.dataType = "LocalDate";
+
+ fakeJavaCodegen.setParameterExampleValue(p);
+ Assert.assertEquals(p.example, "LocalDate.now()");
+ }
+
+ @Test
+ void dateGivenExample() {
+ final CodegenParameter p = new CodegenParameter();
+ p.isDate = true;
+ p.dataType = "LocalDate";
+ p.example = "2017-03-30";
+
+ fakeJavaCodegen.setParameterExampleValue(p);
+ Assert.assertEquals(p.example, "LocalDate.parse(\"2017-03-30\")");
+ }
+
+ @Test
+ void dateTimeDefault() {
+ final CodegenParameter p = new CodegenParameter();
+ p.isDateTime = true;
+ p.dataType = "OffsetDateTime";
+
+ fakeJavaCodegen.setParameterExampleValue(p);
+ Assert.assertEquals(p.example, "OffsetDateTime.now()");
+ }
+
+ @Test
+ void dateTimeGivenExample() {
+ final CodegenParameter p = new CodegenParameter();
+ p.isDateTime = true;
+ p.dataType = "OffsetDateTime";
+ p.example = "2007-12-03T10:15:30+01:00";
+
+ fakeJavaCodegen.setParameterExampleValue(p);
+ Assert.assertEquals(p.example, "OffsetDateTime.parse(\"2007-12-03T10:15:30+01:00\")");
+ }
+
+ @Test
+ void uuidDefault() {
+ final CodegenParameter p = new CodegenParameter();
+ p.isUuid = true;
+ p.dataType = "UUID";
+
+ fakeJavaCodegen.setParameterExampleValue(p);
+ Assert.assertEquals(p.example, "UUID.randomUUID()");
+ }
+
+ @Test
+ void uuidGivenExample() {
+ final CodegenParameter p = new CodegenParameter();
+ p.isUuid = true;
+ p.dataType = "UUID";
+ p.example = "13b48713-b931-45ea-bd60-b07491245960";
+
+ fakeJavaCodegen.setParameterExampleValue(p);
+ Assert.assertEquals(p.example, "UUID.fromString(\"13b48713-b931-45ea-bd60-b07491245960\")");
+ }
+
+ private static class P_AbstractJavaCodegen extends AbstractJavaCodegen {
+ @Override
+ public CodegenType getTag() {
+ return null;
+ }
+
+ @Override
+ public String getName() {
+ return null;
+ }
+
+ @Override
+ public String getHelp() {
+ return null;
+ }
+
+ /**
+ * Gets artifact version.
+ * Only for testing purposes.
+ *
+ * @return version
+ */
+ public String getArtifactVersion() {
+ return this.artifactVersion;
+ }
+ }
+}
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java
index 48fa9cadcfb..f034760ea96 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java
@@ -1164,4 +1164,62 @@ public class JavaClientCodegenTest {
"formParams.add(\"file\", file);"
);
}
+
+ /**
+ * See https://github.com/OpenAPITools/openapi-generator/issues/8352
+ */
+ @Test
+ public void testRestTemplateWithFreeFormInQueryParameters() throws IOException {
+ final Map properties = new HashMap<>();
+ properties.put(AbstractJavaCodegen.JAVA8_MODE, true);
+ properties.put(CodegenConstants.API_PACKAGE, "xyz.abcdef.api");
+
+ final File output = Files.createTempDirectory("test")
+ .toFile();
+ output.deleteOnExit();
+
+ final CodegenConfigurator configurator = new CodegenConfigurator().setGeneratorName("java")
+ .setLibrary(JavaClientCodegen.RESTTEMPLATE)
+ .setAdditionalProperties(properties)
+ .setInputSpec("src/test/resources/3_0/issue8352.yaml")
+ .setOutputDir(output.getAbsolutePath()
+ .replace("\\", "/"));
+
+ final DefaultGenerator generator = new DefaultGenerator();
+ final List files = generator.opts(configurator.toClientOptInput())
+ .generate();
+ files.forEach(File::deleteOnExit);
+
+ final Path defaultApi = Paths.get(output + "/src/main/java/xyz/abcdef/ApiClient.java");
+ TestUtils.assertFileContains(defaultApi, "value instanceof Map");
+ }
+
+ /**
+ * See https://github.com/OpenAPITools/openapi-generator/issues/8352
+ */
+ @Test
+ public void testWebClientWithFreeFormInQueryParameters() throws IOException {
+ final Map properties = new HashMap<>();
+ properties.put(AbstractJavaCodegen.JAVA8_MODE, true);
+ properties.put(CodegenConstants.API_PACKAGE, "xyz.abcdef.api");
+
+ final File output = Files.createTempDirectory("test")
+ .toFile();
+ output.deleteOnExit();
+
+ final CodegenConfigurator configurator = new CodegenConfigurator().setGeneratorName("java")
+ .setLibrary(JavaClientCodegen.WEBCLIENT)
+ .setAdditionalProperties(properties)
+ .setInputSpec("src/test/resources/3_0/issue8352.yaml")
+ .setOutputDir(output.getAbsolutePath()
+ .replace("\\", "/"));
+
+ final DefaultGenerator generator = new DefaultGenerator();
+ final List files = generator.opts(configurator.toClientOptInput())
+ .generate();
+ files.forEach(File::deleteOnExit);
+
+ final Path defaultApi = Paths.get(output + "/src/main/java/xyz/abcdef/ApiClient.java");
+ TestUtils.assertFileContains(defaultApi, "value instanceof Map");
+ }
}
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java
index 6bdd0cc4836..66817e5dbc7 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java
@@ -653,4 +653,74 @@ public class SpringCodegenTest {
assertFileNotContains(Paths.get(outputPath + "/src/main/java/org/openapitools/api/SomeApi.java"), "Mono");
assertFileNotContains(Paths.get(outputPath + "/src/main/java/org/openapitools/api/SomeApiDelegate.java"), "Mono");
}
+
+ @Test
+ public void doGeneratePathVariableForSimpleParam() throws IOException {
+ File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
+ output.deleteOnExit();
+ String outputPath = output.getAbsolutePath().replace('\\', '/');
+
+ OpenAPI openAPI = new OpenAPIParser()
+ .readLocation("src/test/resources/3_0/issue_6762.yaml", null, new ParseOptions()).getOpenAPI();
+
+ SpringCodegen codegen = new SpringCodegen();
+ codegen.setOutputDir(output.getAbsolutePath());
+ codegen.additionalProperties().put(CXFServerFeatures.LOAD_TEST_DATA_FROM_FILE, "true");
+
+ ClientOptInput input = new ClientOptInput();
+ input.openAPI(openAPI);
+ input.config(codegen);
+
+ DefaultGenerator generator = new DefaultGenerator();
+
+ generator.setGeneratorPropertyDefault(CodegenConstants.MODELS, "false");
+ generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_TESTS, "false");
+ generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_DOCS, "false");
+ generator.setGeneratorPropertyDefault(CodegenConstants.APIS, "true");
+ generator.setGeneratorPropertyDefault(CodegenConstants.SUPPORTING_FILES, "false");
+
+ generator.opts(input).generate();
+
+ assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/api/ZebrasApi.java"), "allowableValues = \"0, 1\"");
+ assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/api/ZebrasApi.java"), "@PathVariable");
+ assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/api/BearsApi.java"), "allowableValues = \"sleeping, awake\"");
+ assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/api/BearsApi.java"), "@PathVariable");
+ assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/api/CamelsApi.java"), "allowableValues = \"sleeping, awake\"");
+ assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/api/CamelsApi.java"), "@PathVariable");
+ assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/api/GirafesApi.java"), "allowableValues = \"0, 1\"");
+ assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/api/GirafesApi.java"), "@PathVariable");
+ }
+
+ @Test
+ public void shouldGenerateDefaultValueForEnumRequestParameter() throws IOException {
+ File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
+ output.deleteOnExit();
+ String outputPath = output.getAbsolutePath().replace('\\', '/');
+
+ final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/spring/issue_10278.yaml");
+ final SpringCodegen codegen = new SpringCodegen();
+ codegen.setOpenAPI(openAPI);
+ codegen.setOutputDir(output.getAbsolutePath());
+
+ codegen.additionalProperties().put(SpringCodegen.DELEGATE_PATTERN, "true");
+ codegen.additionalProperties().put(SpringCodegen.REACTIVE, "true");
+
+ ClientOptInput input = new ClientOptInput();
+ input.openAPI(openAPI);
+ input.config(codegen);
+
+ DefaultGenerator generator = new DefaultGenerator();
+
+ generator.setGeneratorPropertyDefault(CodegenConstants.MODELS, "false");
+ generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_TESTS, "false");
+ generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_DOCS, "false");
+ generator.setGeneratorPropertyDefault(CodegenConstants.APIS, "true");
+ generator.setGeneratorPropertyDefault(CodegenConstants.SUPPORTING_FILES, "false");
+
+ generator.opts(input).generate();
+
+ assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/api/GetApi.java"),
+ "@RequestParam(value = \"testParameter1\", required = false, defaultValue = \"BAR\")",
+ "@RequestParam(value = \"TestParameter2\", required = false, defaultValue = \"BAR\")");
+ }
}
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/Swift5OptionsProvider.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/Swift5OptionsProvider.java
index fa562df6d7f..cf6b8ba3bfa 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/Swift5OptionsProvider.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/Swift5OptionsProvider.java
@@ -45,6 +45,7 @@ public class Swift5OptionsProvider implements OptionsProvider {
public static final String POD_SCREENSHOTS_VALUE = "podScreenshots";
public static final String POD_DOCUMENTATION_URL_VALUE = "podDocumentationURL";
public static final String READONLY_PROPERTIES_VALUE = "false";
+ public static final String REMOVE_MIGRATION_PROJECT_NAME_CLASS_VALUE = "false";
public static final String SWIFT_USE_API_NAMESPACE_VALUE = "swiftUseApiNamespace";
public static final String USE_BACKTICKS_ESCAPES_VALUE = "false";
public static final String GENERATE_MODEL_ADDITIONAL_PROPERTIES_VALUE = "true";
@@ -82,6 +83,7 @@ public class Swift5OptionsProvider implements OptionsProvider {
.put(Swift5ClientCodegen.POD_SCREENSHOTS, POD_SCREENSHOTS_VALUE)
.put(Swift5ClientCodegen.POD_DOCUMENTATION_URL, POD_DOCUMENTATION_URL_VALUE)
.put(Swift5ClientCodegen.READONLY_PROPERTIES, READONLY_PROPERTIES_VALUE)
+ .put(Swift5ClientCodegen.REMOVE_MIGRATION_PROJECT_NAME_CLASS, REMOVE_MIGRATION_PROJECT_NAME_CLASS_VALUE)
.put(Swift5ClientCodegen.SWIFT_USE_API_NAMESPACE, SWIFT_USE_API_NAMESPACE_VALUE)
.put(Swift5ClientCodegen.USE_BACKTICK_ESCAPES, USE_BACKTICKS_ESCAPES_VALUE)
.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, "true")
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/php/AbstractPhpCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/php/AbstractPhpCodegenTest.java
index 667e91df22e..44661e7498c 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/php/AbstractPhpCodegenTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/php/AbstractPhpCodegenTest.java
@@ -32,6 +32,7 @@ import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.util.Arrays;
+import java.util.Collections;
import java.util.HashMap;
public class AbstractPhpCodegenTest {
@@ -146,6 +147,26 @@ public class AbstractPhpCodegenTest {
Assert.assertTrue(cp1.isPrimitiveType);
}
+ @Test(description = "Issue #10244")
+ public void testEnumPropertyWithDefaultValue() {
+ final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/php/issue_10244.yaml");
+ final AbstractPhpCodegen codegen = new P_AbstractPhpCodegen();
+
+ Schema test1 = openAPI.getComponents().getSchemas().get("ModelWithEnumPropertyHavingDefault");
+ CodegenModel cm1 = codegen.fromModel("ModelWithEnumPropertyHavingDefault", test1);
+
+ // Make sure we got the container object.
+ Assert.assertEquals(cm1.getDataType(), "object");
+ Assert.assertEquals(codegen.getTypeDeclaration("MyResponse"), "\\php\\Model\\MyResponse");
+
+ // We need to postProcess the model for enums to be processed
+ codegen.postProcessModels(Collections.singletonMap("models", Collections.singletonList(Collections.singletonMap("model", cm1))));
+
+ // Assert the enum default value is properly generated
+ CodegenProperty cp1 = cm1.vars.get(0);
+ Assert.assertEquals(cp1.getDefaultValue(), "self::PROPERTY_NAME_VALUE");
+ }
+
private static class P_AbstractPhpCodegen extends AbstractPhpCodegen {
@Override
public CodegenType getTag() {
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/scala/AbstractScalaCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/scala/AbstractScalaCodegenTest.java
index 97e9c3102e8..ce62184a0d3 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/scala/AbstractScalaCodegenTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/scala/AbstractScalaCodegenTest.java
@@ -1,5 +1,7 @@
package org.openapitools.codegen.scala;
+import io.swagger.v3.oas.models.media.ObjectSchema;
+import io.swagger.v3.oas.models.media.Schema;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.languages.AbstractScalaCodegen;
import org.testng.Assert;
@@ -95,4 +97,21 @@ public class AbstractScalaCodegenTest {
Assert.assertFalse(fakeScalaCodegen.importMapping().containsKey("BigInt"),
"BigInt is a Scala type and must not be imported");
}
+
+ @Test
+ void checkScalaTypeDeclaration() {
+
+ final AbstractScalaCodegen codegen = new P_AbstractScalaCodegen();
+
+ Schema> byteArraySchema = new ObjectSchema();
+ byteArraySchema.setType("string");
+ byteArraySchema.setFormat("byte");
+ byteArraySchema.setDescription("Schema with byte string");
+
+ Assert.assertEquals(codegen.getTypeDeclaration(byteArraySchema), "Array[Byte]",
+ "OpenApi File type represented as byte string should be represented as Array[Byte] scala type");
+
+ }
+
+
}
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/scala/SttpBooleanPropertyTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/scala/SttpBooleanPropertyTest.java
index c500dda7706..010fd99f564 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/scala/SttpBooleanPropertyTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/scala/SttpBooleanPropertyTest.java
@@ -1,7 +1,7 @@
package org.openapitools.codegen.scala;
-import org.junit.Assert;
-import org.junit.Test;
+import org.testng.Assert;
+import org.testng.annotations.Test;
import org.openapitools.codegen.languages.ScalaSttpClientCodegen;
import java.util.HashMap;
@@ -14,7 +14,7 @@ public class SttpBooleanPropertyTest {
Map additionalProperties = new HashMap<>();
booleanProperty.updateAdditionalProperties(additionalProperties);
- Assert.assertEquals(false, additionalProperties.get("k1"));
+ Assert.assertEquals(additionalProperties.get("k1"), false);
}
@Test
@@ -24,6 +24,6 @@ public class SttpBooleanPropertyTest {
additionalProperties.put("k1", true);
booleanProperty.updateAdditionalProperties(additionalProperties);
- Assert.assertEquals(true, additionalProperties.get("k1"));
+ Assert.assertEquals(additionalProperties.get("k1"), true);
}
}
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/scala/SttpCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/scala/SttpCodegenTest.java
index a48225430f0..653fc342d82 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/scala/SttpCodegenTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/scala/SttpCodegenTest.java
@@ -4,6 +4,8 @@ import org.openapitools.codegen.languages.ScalaSttpClientCodegen;
import org.testng.Assert;
import org.testng.annotations.Test;
+import io.swagger.v3.oas.models.media.Schema;
+
public class SttpCodegenTest {
private final ScalaSttpClientCodegen codegen = new ScalaSttpClientCodegen();
@@ -17,4 +19,14 @@ public class SttpCodegenTest {
Assert.assertEquals(codegen.encodePath("before/{UserName}/after"), "before/${userName}/after");
}
+ @Test
+ public void typeByteArray() {
+ final Schema> schema = new Schema()
+ .description("Schema with byte string");
+ schema.setType("string");
+ schema.setFormat("byte");
+ String type = codegen.getTypeDeclaration(schema);
+ Assert.assertEquals(type, "Array[Byte]");
+ }
+
}
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/scala/SttpJsonLibraryPropertyTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/scala/SttpJsonLibraryPropertyTest.java
index d8473cb8f5d..23ae32e0511 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/scala/SttpJsonLibraryPropertyTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/scala/SttpJsonLibraryPropertyTest.java
@@ -1,7 +1,7 @@
package org.openapitools.codegen.scala;
-import org.junit.Assert;
-import org.junit.Test;
+import org.testng.Assert;
+import org.testng.annotations.Test;
import org.openapitools.codegen.languages.ScalaSttpClientCodegen;
import java.util.HashMap;
@@ -13,8 +13,8 @@ public class SttpJsonLibraryPropertyTest {
ScalaSttpClientCodegen.JsonLibraryProperty property = new ScalaSttpClientCodegen.JsonLibraryProperty();
Map additionalProperties = new HashMap<>();
property.updateAdditionalProperties(additionalProperties);
- Assert.assertEquals(true, additionalProperties.get("json4s"));
- Assert.assertEquals(false, additionalProperties.get("circe"));
+ Assert.assertEquals(additionalProperties.get("json4s"), true);
+ Assert.assertEquals(additionalProperties.get("circe"), false);
}
@Test
@@ -23,8 +23,8 @@ public class SttpJsonLibraryPropertyTest {
Map additionalProperties = new HashMap<>();
additionalProperties.put("jsonLibrary", "json4s");
property.updateAdditionalProperties(additionalProperties);
- Assert.assertEquals(true, additionalProperties.get("json4s"));
- Assert.assertEquals(false, additionalProperties.get("circe"));
+ Assert.assertEquals(additionalProperties.get("json4s"), true);
+ Assert.assertEquals(additionalProperties.get("circe"), false);
}
@Test
@@ -33,7 +33,7 @@ public class SttpJsonLibraryPropertyTest {
Map additionalProperties = new HashMap<>();
additionalProperties.put("jsonLibrary", "circe");
property.updateAdditionalProperties(additionalProperties);
- Assert.assertEquals(false, additionalProperties.get("json4s"));
- Assert.assertEquals(true, additionalProperties.get("circe"));
+ Assert.assertEquals(additionalProperties.get("json4s"), false);
+ Assert.assertEquals(additionalProperties.get("circe"), true);
}
}
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/scala/SttpPackagePropertyTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/scala/SttpPackagePropertyTest.java
index 7aa45197522..8bbdb684f1c 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/scala/SttpPackagePropertyTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/scala/SttpPackagePropertyTest.java
@@ -1,7 +1,7 @@
package org.openapitools.codegen.scala;
-import org.junit.Assert;
-import org.junit.Test;
+import org.testng.Assert;
+import org.testng.annotations.Test;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.languages.ScalaSttpClientCodegen;
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/scala/SttpStringPropertyTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/scala/SttpStringPropertyTest.java
index f0db3bdafd3..22be5feecc8 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/scala/SttpStringPropertyTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/scala/SttpStringPropertyTest.java
@@ -1,7 +1,7 @@
package org.openapitools.codegen.scala;
-import org.junit.Assert;
-import org.junit.Test;
+import org.testng.Assert;
+import org.testng.annotations.Test;
import org.openapitools.codegen.languages.ScalaSttpClientCodegen;
import java.util.HashMap;
@@ -10,21 +10,21 @@ import java.util.Map;
public class SttpStringPropertyTest {
@Test
- public void shouldUseDefaultValueIfAdditionalPropertiesAreEmpty(){
+ public void shouldUseDefaultValueIfAdditionalPropertiesAreEmpty() {
ScalaSttpClientCodegen.StringProperty property = new ScalaSttpClientCodegen.StringProperty("k1", "desc", "default");
Map additionalProperties = new HashMap<>();
property.updateAdditionalProperties(additionalProperties);
- Assert.assertEquals("default", additionalProperties.get("k1"));
+ Assert.assertEquals(additionalProperties.get("k1"), "default");
}
@Test
- public void shouldUseGivenValueIfProvided(){
+ public void shouldUseGivenValueIfProvided() {
ScalaSttpClientCodegen.StringProperty property = new ScalaSttpClientCodegen.StringProperty("k1", "desc", "default");
Map additionalProperties = new HashMap<>();
additionalProperties.put("k1", "custom");
property.updateAdditionalProperties(additionalProperties);
- Assert.assertEquals("custom", additionalProperties.get("k1"));
+ Assert.assertEquals(additionalProperties.get("k1"), "custom");
}
}
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/swift5/Swift5OptionsTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/swift5/Swift5OptionsTest.java
index 268d52bed28..15a06885bc0 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/swift5/Swift5OptionsTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/swift5/Swift5OptionsTest.java
@@ -48,6 +48,7 @@ public class Swift5OptionsTest extends AbstractOptionsTest {
verify(clientCodegen).setLenientTypeCast(Boolean.parseBoolean(Swift5OptionsProvider.LENIENT_TYPE_CAST_VALUE));
verify(clientCodegen).setPrependFormOrBodyParameters(Boolean.valueOf(Swift5OptionsProvider.PREPEND_FORM_OR_BODY_PARAMETERS_VALUE));
verify(clientCodegen).setReadonlyProperties(Boolean.parseBoolean(Swift5OptionsProvider.READONLY_PROPERTIES_VALUE));
+ verify(clientCodegen).setRemoveMigrationProjectNameClass(Boolean.parseBoolean(Swift5OptionsProvider.REMOVE_MIGRATION_PROJECT_NAME_CLASS_VALUE));
verify(clientCodegen).setGenerateModelAdditionalProperties(Boolean.parseBoolean(Swift5OptionsProvider.GENERATE_MODEL_ADDITIONAL_PROPERTIES_VALUE));
verify(clientCodegen).setHashableModels(Boolean.parseBoolean(Swift5OptionsProvider.HASHABLE_MODELS_VALUE));
}
diff --git a/modules/openapi-generator/src/test/resources/2_0/templates/Java/libraries/jersey2/ApiClient.mustache b/modules/openapi-generator/src/test/resources/2_0/templates/Java/libraries/jersey2/ApiClient.mustache
index f8a121d1ade..a1c91c8eadf 100644
--- a/modules/openapi-generator/src/test/resources/2_0/templates/Java/libraries/jersey2/ApiClient.mustache
+++ b/modules/openapi-generator/src/test/resources/2_0/templates/Java/libraries/jersey2/ApiClient.mustache
@@ -526,7 +526,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
* @return API client
*/
public ApiClient setUserAgent(String userAgent) {
- userAgent = userAgent;
+ this.userAgent = userAgent;
addDefaultHeader("User-Agent", userAgent);
return this;
}
diff --git a/modules/openapi-generator/src/test/resources/3_0/issue8352.yaml b/modules/openapi-generator/src/test/resources/3_0/issue8352.yaml
new file mode 100644
index 00000000000..a1298fa8b93
--- /dev/null
+++ b/modules/openapi-generator/src/test/resources/3_0/issue8352.yaml
@@ -0,0 +1,18 @@
+openapi: 3.0.0
+info:
+ title: test handle of free form query parameters
+ version: 0.0.1
+servers:
+ - url: "http://localhost"
+paths:
+ /some/endpoint:
+ get:
+ parameters:
+ - in: "query"
+ name: "free-form"
+ schema:
+ type: "object"
+ style: "form"
+ responses:
+ 200:
+ description: "test"
\ No newline at end of file
diff --git a/modules/openapi-generator/src/test/resources/3_0/issue_6762.yaml b/modules/openapi-generator/src/test/resources/3_0/issue_6762.yaml
new file mode 100644
index 00000000000..9df77efc7f9
--- /dev/null
+++ b/modules/openapi-generator/src/test/resources/3_0/issue_6762.yaml
@@ -0,0 +1,61 @@
+openapi: 3.0.0
+servers:
+ - url: 'localhost:8080'
+info:
+ version: 1.0.0
+ title: OpenAPI Zoo
+ license:
+ name: Apache-2.0
+ url: 'https://www.apache.org/licenses/LICENSE-2.0.html'
+paths:
+ /girafes/{refStatus}:
+ get:
+ operationId: getGirafes
+ parameters:
+ - $ref: '#/components/parameters/refStatus'
+ /zebras/{status}:
+ get:
+ operationId: getZebras
+ parameters:
+ - in: path
+ name: status
+ required: true
+ schema:
+ type: integer
+ enum: [0,1]
+ default: 0
+ /bears/{refCondition}:
+ get:
+ operationId: getBears
+ parameters:
+ - $ref: '#/components/parameters/refCondition'
+ /camels/{condition}:
+ get:
+ operationId: getCamels
+ parameters:
+ - in: path
+ name: condition
+ required: true
+ schema:
+ type: string
+ enum:
+ - sleeping
+ - awake
+components:
+ parameters:
+ refStatus:
+ in: path
+ name: refStatus
+ required: true
+ schema:
+ type: integer
+ enum: [0,1]
+ default: 0
+ refCondition:
+ in: path
+ name: refCondition
+ schema:
+ type: string
+ enum:
+ - sleeping
+ - awake
diff --git a/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml b/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
index 941db12d9ab..80e6ff8e9de 100644
--- a/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
+++ b/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
@@ -1097,6 +1097,12 @@ paths:
additionalProperties:
type: string
format: string
+ - name: allowEmpty
+ in: query
+ required: true
+ allowEmptyValue: true
+ schema:
+ type: string
responses:
"200":
description: Success
diff --git a/modules/openapi-generator/src/test/resources/3_0/php/issue_10244.yaml b/modules/openapi-generator/src/test/resources/3_0/php/issue_10244.yaml
new file mode 100644
index 00000000000..6a2c48310d9
--- /dev/null
+++ b/modules/openapi-generator/src/test/resources/3_0/php/issue_10244.yaml
@@ -0,0 +1,26 @@
+openapi: 3.0.0
+info:
+ title: 'Issue 10224 Enum default value'
+ version: latest
+paths:
+ '/':
+ get:
+ operationId: operation
+ responses:
+ '200':
+ description: Success
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/ModelWithEnumPropertyHavingDefault'
+components:
+ schemas:
+ ModelWithEnumPropertyHavingDefault:
+ required:
+ - propertyName
+ properties:
+ propertyName:
+ type: string
+ default: VALUE
+ enum:
+ - VALUE
diff --git a/modules/openapi-generator/src/test/resources/3_0/spring/issue_10278.yaml b/modules/openapi-generator/src/test/resources/3_0/spring/issue_10278.yaml
new file mode 100644
index 00000000000..aca62e52d12
--- /dev/null
+++ b/modules/openapi-generator/src/test/resources/3_0/spring/issue_10278.yaml
@@ -0,0 +1,112 @@
+openapi: 3.0.1
+info:
+ title: Swagger Petstore
+ description: 'This is a sample server Petstore server. You can find out more about Swagger
+ at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For
+ this sample, you can use the api key `special-key` to test the authorization filters.'
+ termsOfService: http://swagger.io/terms/
+ contact:
+ email: apiteam@swagger.io
+ license:
+ name: Apache 2.0
+ url: http://www.apache.org/licenses/LICENSE-2.0.html
+ version: 1.0.0
+externalDocs:
+ description: Find out more about Swagger
+ url: http://swagger.io
+servers:
+ - url: https://petstore.swagger.io/v2
+ - url: http://petstore.swagger.io/v2
+tags:
+ - name: pet
+ description: Everything about your Pets
+ externalDocs:
+ description: Find out more
+ url: http://swagger.io
+ - name: store
+ description: Access to Petstore orders
+ - name: user
+ description: Operations about user
+ externalDocs:
+ description: Find out more about our store
+ url: http://swagger.io
+paths:
+ /get:
+ put:
+ tags:
+ - pet
+ summary: Update an existing pet
+ operationId: getPet
+ parameters:
+ - $ref: '#/components/parameters/TestParameter1'
+ - in: query
+ name: TestParameter2
+ schema:
+ type: string
+ enum: [ FOO, BAR ]
+ default: BAR
+ responses:
+ 400:
+ description: Invalid ID supplied
+ content: {}
+ 404:
+ description: Pet not found
+ content: {}
+ 405:
+ description: Validation exception
+ content: {}
+ security:
+ - petstore_auth:
+ - write:pets
+ - read:pets
+ x-codegen-request-body-name: body
+
+components:
+ parameters:
+ TestParameter1:
+ name: testParameter1
+ in: query
+ description: |
+ Type of token
+ schema:
+ $ref: '#/components/schemas/TestParameter1'
+ schemas:
+ TestParameter1:
+ type: string
+ enum:
+ - FOO
+ - BAR
+ default: BAR
+ Category:
+ type: object
+ properties:
+ id:
+ type: integer
+ format: int64
+ name:
+ type: string
+ xml:
+ name: Category
+ Tag:
+ type: object
+ properties:
+ id:
+ type: integer
+ format: int64
+ name:
+ type: string
+ xml:
+ name: Tag
+ securitySchemes:
+ petstore_auth:
+ type: oauth2
+ flows:
+ implicit:
+ authorizationUrl: http://petstore.swagger.io/oauth/dialog
+ scopes:
+ write:pets: modify pets in your account
+ read:pets: read your pets
+ api_key:
+ type: apiKey
+ name: api_key
+ in: header
\ No newline at end of file
diff --git a/modules/openapi-generator/src/test/resources/integrationtests/typescript/additional-properties-expected/git_push.sh b/modules/openapi-generator/src/test/resources/integrationtests/typescript/additional-properties-expected/git_push.sh
index da84dcdab3b..484e8cc0033 100644
--- a/modules/openapi-generator/src/test/resources/integrationtests/typescript/additional-properties-expected/git_push.sh
+++ b/modules/openapi-generator/src/test/resources/integrationtests/typescript/additional-properties-expected/git_push.sh
@@ -32,14 +32,14 @@ git add .
git commit -m "$release_note"
# Sets the new remote
-git_remote=`git remote`
+git_remote=$(git remote)
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@github.com/${git_user_id}/${git_repo_id}.git
fi
fi
diff --git a/modules/openapi-generator/src/test/resources/integrationtests/typescript/array-and-object-expected/git_push.sh b/modules/openapi-generator/src/test/resources/integrationtests/typescript/array-and-object-expected/git_push.sh
index da84dcdab3b..484e8cc0033 100644
--- a/modules/openapi-generator/src/test/resources/integrationtests/typescript/array-and-object-expected/git_push.sh
+++ b/modules/openapi-generator/src/test/resources/integrationtests/typescript/array-and-object-expected/git_push.sh
@@ -32,14 +32,14 @@ git add .
git commit -m "$release_note"
# Sets the new remote
-git_remote=`git remote`
+git_remote=$(git remote)
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@github.com/${git_user_id}/${git_repo_id}.git
fi
fi
diff --git a/modules/openapi-generator/src/test/resources/integrationtests/typescript/node-es5-expected/git_push.sh b/modules/openapi-generator/src/test/resources/integrationtests/typescript/node-es5-expected/git_push.sh
index da84dcdab3b..484e8cc0033 100644
--- a/modules/openapi-generator/src/test/resources/integrationtests/typescript/node-es5-expected/git_push.sh
+++ b/modules/openapi-generator/src/test/resources/integrationtests/typescript/node-es5-expected/git_push.sh
@@ -32,14 +32,14 @@ git add .
git commit -m "$release_note"
# Sets the new remote
-git_remote=`git remote`
+git_remote=$(git remote)
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@github.com/${git_user_id}/${git_repo_id}.git
fi
fi
diff --git a/modules/openapi-generator/src/test/resources/integrationtests/typescript/objectsWithEnums-expected/git_push.sh b/modules/openapi-generator/src/test/resources/integrationtests/typescript/objectsWithEnums-expected/git_push.sh
index 8d7f76ddf28..90208376649 100644
--- a/modules/openapi-generator/src/test/resources/integrationtests/typescript/objectsWithEnums-expected/git_push.sh
+++ b/modules/openapi-generator/src/test/resources/integrationtests/typescript/objectsWithEnums-expected/git_push.sh
@@ -32,14 +32,14 @@ git add .
git commit -m "$release_note"
# Sets the new remote
-git_remote=`git remote`
+git_remote=$(git remote)
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@github.com/${git_user_id}/${git_repo_id}.git
fi
fi
diff --git a/modules/openapi-generator/src/test/resources/integrationtests/typescript/petstore-expected/git_push.sh b/modules/openapi-generator/src/test/resources/integrationtests/typescript/petstore-expected/git_push.sh
index da84dcdab3b..484e8cc0033 100644
--- a/modules/openapi-generator/src/test/resources/integrationtests/typescript/petstore-expected/git_push.sh
+++ b/modules/openapi-generator/src/test/resources/integrationtests/typescript/petstore-expected/git_push.sh
@@ -32,14 +32,14 @@ git add .
git commit -m "$release_note"
# Sets the new remote
-git_remote=`git remote`
+git_remote=$(git remote)
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@github.com/${git_user_id}/${git_repo_id}.git
fi
fi
diff --git a/pom.xml b/pom.xml
index 421cd53d52f..79513ed10ca 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1222,12 +1222,9 @@
samples/client/petstore/php/OpenAPIClient-php -->
samples/client/petstore/javascript-flowtyped
- samples/client/petstore/python
- samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent
samples/client/petstore/python-legacy
samples/client/petstore/python-asyncio
samples/client/petstore/python-tornado
- samples/openapi3/client/petstore/python
samples/openapi3/client/petstore/python-legacy
@@ -1287,6 +1284,7 @@
samples/server/petstore/springboot
samples/server/petstore/springboot-beanvalidation
samples/server/petstore/springboot-useoptional
+ samples/server/petstore/springboot-reactive
samples/server/petstore/jaxrs-cxf
samples/server/petstore/jaxrs-cxf-annotated-base-path
samples/server/petstore/jaxrs-cxf-cdi
@@ -1301,6 +1299,22 @@
+
+
+ samples.circleci.node3
+
+
+ env
+ samples.circleci.node3
+
+
+
+
+ samples/client/petstore/python
+ samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent
+ samples/openapi3/client/petstore/python
+
+
samples.circleci.others
diff --git a/samples/client/petstore/R/git_push.sh b/samples/client/petstore/R/git_push.sh
index 18f86b99e82..f53a75d4fab 100644
--- a/samples/client/petstore/R/git_push.sh
+++ b/samples/client/petstore/R/git_push.sh
@@ -38,14 +38,14 @@ git add .
git commit -m "$release_note"
# Sets the new remote
-git_remote=`git remote`
+git_remote=$(git remote)
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
diff --git a/samples/client/petstore/c/src/apiClient.c b/samples/client/petstore/c/src/apiClient.c
index 2ab296b2e63..ce2f522cda2 100644
--- a/samples/client/petstore/c/src/apiClient.c
+++ b/samples/client/petstore/c/src/apiClient.c
@@ -476,7 +476,7 @@ size_t writeDataCallback(void *buffer, size_t size, size_t nmemb, void *userp) {
size_t size_this_time = nmemb * size;
apiClient_t *apiClient = (apiClient_t *)userp;
apiClient->dataReceived = (char *)realloc( apiClient->dataReceived, apiClient->dataReceivedLen + size_this_time + 1);
- memcpy(apiClient->dataReceived + apiClient->dataReceivedLen, buffer, size_this_time);
+ memcpy((char *)apiClient->dataReceived + apiClient->dataReceivedLen, buffer, size_this_time);
apiClient->dataReceivedLen += size_this_time;
((char*)apiClient->dataReceived)[apiClient->dataReceivedLen] = '\0'; // the space size of (apiClient->dataReceived) = dataReceivedLen + 1
if (apiClient->data_callback_func) {
diff --git a/samples/client/petstore/cpp-qt/.gitignore b/samples/client/petstore/cpp-qt/.gitignore
deleted file mode 100644
index 378eac25d31..00000000000
--- a/samples/client/petstore/cpp-qt/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-build
diff --git a/samples/client/petstore/cpp-qt/PetStore/PetStore.pro b/samples/client/petstore/cpp-qt/PetStore/PetStore.pro
index 88d64d63958..961daeeeffc 100644
--- a/samples/client/petstore/cpp-qt/PetStore/PetStore.pro
+++ b/samples/client/petstore/cpp-qt/PetStore/PetStore.pro
@@ -18,6 +18,8 @@ TEMPLATE = app
include(../client/PFXclient.pri)
+INCLUDEPATH += ../client
+
SOURCES += main.cpp \
PetApiTests.cpp \
StoreApiTests.cpp \
diff --git a/samples/client/petstore/cpp-qt/client/PFXPetApi.cpp b/samples/client/petstore/cpp-qt/client/PFXPetApi.cpp
index 136f71708ba..7c999d98687 100644
--- a/samples/client/petstore/cpp-qt/client/PFXPetApi.cpp
+++ b/samples/client/petstore/cpp-qt/client/PFXPetApi.cpp
@@ -19,19 +19,18 @@ namespace test_namespace {
PFXPetApi::PFXPetApi(const int timeOut)
: _timeOut(timeOut),
_manager(nullptr),
- isResponseCompressionEnabled(false),
- isRequestCompressionEnabled(false) {
+ _isResponseCompressionEnabled(false),
+ _isRequestCompressionEnabled(false) {
initializeServerConfigs();
}
PFXPetApi::~PFXPetApi() {
}
-void PFXPetApi::initializeServerConfigs(){
+void PFXPetApi::initializeServerConfigs() {
//Default server
QList defaultConf = QList();
//varying endpoint server
- QList serverConf = QList();
defaultConf.append(PFXServerConfiguration(
QUrl("http://petstore.swagger.io/v2"),
"No description provided",
@@ -58,23 +57,24 @@ void PFXPetApi::initializeServerConfigs(){
* returns 0 on success and -1, -2 or -3 on failure.
* -1 when the variable does not exist and -2 if the value is not defined in the enum and -3 if the operation or server index is not found
*/
-int PFXPetApi::setDefaultServerValue(int serverIndex, const QString &operation, const QString &variable, const QString &value){
+int PFXPetApi::setDefaultServerValue(int serverIndex, const QString &operation, const QString &variable, const QString &value) {
auto it = _serverConfigs.find(operation);
- if(it != _serverConfigs.end() && serverIndex < it.value().size() ){
+ if (it != _serverConfigs.end() && serverIndex < it.value().size()) {
return _serverConfigs[operation][serverIndex].setDefaultValue(variable,value);
}
return -3;
}
-void PFXPetApi::setServerIndex(const QString &operation, int serverIndex){
- if(_serverIndices.contains(operation) && serverIndex < _serverConfigs.find(operation).value().size() )
+void PFXPetApi::setServerIndex(const QString &operation, int serverIndex) {
+ if (_serverIndices.contains(operation) && serverIndex < _serverConfigs.find(operation).value().size()) {
_serverIndices[operation] = serverIndex;
+ }
}
-void PFXPetApi::setApiKey(const QString &apiKeyName, const QString &apiKey){
+void PFXPetApi::setApiKey(const QString &apiKeyName, const QString &apiKey) {
_apiKeys.insert(apiKeyName,apiKey);
}
-void PFXPetApi::setBearerToken(const QString &token){
+void PFXPetApi::setBearerToken(const QString &token) {
_bearerToken = token;
}
@@ -107,14 +107,14 @@ void PFXPetApi::setNetworkAccessManager(QNetworkAccessManager* manager) {
* @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
* returns the index of the new server config on success and -1 if the operation is not found
*/
-int PFXPetApi::addServerConfiguration(const QString &operation, const QUrl &url, const QString &description, const QMap &variables){
- if(_serverConfigs.contains(operation)){
+int PFXPetApi::addServerConfiguration(const QString &operation, const QUrl &url, const QString &description, const QMap &variables) {
+ if (_serverConfigs.contains(operation)) {
_serverConfigs[operation].append(PFXServerConfiguration(
url,
description,
variables));
return _serverConfigs[operation].size()-1;
- }else{
+ } else {
return -1;
}
}
@@ -125,10 +125,16 @@ int PFXPetApi::addServerConfiguration(const QString &operation, const QUrl &url,
* @param description A String that describes the server
* @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
*/
-void PFXPetApi::setNewServerForAllOperations(const QUrl &url, const QString &description, const QMap &variables){
- for(auto e : _serverIndices.keys()){
+void PFXPetApi::setNewServerForAllOperations(const QUrl &url, const QString &description, const QMap &variables) {
+#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
+ for (auto keyIt = _serverIndices.keyBegin(); keyIt != _serverIndices.keyEnd(); keyIt++) {
+ setServerIndex(*keyIt, addServerConfiguration(*keyIt, url, description, variables));
+ }
+#else
+ for (auto &e : _serverIndices.keys()) {
setServerIndex(e, addServerConfiguration(e, url, description, variables));
}
+#endif
}
/**
@@ -137,85 +143,85 @@ void PFXPetApi::setNewServerForAllOperations(const QUrl &url, const QString &des
* @param description A String that describes the server
* @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
*/
-void PFXPetApi::setNewServer(const QString &operation, const QUrl &url, const QString &description, const QMap &variables){
+void PFXPetApi::setNewServer(const QString &operation, const QUrl &url, const QString &description, const QMap &variables) {
setServerIndex(operation, addServerConfiguration(operation, url, description, variables));
}
void PFXPetApi::addHeaders(const QString &key, const QString &value) {
- defaultHeaders.insert(key, value);
+ _defaultHeaders.insert(key, value);
}
void PFXPetApi::enableRequestCompression() {
- isRequestCompressionEnabled = true;
+ _isRequestCompressionEnabled = true;
}
void PFXPetApi::enableResponseCompression() {
- isResponseCompressionEnabled = true;
+ _isResponseCompressionEnabled = true;
}
-void PFXPetApi::abortRequests(){
+void PFXPetApi::abortRequests() {
emit abortRequestsSignal();
}
-QString PFXPetApi::getParamStylePrefix(QString style){
- if(style == "matrix"){
+QString PFXPetApi::getParamStylePrefix(const QString &style) {
+ if (style == "matrix") {
return ";";
- }else if(style == "label"){
+ } else if (style == "label") {
return ".";
- }else if(style == "form"){
+ } else if (style == "form") {
return "&";
- }else if(style == "simple"){
+ } else if (style == "simple") {
return "";
- }else if(style == "spaceDelimited"){
+ } else if (style == "spaceDelimited") {
return "&";
- }else if(style == "pipeDelimited"){
+ } else if (style == "pipeDelimited") {
return "&";
- }else{
+ } else {
return "none";
}
}
-QString PFXPetApi::getParamStyleSuffix(QString style){
- if(style == "matrix"){
+QString PFXPetApi::getParamStyleSuffix(const QString &style) {
+ if (style == "matrix") {
return "=";
- }else if(style == "label"){
+ } else if (style == "label") {
return "";
- }else if(style == "form"){
+ } else if (style == "form") {
return "=";
- }else if(style == "simple"){
+ } else if (style == "simple") {
return "";
- }else if(style == "spaceDelimited"){
+ } else if (style == "spaceDelimited") {
return "=";
- }else if(style == "pipeDelimited"){
+ } else if (style == "pipeDelimited") {
return "=";
- }else{
+ } else {
return "none";
}
}
-QString PFXPetApi::getParamStyleDelimiter(QString style, QString name, bool isExplode){
+QString PFXPetApi::getParamStyleDelimiter(const QString &style, const QString &name, bool isExplode) {
- if(style == "matrix"){
+ if (style == "matrix") {
return (isExplode) ? ";" + name + "=" : ",";
- }else if(style == "label"){
+ } else if (style == "label") {
return (isExplode) ? "." : ",";
- }else if(style == "form"){
+ } else if (style == "form") {
return (isExplode) ? "&" + name + "=" : ",";
- }else if(style == "simple"){
+ } else if (style == "simple") {
return ",";
- }else if(style == "spaceDelimited"){
+ } else if (style == "spaceDelimited") {
return (isExplode) ? "&" + name + "=" : " ";
- }else if(style == "pipeDelimited"){
+ } else if (style == "pipeDelimited") {
return (isExplode) ? "&" + name + "=" : "|";
- }else if(style == "deepObject"){
+ } else if (style == "deepObject") {
return (isExplode) ? "&" : "none";
- }else {
+ } else {
return "none";
}
}
@@ -233,12 +239,20 @@ void PFXPetApi::addPet(const PFXPet &body) {
QByteArray output = body.asJson().toUtf8();
input.request_body.append(output);
}
- foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
+#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
+ for (auto keyValueIt = _defaultHeaders.keyValueBegin(); keyValueIt != _defaultHeaders.keyValueEnd(); keyValueIt++) {
+ input.headers.insert(keyValueIt->first, keyValueIt->second);
+ }
+#else
+ for (auto key : _defaultHeaders.keys()) {
+ input.headers.insert(key, _defaultHeaders[key]);
+ }
+#endif
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::addPetCallback);
connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater);
- connect(worker, &QObject::destroyed, [this](){
- if(findChildren().count() == 0){
+ connect(worker, &QObject::destroyed, this, [this]() {
+ if (findChildren().count() == 0) {
emit allPendingRequestsCompleted();
}
});
@@ -247,15 +261,11 @@ void PFXPetApi::addPet(const PFXPet &body) {
}
void PFXPetApi::addPetCallback(PFXHttpRequestWorker *worker) {
- QString msg;
QString error_str = worker->error_str;
QNetworkReply::NetworkError error_type = worker->error_type;
- if (worker->error_type == QNetworkReply::NoError) {
- msg = QString("Success! %1 bytes").arg(worker->response.length());
- } else {
- msg = "Error: " + worker->error_str;
- error_str = QString("%1, %2").arg(worker->error_str).arg(QString(worker->response));
+ if (worker->error_type != QNetworkReply::NoError) {
+ error_str = QString("%1, %2").arg(worker->error_str, QString(worker->response));
}
worker->deleteLater();
@@ -277,7 +287,7 @@ void PFXPetApi::deletePet(const qint64 &pet_id, const ::test_namespace::Optional
pet_idPathParam.append("petId").append("}");
QString pathPrefix, pathSuffix, pathDelimiter;
QString pathStyle = "";
- if(pathStyle == "")
+ if (pathStyle == "")
pathStyle = "simple";
pathPrefix = getParamStylePrefix(pathStyle);
pathSuffix = getParamStyleSuffix(pathStyle);
@@ -291,18 +301,26 @@ void PFXPetApi::deletePet(const qint64 &pet_id, const ::test_namespace::Optional
PFXHttpRequestInput input(fullPath, "DELETE");
- if(api_key.hasValue())
+ if (api_key.hasValue())
{
if (!::test_namespace::toStringValue(api_key.value()).isEmpty()) {
input.headers.insert("api_key", ::test_namespace::toStringValue(api_key.value()));
}
}
- foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
+#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
+ for (auto keyValueIt = _defaultHeaders.keyValueBegin(); keyValueIt != _defaultHeaders.keyValueEnd(); keyValueIt++) {
+ input.headers.insert(keyValueIt->first, keyValueIt->second);
+ }
+#else
+ for (auto key : _defaultHeaders.keys()) {
+ input.headers.insert(key, _defaultHeaders[key]);
+ }
+#endif
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::deletePetCallback);
connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater);
- connect(worker, &QObject::destroyed, [this](){
- if(findChildren().count() == 0){
+ connect(worker, &QObject::destroyed, this, [this]() {
+ if (findChildren().count() == 0) {
emit allPendingRequestsCompleted();
}
});
@@ -311,15 +329,11 @@ void PFXPetApi::deletePet(const qint64 &pet_id, const ::test_namespace::Optional
}
void PFXPetApi::deletePetCallback(PFXHttpRequestWorker *worker) {
- QString msg;
QString error_str = worker->error_str;
QNetworkReply::NetworkError error_type = worker->error_type;
- if (worker->error_type == QNetworkReply::NoError) {
- msg = QString("Success! %1 bytes").arg(worker->response.length());
- } else {
- msg = "Error: " + worker->error_str;
- error_str = QString("%1, %2").arg(worker->error_str).arg(QString(worker->response));
+ if (worker->error_type != QNetworkReply::NoError) {
+ error_str = QString("%1, %2").arg(worker->error_str, QString(worker->response));
}
worker->deleteLater();
@@ -339,12 +353,12 @@ void PFXPetApi::findPetsByStatus(const QList &status) {
{
queryStyle = "form";
- if(queryStyle == "")
+ if (queryStyle == "")
queryStyle = "form";
queryPrefix = getParamStylePrefix(queryStyle);
querySuffix = getParamStyleSuffix(queryStyle);
queryDelimiter = getParamStyleDelimiter(queryStyle, "status", false);
- if(status.size() > 0) {
+ if (status.size() > 0) {
if (QString("csv").indexOf("multi") == 0) {
foreach (QString t, status) {
if (fullPath.indexOf("?") > 0)
@@ -427,12 +441,20 @@ void PFXPetApi::findPetsByStatus(const QList &status) {
PFXHttpRequestInput input(fullPath, "GET");
- foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
+#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
+ for (auto keyValueIt = _defaultHeaders.keyValueBegin(); keyValueIt != _defaultHeaders.keyValueEnd(); keyValueIt++) {
+ input.headers.insert(keyValueIt->first, keyValueIt->second);
+ }
+#else
+ for (auto key : _defaultHeaders.keys()) {
+ input.headers.insert(key, _defaultHeaders[key]);
+ }
+#endif
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::findPetsByStatusCallback);
connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater);
- connect(worker, &QObject::destroyed, [this](){
- if(findChildren().count() == 0){
+ connect(worker, &QObject::destroyed, this, [this]() {
+ if (findChildren().count() == 0) {
emit allPendingRequestsCompleted();
}
});
@@ -441,15 +463,11 @@ void PFXPetApi::findPetsByStatus(const QList &status) {
}
void PFXPetApi::findPetsByStatusCallback(PFXHttpRequestWorker *worker) {
- QString msg;
QString error_str = worker->error_str;
QNetworkReply::NetworkError error_type = worker->error_type;
- if (worker->error_type == QNetworkReply::NoError) {
- msg = QString("Success! %1 bytes").arg(worker->response.length());
- } else {
- msg = "Error: " + worker->error_str;
- error_str = QString("%1, %2").arg(worker->error_str).arg(QString(worker->response));
+ if (worker->error_type != QNetworkReply::NoError) {
+ error_str = QString("%1, %2").arg(worker->error_str, QString(worker->response));
}
QList output;
QString json(worker->response);
@@ -479,12 +497,12 @@ void PFXPetApi::findPetsByTags(const QList &tags) {
{
queryStyle = "form";
- if(queryStyle == "")
+ if (queryStyle == "")
queryStyle = "form";
queryPrefix = getParamStylePrefix(queryStyle);
querySuffix = getParamStyleSuffix(queryStyle);
queryDelimiter = getParamStyleDelimiter(queryStyle, "tags", false);
- if(tags.size() > 0) {
+ if (tags.size() > 0) {
if (QString("csv").indexOf("multi") == 0) {
foreach (QString t, tags) {
if (fullPath.indexOf("?") > 0)
@@ -567,12 +585,20 @@ void PFXPetApi::findPetsByTags(const QList &tags) {
PFXHttpRequestInput input(fullPath, "GET");
- foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
+#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
+ for (auto keyValueIt = _defaultHeaders.keyValueBegin(); keyValueIt != _defaultHeaders.keyValueEnd(); keyValueIt++) {
+ input.headers.insert(keyValueIt->first, keyValueIt->second);
+ }
+#else
+ for (auto key : _defaultHeaders.keys()) {
+ input.headers.insert(key, _defaultHeaders[key]);
+ }
+#endif
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::findPetsByTagsCallback);
connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater);
- connect(worker, &QObject::destroyed, [this](){
- if(findChildren().count() == 0){
+ connect(worker, &QObject::destroyed, this, [this]() {
+ if (findChildren().count() == 0) {
emit allPendingRequestsCompleted();
}
});
@@ -581,15 +607,11 @@ void PFXPetApi::findPetsByTags(const QList &tags) {
}
void PFXPetApi::findPetsByTagsCallback(PFXHttpRequestWorker *worker) {
- QString msg;
QString error_str = worker->error_str;
QNetworkReply::NetworkError error_type = worker->error_type;
- if (worker->error_type == QNetworkReply::NoError) {
- msg = QString("Success! %1 bytes").arg(worker->response.length());
- } else {
- msg = "Error: " + worker->error_str;
- error_str = QString("%1, %2").arg(worker->error_str).arg(QString(worker->response));
+ if (worker->error_type != QNetworkReply::NoError) {
+ error_str = QString("%1, %2").arg(worker->error_str, QString(worker->response));
}
QList output;
QString json(worker->response);
@@ -615,7 +637,7 @@ void PFXPetApi::findPetsByTagsCallback(PFXHttpRequestWorker *worker) {
void PFXPetApi::getPetById(const qint64 &pet_id) {
QString fullPath = QString(_serverConfigs["getPetById"][_serverIndices.value("getPetById")].URL()+"/pet/{petId}");
- if(_apiKeys.contains("api_key")){
+ if (_apiKeys.contains("api_key")) {
addHeaders("api_key",_apiKeys.find("api_key").value());
}
@@ -625,7 +647,7 @@ void PFXPetApi::getPetById(const qint64 &pet_id) {
pet_idPathParam.append("petId").append("}");
QString pathPrefix, pathSuffix, pathDelimiter;
QString pathStyle = "";
- if(pathStyle == "")
+ if (pathStyle == "")
pathStyle = "simple";
pathPrefix = getParamStylePrefix(pathStyle);
pathSuffix = getParamStyleSuffix(pathStyle);
@@ -639,12 +661,20 @@ void PFXPetApi::getPetById(const qint64 &pet_id) {
PFXHttpRequestInput input(fullPath, "GET");
- foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
+#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
+ for (auto keyValueIt = _defaultHeaders.keyValueBegin(); keyValueIt != _defaultHeaders.keyValueEnd(); keyValueIt++) {
+ input.headers.insert(keyValueIt->first, keyValueIt->second);
+ }
+#else
+ for (auto key : _defaultHeaders.keys()) {
+ input.headers.insert(key, _defaultHeaders[key]);
+ }
+#endif
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::getPetByIdCallback);
connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater);
- connect(worker, &QObject::destroyed, [this](){
- if(findChildren().count() == 0){
+ connect(worker, &QObject::destroyed, this, [this]() {
+ if (findChildren().count() == 0) {
emit allPendingRequestsCompleted();
}
});
@@ -653,15 +683,11 @@ void PFXPetApi::getPetById(const qint64 &pet_id) {
}
void PFXPetApi::getPetByIdCallback(PFXHttpRequestWorker *worker) {
- QString msg;
QString error_str = worker->error_str;
QNetworkReply::NetworkError error_type = worker->error_type;
- if (worker->error_type == QNetworkReply::NoError) {
- msg = QString("Success! %1 bytes").arg(worker->response.length());
- } else {
- msg = "Error: " + worker->error_str;
- error_str = QString("%1, %2").arg(worker->error_str).arg(QString(worker->response));
+ if (worker->error_type != QNetworkReply::NoError) {
+ error_str = QString("%1, %2").arg(worker->error_str, QString(worker->response));
}
PFXPet output(QString(worker->response));
worker->deleteLater();
@@ -688,12 +714,20 @@ void PFXPetApi::updatePet(const PFXPet &body) {
QByteArray output = body.asJson().toUtf8();
input.request_body.append(output);
}
- foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
+#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
+ for (auto keyValueIt = _defaultHeaders.keyValueBegin(); keyValueIt != _defaultHeaders.keyValueEnd(); keyValueIt++) {
+ input.headers.insert(keyValueIt->first, keyValueIt->second);
+ }
+#else
+ for (auto key : _defaultHeaders.keys()) {
+ input.headers.insert(key, _defaultHeaders[key]);
+ }
+#endif
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::updatePetCallback);
connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater);
- connect(worker, &QObject::destroyed, [this](){
- if(findChildren().count() == 0){
+ connect(worker, &QObject::destroyed, this, [this]() {
+ if (findChildren().count() == 0) {
emit allPendingRequestsCompleted();
}
});
@@ -702,15 +736,11 @@ void PFXPetApi::updatePet(const PFXPet &body) {
}
void PFXPetApi::updatePetCallback(PFXHttpRequestWorker *worker) {
- QString msg;
QString error_str = worker->error_str;
QNetworkReply::NetworkError error_type = worker->error_type;
- if (worker->error_type == QNetworkReply::NoError) {
- msg = QString("Success! %1 bytes").arg(worker->response.length());
- } else {
- msg = "Error: " + worker->error_str;
- error_str = QString("%1, %2").arg(worker->error_str).arg(QString(worker->response));
+ if (worker->error_type != QNetworkReply::NoError) {
+ error_str = QString("%1, %2").arg(worker->error_str, QString(worker->response));
}
worker->deleteLater();
@@ -732,7 +762,7 @@ void PFXPetApi::updatePetWithForm(const qint64 &pet_id, const ::test_namespace::
pet_idPathParam.append("petId").append("}");
QString pathPrefix, pathSuffix, pathDelimiter;
QString pathStyle = "";
- if(pathStyle == "")
+ if (pathStyle == "")
pathStyle = "simple";
pathPrefix = getParamStylePrefix(pathStyle);
pathSuffix = getParamStyleSuffix(pathStyle);
@@ -745,21 +775,29 @@ void PFXPetApi::updatePetWithForm(const qint64 &pet_id, const ::test_namespace::
worker->setWorkingDirectory(_workingDirectory);
PFXHttpRequestInput input(fullPath, "POST");
- if(name.hasValue())
+ if (name.hasValue())
{
input.add_var("name", ::test_namespace::toStringValue(name.value()));
}
- if(status.hasValue())
+ if (status.hasValue())
{
input.add_var("status", ::test_namespace::toStringValue(status.value()));
}
- foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
+#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
+ for (auto keyValueIt = _defaultHeaders.keyValueBegin(); keyValueIt != _defaultHeaders.keyValueEnd(); keyValueIt++) {
+ input.headers.insert(keyValueIt->first, keyValueIt->second);
+ }
+#else
+ for (auto key : _defaultHeaders.keys()) {
+ input.headers.insert(key, _defaultHeaders[key]);
+ }
+#endif
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::updatePetWithFormCallback);
connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater);
- connect(worker, &QObject::destroyed, [this](){
- if(findChildren().count() == 0){
+ connect(worker, &QObject::destroyed, this, [this]() {
+ if (findChildren().count() == 0) {
emit allPendingRequestsCompleted();
}
});
@@ -768,15 +806,11 @@ void PFXPetApi::updatePetWithForm(const qint64 &pet_id, const ::test_namespace::
}
void PFXPetApi::updatePetWithFormCallback(PFXHttpRequestWorker *worker) {
- QString msg;
QString error_str = worker->error_str;
QNetworkReply::NetworkError error_type = worker->error_type;
- if (worker->error_type == QNetworkReply::NoError) {
- msg = QString("Success! %1 bytes").arg(worker->response.length());
- } else {
- msg = "Error: " + worker->error_str;
- error_str = QString("%1, %2").arg(worker->error_str).arg(QString(worker->response));
+ if (worker->error_type != QNetworkReply::NoError) {
+ error_str = QString("%1, %2").arg(worker->error_str, QString(worker->response));
}
worker->deleteLater();
@@ -798,7 +832,7 @@ void PFXPetApi::uploadFile(const qint64 &pet_id, const ::test_namespace::Optiona
pet_idPathParam.append("petId").append("}");
QString pathPrefix, pathSuffix, pathDelimiter;
QString pathStyle = "";
- if(pathStyle == "")
+ if (pathStyle == "")
pathStyle = "simple";
pathPrefix = getParamStylePrefix(pathStyle);
pathSuffix = getParamStyleSuffix(pathStyle);
@@ -811,21 +845,29 @@ void PFXPetApi::uploadFile(const qint64 &pet_id, const ::test_namespace::Optiona
worker->setWorkingDirectory(_workingDirectory);
PFXHttpRequestInput input(fullPath, "POST");
- if(additional_metadata.hasValue())
+ if (additional_metadata.hasValue())
{
input.add_var("additionalMetadata", ::test_namespace::toStringValue(additional_metadata.value()));
}
- if(file.hasValue())
+ if (file.hasValue())
{
input.add_file("file", file.value().local_filename, file.value().request_filename, file.value().mime_type);
}
- foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
+#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
+ for (auto keyValueIt = _defaultHeaders.keyValueBegin(); keyValueIt != _defaultHeaders.keyValueEnd(); keyValueIt++) {
+ input.headers.insert(keyValueIt->first, keyValueIt->second);
+ }
+#else
+ for (auto key : _defaultHeaders.keys()) {
+ input.headers.insert(key, _defaultHeaders[key]);
+ }
+#endif
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::uploadFileCallback);
connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater);
- connect(worker, &QObject::destroyed, [this](){
- if(findChildren().count() == 0){
+ connect(worker, &QObject::destroyed, this, [this]() {
+ if (findChildren().count() == 0) {
emit allPendingRequestsCompleted();
}
});
@@ -834,15 +876,11 @@ void PFXPetApi::uploadFile(const qint64 &pet_id, const ::test_namespace::Optiona
}
void PFXPetApi::uploadFileCallback(PFXHttpRequestWorker *worker) {
- QString msg;
QString error_str = worker->error_str;
QNetworkReply::NetworkError error_type = worker->error_type;
- if (worker->error_type == QNetworkReply::NoError) {
- msg = QString("Success! %1 bytes").arg(worker->response.length());
- } else {
- msg = "Error: " + worker->error_str;
- error_str = QString("%1, %2").arg(worker->error_str).arg(QString(worker->response));
+ if (worker->error_type != QNetworkReply::NoError) {
+ error_str = QString("%1, %2").arg(worker->error_str, QString(worker->response));
}
PFXApiResponse output(QString(worker->response));
worker->deleteLater();
diff --git a/samples/client/petstore/cpp-qt/client/PFXPetApi.h b/samples/client/petstore/cpp-qt/client/PFXPetApi.h
index 2c4d472306b..4007bd2e942 100644
--- a/samples/client/petstore/cpp-qt/client/PFXPetApi.h
+++ b/samples/client/petstore/cpp-qt/client/PFXPetApi.h
@@ -53,9 +53,9 @@ public:
void enableRequestCompression();
void enableResponseCompression();
void abortRequests();
- QString getParamStylePrefix(QString style);
- QString getParamStyleSuffix(QString style);
- QString getParamStyleDelimiter(QString style, QString name, bool isExplode);
+ QString getParamStylePrefix(const QString &style);
+ QString getParamStyleSuffix(const QString &style);
+ QString getParamStyleDelimiter(const QString &style, const QString &name, bool isExplode);
/**
* @param[in] body PFXPet [required]
@@ -113,9 +113,9 @@ private:
int _timeOut;
QString _workingDirectory;
QNetworkAccessManager* _manager;
- QMap defaultHeaders;
- bool isResponseCompressionEnabled;
- bool isRequestCompressionEnabled;
+ QMap _defaultHeaders;
+ bool _isResponseCompressionEnabled;
+ bool _isRequestCompressionEnabled;
void addPetCallback(PFXHttpRequestWorker *worker);
void deletePetCallback(PFXHttpRequestWorker *worker);
diff --git a/samples/client/petstore/cpp-qt/client/PFXServerConfiguration.h b/samples/client/petstore/cpp-qt/client/PFXServerConfiguration.h
index 72bd32a4f6e..42e7504dcaa 100644
--- a/samples/client/petstore/cpp-qt/client/PFXServerConfiguration.h
+++ b/samples/client/petstore/cpp-qt/client/PFXServerConfiguration.h
@@ -14,9 +14,11 @@
*/
#ifndef PFX_SERVERVCONFIGURATION_H
#define PFX_SERVERVCONFIGURATION_H
+
#include
#include
#include
+#include
#include
#include "PFXServerVariable.h"
diff --git a/samples/client/petstore/cpp-qt/client/PFXStoreApi.cpp b/samples/client/petstore/cpp-qt/client/PFXStoreApi.cpp
index 723af6e80c2..9ff025b0ad1 100644
--- a/samples/client/petstore/cpp-qt/client/PFXStoreApi.cpp
+++ b/samples/client/petstore/cpp-qt/client/PFXStoreApi.cpp
@@ -19,19 +19,18 @@ namespace test_namespace {
PFXStoreApi::PFXStoreApi(const int timeOut)
: _timeOut(timeOut),
_manager(nullptr),
- isResponseCompressionEnabled(false),
- isRequestCompressionEnabled(false) {
+ _isResponseCompressionEnabled(false),
+ _isRequestCompressionEnabled(false) {
initializeServerConfigs();
}
PFXStoreApi::~PFXStoreApi() {
}
-void PFXStoreApi::initializeServerConfigs(){
+void PFXStoreApi::initializeServerConfigs() {
//Default server
QList defaultConf = QList();
//varying endpoint server
- QList serverConf = QList();
defaultConf.append(PFXServerConfiguration(
QUrl("http://petstore.swagger.io/v2"),
"No description provided",
@@ -50,23 +49,24 @@ void PFXStoreApi::initializeServerConfigs(){
* returns 0 on success and -1, -2 or -3 on failure.
* -1 when the variable does not exist and -2 if the value is not defined in the enum and -3 if the operation or server index is not found
*/
-int PFXStoreApi::setDefaultServerValue(int serverIndex, const QString &operation, const QString &variable, const QString &value){
+int PFXStoreApi::setDefaultServerValue(int serverIndex, const QString &operation, const QString &variable, const QString &value) {
auto it = _serverConfigs.find(operation);
- if(it != _serverConfigs.end() && serverIndex < it.value().size() ){
+ if (it != _serverConfigs.end() && serverIndex < it.value().size()) {
return _serverConfigs[operation][serverIndex].setDefaultValue(variable,value);
}
return -3;
}
-void PFXStoreApi::setServerIndex(const QString &operation, int serverIndex){
- if(_serverIndices.contains(operation) && serverIndex < _serverConfigs.find(operation).value().size() )
+void PFXStoreApi::setServerIndex(const QString &operation, int serverIndex) {
+ if (_serverIndices.contains(operation) && serverIndex < _serverConfigs.find(operation).value().size()) {
_serverIndices[operation] = serverIndex;
+ }
}
-void PFXStoreApi::setApiKey(const QString &apiKeyName, const QString &apiKey){
+void PFXStoreApi::setApiKey(const QString &apiKeyName, const QString &apiKey) {
_apiKeys.insert(apiKeyName,apiKey);
}
-void PFXStoreApi::setBearerToken(const QString &token){
+void PFXStoreApi::setBearerToken(const QString &token) {
_bearerToken = token;
}
@@ -99,14 +99,14 @@ void PFXStoreApi::setNetworkAccessManager(QNetworkAccessManager* manager) {
* @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
* returns the index of the new server config on success and -1 if the operation is not found
*/
-int PFXStoreApi::addServerConfiguration(const QString &operation, const QUrl &url, const QString &description, const QMap &variables){
- if(_serverConfigs.contains(operation)){
+int PFXStoreApi::addServerConfiguration(const QString &operation, const QUrl &url, const QString &description, const QMap &variables) {
+ if (_serverConfigs.contains(operation)) {
_serverConfigs[operation].append(PFXServerConfiguration(
url,
description,
variables));
return _serverConfigs[operation].size()-1;
- }else{
+ } else {
return -1;
}
}
@@ -117,10 +117,16 @@ int PFXStoreApi::addServerConfiguration(const QString &operation, const QUrl &ur
* @param description A String that describes the server
* @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
*/
-void PFXStoreApi::setNewServerForAllOperations(const QUrl &url, const QString &description, const QMap &variables){
- for(auto e : _serverIndices.keys()){
+void PFXStoreApi::setNewServerForAllOperations(const QUrl &url, const QString &description, const QMap &variables) {
+#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
+ for (auto keyIt = _serverIndices.keyBegin(); keyIt != _serverIndices.keyEnd(); keyIt++) {
+ setServerIndex(*keyIt, addServerConfiguration(*keyIt, url, description, variables));
+ }
+#else
+ for (auto &e : _serverIndices.keys()) {
setServerIndex(e, addServerConfiguration(e, url, description, variables));
}
+#endif
}
/**
@@ -129,85 +135,85 @@ void PFXStoreApi::setNewServerForAllOperations(const QUrl &url, const QString &d
* @param description A String that describes the server
* @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
*/
-void PFXStoreApi::setNewServer(const QString &operation, const QUrl &url, const QString &description, const QMap &variables){
+void PFXStoreApi::setNewServer(const QString &operation, const QUrl &url, const QString &description, const QMap &variables) {
setServerIndex(operation, addServerConfiguration(operation, url, description, variables));
}
void PFXStoreApi::addHeaders(const QString &key, const QString &value) {
- defaultHeaders.insert(key, value);
+ _defaultHeaders.insert(key, value);
}
void PFXStoreApi::enableRequestCompression() {
- isRequestCompressionEnabled = true;
+ _isRequestCompressionEnabled = true;
}
void PFXStoreApi::enableResponseCompression() {
- isResponseCompressionEnabled = true;
+ _isResponseCompressionEnabled = true;
}
-void PFXStoreApi::abortRequests(){
+void PFXStoreApi::abortRequests() {
emit abortRequestsSignal();
}
-QString PFXStoreApi::getParamStylePrefix(QString style){
- if(style == "matrix"){
+QString PFXStoreApi::getParamStylePrefix(const QString &style) {
+ if (style == "matrix") {
return ";";
- }else if(style == "label"){
+ } else if (style == "label") {
return ".";
- }else if(style == "form"){
+ } else if (style == "form") {
return "&";
- }else if(style == "simple"){
+ } else if (style == "simple") {
return "";
- }else if(style == "spaceDelimited"){
+ } else if (style == "spaceDelimited") {
return "&";
- }else if(style == "pipeDelimited"){
+ } else if (style == "pipeDelimited") {
return "&";
- }else{
+ } else {
return "none";
}
}
-QString PFXStoreApi::getParamStyleSuffix(QString style){
- if(style == "matrix"){
+QString PFXStoreApi::getParamStyleSuffix(const QString &style) {
+ if (style == "matrix") {
return "=";
- }else if(style == "label"){
+ } else if (style == "label") {
return "";
- }else if(style == "form"){
+ } else if (style == "form") {
return "=";
- }else if(style == "simple"){
+ } else if (style == "simple") {
return "";
- }else if(style == "spaceDelimited"){
+ } else if (style == "spaceDelimited") {
return "=";
- }else if(style == "pipeDelimited"){
+ } else if (style == "pipeDelimited") {
return "=";
- }else{
+ } else {
return "none";
}
}
-QString PFXStoreApi::getParamStyleDelimiter(QString style, QString name, bool isExplode){
+QString PFXStoreApi::getParamStyleDelimiter(const QString &style, const QString &name, bool isExplode) {
- if(style == "matrix"){
+ if (style == "matrix") {
return (isExplode) ? ";" + name + "=" : ",";
- }else if(style == "label"){
+ } else if (style == "label") {
return (isExplode) ? "." : ",";
- }else if(style == "form"){
+ } else if (style == "form") {
return (isExplode) ? "&" + name + "=" : ",";
- }else if(style == "simple"){
+ } else if (style == "simple") {
return ",";
- }else if(style == "spaceDelimited"){
+ } else if (style == "spaceDelimited") {
return (isExplode) ? "&" + name + "=" : " ";
- }else if(style == "pipeDelimited"){
+ } else if (style == "pipeDelimited") {
return (isExplode) ? "&" + name + "=" : "|";
- }else if(style == "deepObject"){
+ } else if (style == "deepObject") {
return (isExplode) ? "&" : "none";
- }else {
+ } else {
return "none";
}
}
@@ -221,7 +227,7 @@ void PFXStoreApi::deleteOrder(const QString &order_id) {
order_idPathParam.append("orderId").append("}");
QString pathPrefix, pathSuffix, pathDelimiter;
QString pathStyle = "";
- if(pathStyle == "")
+ if (pathStyle == "")
pathStyle = "simple";
pathPrefix = getParamStylePrefix(pathStyle);
pathSuffix = getParamStyleSuffix(pathStyle);
@@ -235,12 +241,20 @@ void PFXStoreApi::deleteOrder(const QString &order_id) {
PFXHttpRequestInput input(fullPath, "DELETE");
- foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
+#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
+ for (auto keyValueIt = _defaultHeaders.keyValueBegin(); keyValueIt != _defaultHeaders.keyValueEnd(); keyValueIt++) {
+ input.headers.insert(keyValueIt->first, keyValueIt->second);
+ }
+#else
+ for (auto key : _defaultHeaders.keys()) {
+ input.headers.insert(key, _defaultHeaders[key]);
+ }
+#endif
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXStoreApi::deleteOrderCallback);
connect(this, &PFXStoreApi::abortRequestsSignal, worker, &QObject::deleteLater);
- connect(worker, &QObject::destroyed, [this](){
- if(findChildren().count() == 0){
+ connect(worker, &QObject::destroyed, this, [this]() {
+ if (findChildren().count() == 0) {
emit allPendingRequestsCompleted();
}
});
@@ -249,15 +263,11 @@ void PFXStoreApi::deleteOrder(const QString &order_id) {
}
void PFXStoreApi::deleteOrderCallback(PFXHttpRequestWorker *worker) {
- QString msg;
QString error_str = worker->error_str;
QNetworkReply::NetworkError error_type = worker->error_type;
- if (worker->error_type == QNetworkReply::NoError) {
- msg = QString("Success! %1 bytes").arg(worker->response.length());
- } else {
- msg = "Error: " + worker->error_str;
- error_str = QString("%1, %2").arg(worker->error_str).arg(QString(worker->response));
+ if (worker->error_type != QNetworkReply::NoError) {
+ error_str = QString("%1, %2").arg(worker->error_str, QString(worker->response));
}
worker->deleteLater();
@@ -273,7 +283,7 @@ void PFXStoreApi::deleteOrderCallback(PFXHttpRequestWorker *worker) {
void PFXStoreApi::getInventory() {
QString fullPath = QString(_serverConfigs["getInventory"][_serverIndices.value("getInventory")].URL()+"/store/inventory");
- if(_apiKeys.contains("api_key")){
+ if (_apiKeys.contains("api_key")) {
addHeaders("api_key",_apiKeys.find("api_key").value());
}
@@ -283,12 +293,20 @@ void PFXStoreApi::getInventory() {
PFXHttpRequestInput input(fullPath, "GET");
- foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
+#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
+ for (auto keyValueIt = _defaultHeaders.keyValueBegin(); keyValueIt != _defaultHeaders.keyValueEnd(); keyValueIt++) {
+ input.headers.insert(keyValueIt->first, keyValueIt->second);
+ }
+#else
+ for (auto key : _defaultHeaders.keys()) {
+ input.headers.insert(key, _defaultHeaders[key]);
+ }
+#endif
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXStoreApi::getInventoryCallback);
connect(this, &PFXStoreApi::abortRequestsSignal, worker, &QObject::deleteLater);
- connect(worker, &QObject::destroyed, [this](){
- if(findChildren().count() == 0){
+ connect(worker, &QObject::destroyed, this, [this]() {
+ if (findChildren().count() == 0) {
emit allPendingRequestsCompleted();
}
});
@@ -297,15 +315,11 @@ void PFXStoreApi::getInventory() {
}
void PFXStoreApi::getInventoryCallback(PFXHttpRequestWorker *worker) {
- QString msg;
QString error_str = worker->error_str;
QNetworkReply::NetworkError error_type = worker->error_type;
- if (worker->error_type == QNetworkReply::NoError) {
- msg = QString("Success! %1 bytes").arg(worker->response.length());
- } else {
- msg = "Error: " + worker->error_str;
- error_str = QString("%1, %2").arg(worker->error_str).arg(QString(worker->response));
+ if (worker->error_type != QNetworkReply::NoError) {
+ error_str = QString("%1, %2").arg(worker->error_str, QString(worker->response));
}
QMap output;
QString json(worker->response);
@@ -337,7 +351,7 @@ void PFXStoreApi::getOrderById(const qint64 &order_id) {
order_idPathParam.append("orderId").append("}");
QString pathPrefix, pathSuffix, pathDelimiter;
QString pathStyle = "";
- if(pathStyle == "")
+ if (pathStyle == "")
pathStyle = "simple";
pathPrefix = getParamStylePrefix(pathStyle);
pathSuffix = getParamStyleSuffix(pathStyle);
@@ -351,12 +365,20 @@ void PFXStoreApi::getOrderById(const qint64 &order_id) {
PFXHttpRequestInput input(fullPath, "GET");
- foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
+#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
+ for (auto keyValueIt = _defaultHeaders.keyValueBegin(); keyValueIt != _defaultHeaders.keyValueEnd(); keyValueIt++) {
+ input.headers.insert(keyValueIt->first, keyValueIt->second);
+ }
+#else
+ for (auto key : _defaultHeaders.keys()) {
+ input.headers.insert(key, _defaultHeaders[key]);
+ }
+#endif
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXStoreApi::getOrderByIdCallback);
connect(this, &PFXStoreApi::abortRequestsSignal, worker, &QObject::deleteLater);
- connect(worker, &QObject::destroyed, [this](){
- if(findChildren().count() == 0){
+ connect(worker, &QObject::destroyed, this, [this]() {
+ if (findChildren