From 5d946289efe1cd69fc680ab5efc16ac37a02a7db Mon Sep 17 00:00:00 2001 From: William Cheng Date: Wed, 28 Apr 2021 22:36:29 +0800 Subject: [PATCH 01/18] Bump OkHTTP dependency to latest in build.sbt (#9361) --- .../resources/Java/libraries/okhttp-gson/build.sbt.mustache | 4 ++-- .../petstore/java/okhttp-gson-dynamicOperations/build.sbt | 4 ++-- .../petstore/java/okhttp-gson-parcelableModel/build.sbt | 4 ++-- samples/client/petstore/java/okhttp-gson/build.sbt | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/build.sbt.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/build.sbt.mustache index a14047e79984..8979b10a7f8c 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/build.sbt.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/build.sbt.mustache @@ -10,8 +10,8 @@ lazy val root = (project in file(".")). resolvers += Resolver.mavenLocal, libraryDependencies ++= Seq( "io.swagger" % "swagger-annotations" % "1.5.24", - "com.squareup.okhttp3" % "okhttp" % "3.14.7", - "com.squareup.okhttp3" % "logging-interceptor" % "3.14.7", + "com.squareup.okhttp3" % "okhttp" % "4.9.1", + "com.squareup.okhttp3" % "logging-interceptor" % "4.9.1", "com.google.code.gson" % "gson" % "2.8.6", "org.apache.commons" % "commons-lang3" % "3.10", {{#hasOAuthMethods}} diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/build.sbt b/samples/client/petstore/java/okhttp-gson-dynamicOperations/build.sbt index 289532fdd680..020460f4527d 100644 --- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/build.sbt +++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/build.sbt @@ -10,8 +10,8 @@ lazy val root = (project in file(".")). resolvers += Resolver.mavenLocal, libraryDependencies ++= Seq( "io.swagger" % "swagger-annotations" % "1.5.24", - "com.squareup.okhttp3" % "okhttp" % "3.14.7", - "com.squareup.okhttp3" % "logging-interceptor" % "3.14.7", + "com.squareup.okhttp3" % "okhttp" % "4.9.1", + "com.squareup.okhttp3" % "logging-interceptor" % "4.9.1", "com.google.code.gson" % "gson" % "2.8.6", "org.apache.commons" % "commons-lang3" % "3.10", "org.apache.oltu.oauth2" % "org.apache.oltu.oauth2.client" % "1.0.1", diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/build.sbt b/samples/client/petstore/java/okhttp-gson-parcelableModel/build.sbt index d3bf50f4d7f6..c36bbc5ca081 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/build.sbt +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/build.sbt @@ -10,8 +10,8 @@ lazy val root = (project in file(".")). resolvers += Resolver.mavenLocal, libraryDependencies ++= Seq( "io.swagger" % "swagger-annotations" % "1.5.24", - "com.squareup.okhttp3" % "okhttp" % "3.14.7", - "com.squareup.okhttp3" % "logging-interceptor" % "3.14.7", + "com.squareup.okhttp3" % "okhttp" % "4.9.1", + "com.squareup.okhttp3" % "logging-interceptor" % "4.9.1", "com.google.code.gson" % "gson" % "2.8.6", "org.apache.commons" % "commons-lang3" % "3.10", "org.apache.oltu.oauth2" % "org.apache.oltu.oauth2.client" % "1.0.1", diff --git a/samples/client/petstore/java/okhttp-gson/build.sbt b/samples/client/petstore/java/okhttp-gson/build.sbt index ae1791028e0f..6dfd0d7f733b 100644 --- a/samples/client/petstore/java/okhttp-gson/build.sbt +++ b/samples/client/petstore/java/okhttp-gson/build.sbt @@ -10,8 +10,8 @@ lazy val root = (project in file(".")). resolvers += Resolver.mavenLocal, libraryDependencies ++= Seq( "io.swagger" % "swagger-annotations" % "1.5.24", - "com.squareup.okhttp3" % "okhttp" % "3.14.7", - "com.squareup.okhttp3" % "logging-interceptor" % "3.14.7", + "com.squareup.okhttp3" % "okhttp" % "4.9.1", + "com.squareup.okhttp3" % "logging-interceptor" % "4.9.1", "com.google.code.gson" % "gson" % "2.8.6", "org.apache.commons" % "commons-lang3" % "3.10", "org.apache.oltu.oauth2" % "org.apache.oltu.oauth2.client" % "1.0.1", From 18cdb36d3e4999198544ae64729f20613a228098 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Thu, 29 Apr 2021 10:23:55 +0800 Subject: [PATCH 02/18] [Test] Migrate samples from 2.0 Spec to 3.0 spec (#9347) * nim petstore to use 3.0 spec * ktorm to use 3.0 spec * update c petstore to use 3.0 spec * Revert "update c petstore to use 3.0 spec" This reverts commit a8ff0517bacc52fd9ac945f5812a8c12294fc410. --- bin/configs/ktorm-schema.yaml | 4 ++-- bin/configs/nim.yaml | 2 +- .../petstore/nim/petstore/apis/api_pet.nim | 12 ++++++++---- .../petstore/nim/petstore/apis/api_store.nim | 4 ++-- .../petstore/nim/petstore/apis/api_user.nim | 16 ++++++++-------- 5 files changed, 21 insertions(+), 17 deletions(-) diff --git a/bin/configs/ktorm-schema.yaml b/bin/configs/ktorm-schema.yaml index aff895cb279b..d3c5beb9a33b 100644 --- a/bin/configs/ktorm-schema.yaml +++ b/bin/configs/ktorm-schema.yaml @@ -1,7 +1,7 @@ generatorName: ktorm-schema outputDir: samples/schema/petstore/ktorm -inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml +inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml templateDir: modules/openapi-generator/src/main/resources/ktorm-schema additionalProperties: hideGenerationTimestamp: true - importModelPackageName: org.openapitools.client.models \ No newline at end of file + importModelPackageName: org.openapitools.client.models diff --git a/bin/configs/nim.yaml b/bin/configs/nim.yaml index 136a92764c3c..13a27a6b764c 100644 --- a/bin/configs/nim.yaml +++ b/bin/configs/nim.yaml @@ -1,6 +1,6 @@ generatorName: nim outputDir: samples/client/petstore/nim -inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml +inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml templateDir: modules/openapi-generator/src/main/resources/nim-client additionalProperties: packageName: petstore diff --git a/samples/client/petstore/nim/petstore/apis/api_pet.nim b/samples/client/petstore/nim/petstore/apis/api_pet.nim index 3644e392340a..b2f77c2bdbb8 100644 --- a/samples/client/petstore/nim/petstore/apis/api_pet.nim +++ b/samples/client/petstore/nim/petstore/apis/api_pet.nim @@ -39,10 +39,12 @@ template constructResult[T](response: Response): untyped = (none(T.typedesc), response) -proc addPet*(httpClient: HttpClient, body: Pet): Response = +proc addPet*(httpClient: HttpClient, pet: Pet): (Option[Pet], Response) = ## Add a new pet to the store httpClient.headers["Content-Type"] = "application/json" - httpClient.post(basepath & "/pet", $(%body)) + + let response = httpClient.post(basepath & "/pet", $(%pet)) + constructResult[Pet](response) proc deletePet*(httpClient: HttpClient, petId: int64, apiKey: string): Response = @@ -78,10 +80,12 @@ proc getPetById*(httpClient: HttpClient, petId: int64): (Option[Pet], Response) constructResult[Pet](response) -proc updatePet*(httpClient: HttpClient, body: Pet): Response = +proc updatePet*(httpClient: HttpClient, pet: Pet): (Option[Pet], Response) = ## Update an existing pet httpClient.headers["Content-Type"] = "application/json" - httpClient.put(basepath & "/pet", $(%body)) + + let response = httpClient.put(basepath & "/pet", $(%pet)) + constructResult[Pet](response) proc updatePetWithForm*(httpClient: HttpClient, petId: int64, name: string, status: string): Response = diff --git a/samples/client/petstore/nim/petstore/apis/api_store.nim b/samples/client/petstore/nim/petstore/apis/api_store.nim index 3c518e8dd31a..a2f018b7cf3d 100644 --- a/samples/client/petstore/nim/petstore/apis/api_store.nim +++ b/samples/client/petstore/nim/petstore/apis/api_store.nim @@ -57,10 +57,10 @@ proc getOrderById*(httpClient: HttpClient, orderId: int64): (Option[Order], Resp constructResult[Order](response) -proc placeOrder*(httpClient: HttpClient, body: Order): (Option[Order], Response) = +proc placeOrder*(httpClient: HttpClient, order: Order): (Option[Order], Response) = ## Place an order for a pet httpClient.headers["Content-Type"] = "application/json" - let response = httpClient.post(basepath & "/store/order", $(%body)) + let response = httpClient.post(basepath & "/store/order", $(%order)) constructResult[Order](response) diff --git a/samples/client/petstore/nim/petstore/apis/api_user.nim b/samples/client/petstore/nim/petstore/apis/api_user.nim index 87bef06818e4..618477db5954 100644 --- a/samples/client/petstore/nim/petstore/apis/api_user.nim +++ b/samples/client/petstore/nim/petstore/apis/api_user.nim @@ -38,22 +38,22 @@ template constructResult[T](response: Response): untyped = (none(T.typedesc), response) -proc createUser*(httpClient: HttpClient, body: User): Response = +proc createUser*(httpClient: HttpClient, user: User): Response = ## Create user httpClient.headers["Content-Type"] = "application/json" - httpClient.post(basepath & "/user", $(%body)) + httpClient.post(basepath & "/user", $(%user)) -proc createUsersWithArrayInput*(httpClient: HttpClient, body: seq[User]): Response = +proc createUsersWithArrayInput*(httpClient: HttpClient, user: seq[User]): Response = ## Creates list of users with given input array httpClient.headers["Content-Type"] = "application/json" - httpClient.post(basepath & "/user/createWithArray", $(%body)) + httpClient.post(basepath & "/user/createWithArray", $(%user)) -proc createUsersWithListInput*(httpClient: HttpClient, body: seq[User]): Response = +proc createUsersWithListInput*(httpClient: HttpClient, user: seq[User]): Response = ## Creates list of users with given input array httpClient.headers["Content-Type"] = "application/json" - httpClient.post(basepath & "/user/createWithList", $(%body)) + httpClient.post(basepath & "/user/createWithList", $(%user)) proc deleteUser*(httpClient: HttpClient, username: string): Response = @@ -84,8 +84,8 @@ proc logoutUser*(httpClient: HttpClient): Response = httpClient.get(basepath & "/user/logout") -proc updateUser*(httpClient: HttpClient, username: string, body: User): Response = +proc updateUser*(httpClient: HttpClient, username: string, user: User): Response = ## Updated user httpClient.headers["Content-Type"] = "application/json" - httpClient.put(basepath & fmt"/user/{username}", $(%body)) + httpClient.put(basepath & fmt"/user/{username}", $(%user)) From dbb42f90278c92d7dde0627a4647f8082dfa13d5 Mon Sep 17 00:00:00 2001 From: Anders Aaen Springborg Date: Thu, 29 Apr 2021 12:23:13 +0200 Subject: [PATCH 03/18] [BUG] new.sh fix generator type , issue #9320 (#9321) * generation type on template dir path * remove gen_type from template and resources --- new.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/new.sh b/new.sh index 12cfec8cb579..7d33be840e55 100755 --- a/new.sh +++ b/new.sh @@ -178,7 +178,7 @@ public class ${lang_classname} extends DefaultCodegen implements CodegenConfig { outputFolder = "generated-code" + File.separator + "${gen_name_camel}"; modelTemplateFiles.put("model.mustache", ".zz"); apiTemplateFiles.put("api.mustache", ".zz"); - embeddedTemplateDir = templateDir = "${gen_name_camel}-${gen_type}"; + embeddedTemplateDir = templateDir = "${gen_name_camel}"; apiPackage = "Apis"; modelPackage = "Models"; supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); @@ -191,17 +191,17 @@ EOF echo -e "\norg.openapitools.codegen.languages.${lang_classname}" >> "${root}/modules/openapi-generator/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig" # Step 3: Create resource files -mkdir -p "${root}/modules/openapi-generator/src/main/resources/${gen_name_camel}-${gen_type}" -echo "Creating modules/openapi-generator/src/main/resources/${gen_name_camel}-${gen_type}/README.mustache" && \ - touch "${root}/modules/openapi-generator/src/main/resources/${gen_name_camel}-${gen_type}/README.mustache" -echo "Creating modules/openapi-generator/src/main/resources/${gen_name_camel}-${gen_type}/model.mustache" && \ - touch "${root}/modules/openapi-generator/src/main/resources/${gen_name_camel}-${gen_type}/model.mustache" -echo "Creating modules/openapi-generator/src/main/resources/${gen_name_camel}-${gen_type}/api.mustache" && \ - touch "${root}/modules/openapi-generator/src/main/resources/${gen_name_camel}-${gen_type}/api.mustache" +mkdir -p "${root}/modules/openapi-generator/src/main/resources/${gen_name_camel}" +echo "Creating modules/openapi-generator/src/main/resources/${gen_name_camel}/README.mustache" && \ + touch "${root}/modules/openapi-generator/src/main/resources/${gen_name_camel}/README.mustache" +echo "Creating modules/openapi-generator/src/main/resources/${gen_name_camel}/model.mustache" && \ + touch "${root}/modules/openapi-generator/src/main/resources/${gen_name_camel}/model.mustache" +echo "Creating modules/openapi-generator/src/main/resources/${gen_name_camel}/api.mustache" && \ + touch "${root}/modules/openapi-generator/src/main/resources/${gen_name_camel}/api.mustache" # Step 4: Create generation config scripts -echo "Creating bin/configs/${gen_name_camel}-${gen_type}-petstore-new.yaml" -cat > "${root}/bin/configs/${gen_name_camel}-${gen_type}-petstore-new.yaml"< "${root}/bin/configs/${gen_name_camel}-petstore-new.yaml"< Date: Thu, 29 Apr 2021 12:51:30 +0200 Subject: [PATCH 04/18] [scala][akka] Update dependencies for scala 2.13 in scala-akka (#8624) * [scala][akka] Update dependencies for scala 2.13 * Update pom.mustache to support multiple scala's version * Update pom.xml * Scala cross build 2.12 and 2.13 * Update version. Migrate to sbt * Remove space * Add pom.xml back --- .../languages/ScalaAkkaClientCodegen.java | 3 +- .../scala-akka-client/apiInvoker.mustache | 31 +++++++++++-------- .../scala-akka-client/apiSettings.mustache | 15 +++++++-- .../scala-akka-client/build.sbt.mustache | 24 ++++++++------ .../resources/scala-akka-client/pom.mustache | 30 +++++++++++------- .../project/build.properties.mustache | 1 + .../scalaakka/ScalaAkkaClientCodegenTest.java | 4 +-- .../scala-akka/.openapi-generator/FILES | 1 + samples/client/petstore/scala-akka/build.sbt | 24 ++++++++------ samples/client/petstore/scala-akka/pom.xml | 30 +++++++++++------- .../scala-akka/project/build.properties | 1 + .../openapitools/client/core/ApiInvoker.scala | 31 +++++++++++-------- .../client/core/ApiSettings.scala | 15 +++++++-- .../src/test/scala/PetApiTest.scala | 24 +++++++------- 14 files changed, 143 insertions(+), 91 deletions(-) create mode 100644 modules/openapi-generator/src/main/resources/scala-akka-client/project/build.properties.mustache create mode 100644 samples/client/petstore/scala-akka/project/build.properties diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaAkkaClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaAkkaClientCodegen.java index 138e9bf9c1d8..a5e293c9879d 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaAkkaClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaAkkaClientCodegen.java @@ -166,8 +166,8 @@ public void processOpts() { additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage); supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); - supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml")); supportingFiles.add(new SupportingFile("build.sbt.mustache", "", "build.sbt")); + supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml")); supportingFiles.add(new SupportingFile("reference.mustache", resourcesFolder, "reference.conf")); final String invokerFolder = (sourceFolder + File.separator + invokerPackage).replace(".", File.separator); supportingFiles.add(new SupportingFile("apiRequest.mustache", invokerFolder, "ApiRequest.scala")); @@ -175,6 +175,7 @@ public void processOpts() { supportingFiles.add(new SupportingFile("requests.mustache", invokerFolder, "requests.scala")); supportingFiles.add(new SupportingFile("apiSettings.mustache", invokerFolder, "ApiSettings.scala")); final String apiFolder = (sourceFolder + File.separator + apiPackage).replace(".", File.separator); + supportingFiles.add(new SupportingFile("project/build.properties.mustache", "project", "build.properties")); supportingFiles.add(new SupportingFile("enumsSerializers.mustache", apiFolder, "EnumsSerializers.scala")); supportingFiles.add(new SupportingFile("serializers.mustache", invokerFolder, "Serializers.scala")); } diff --git a/modules/openapi-generator/src/main/resources/scala-akka-client/apiInvoker.mustache b/modules/openapi-generator/src/main/resources/scala-akka-client/apiInvoker.mustache index 8c81b0b2d8b5..a82135170c43 100644 --- a/modules/openapi-generator/src/main/resources/scala-akka-client/apiInvoker.mustache +++ b/modules/openapi-generator/src/main/resources/scala-akka-client/apiInvoker.mustache @@ -18,6 +18,7 @@ import de.heikoseeberger.akkahttpjson4s.Json4sSupport import org.json4s._ import org.json4s.jackson.JsonMethods._ import org.json4s.jackson.Serialization +import scala.collection.compat._ import scala.collection.immutable import scala.concurrent.{ ExecutionContext, ExecutionContextExecutor, Future } @@ -86,7 +87,7 @@ class ApiInvoker(formats: Formats)(implicit system: ActorSystem) extends CustomC private val http = Http() - val CompressionFilter: HttpMessage ⇒ Boolean = (msg: HttpMessage) => + val CompressionFilter: HttpMessage => Boolean = (msg: HttpMessage) => Seq( { _: HttpMessage => settings.compressionEnabled }, Encoder.DefaultFilter, @@ -115,7 +116,7 @@ class ApiInvoker(formats: Formats)(implicit system: ActorSystem) extends CustomC private def headers(headers: Map[String, Any]): immutable.Seq[HttpHeader] = headers.asFormattedParams .map { case (name, value) => RawHeader(name, value.toString) } - .to[immutable.Seq] + .to(immutable.Seq) private def bodyPart(name: String, value: Any): BodyPart = { @@ -147,9 +148,9 @@ class ApiInvoker(formats: Formats)(implicit system: ActorSystem) extends CustomC case MediaTypes.`multipart/form-data` => Multipart.FormData(Source(params.toList.map { case (name, value) => bodyPart(name, value) })) case MediaTypes.`application/x-www-form-urlencoded` => - FormData(params.mapValues(_.toString)) + FormData(params.view.mapValues(_.toString).toMap) case _: MediaType => // Default : application/x-www-form-urlencoded. - FormData(params.mapValues(_.toString)) + FormData(params.view.mapValues(_.toString).toMap) } ) } @@ -187,7 +188,9 @@ class ApiInvoker(formats: Formats)(implicit system: ActorSystem) extends CustomC params + (keyName -> key.value) case (params, _) => params }.asFormattedParams + .view .mapValues(_.toString) + .toMap .foldRight[Query](Uri.Query.Empty) { case ((name, value), acc) => acc.+:(name, value) } @@ -196,7 +199,9 @@ class ApiInvoker(formats: Formats)(implicit system: ActorSystem) extends CustomC def makeUri(r: ApiRequest[_]): Uri = { val opPath = r.operationPath.replaceAll("\\{format\\}", "json") val opPathWithParams = r.pathParams.asFormattedParams + .view .mapValues(_.toString) + .toMap .foldLeft(opPath) { case (path, (name, value)) => path.replaceAll(s"\\{$name\\}", value) } @@ -213,13 +218,13 @@ class ApiInvoker(formats: Formats)(implicit system: ActorSystem) extends CustomC http .singleRequest(request) .map { response => - val decoder: Coder with StreamDecoder = response.encoding match { - case HttpEncodings.gzip ⇒ - Gzip - case HttpEncodings.deflate ⇒ - Deflate - case HttpEncodings.identity ⇒ - NoCoding + val decoder: Decoder with Decoder = response.encoding match { + case HttpEncodings.gzip => + Coders.Gzip + case HttpEncodings.deflate => + Coders.Deflate + case HttpEncodings.identity => + Coders.NoCoding case HttpEncoding(encoding) => throw new IllegalArgumentException(s"Unsupported encoding: $encoding") } @@ -247,13 +252,13 @@ class ApiInvoker(formats: Formats)(implicit system: ActorSystem) extends CustomC request .responseForCode(response.status.intValue) match { case Some((Manifest.Unit, state: ResponseState)) => - Future(responseForState(state, Unit).asInstanceOf[ApiResponse[T]]) + Future(responseForState(state, ()).asInstanceOf[ApiResponse[T]]) case Some((manifest, state: ResponseState)) if manifest == mf => implicit val m: Unmarshaller[HttpEntity, T] = unmarshaller[T](mf, serialization, formats) Unmarshal(response.entity) .to[T] .recoverWith { - case e ⇒ throw ApiError(response.status.intValue, s"Unable to unmarshall content to [$manifest]", Some(response.entity.toString), e) + case e => throw ApiError(response.status.intValue, s"Unable to unmarshall content to [$manifest]", Some(response.entity.toString), e) } .map(value => responseForState(state, value)) case None | Some(_) => diff --git a/modules/openapi-generator/src/main/resources/scala-akka-client/apiSettings.mustache b/modules/openapi-generator/src/main/resources/scala-akka-client/apiSettings.mustache index d5856ccc17d1..22f56080b01c 100644 --- a/modules/openapi-generator/src/main/resources/scala-akka-client/apiSettings.mustache +++ b/modules/openapi-generator/src/main/resources/scala-akka-client/apiSettings.mustache @@ -3,12 +3,12 @@ package {{invokerPackage}} import java.util.concurrent.TimeUnit -import akka.actor.{ ExtendedActorSystem, Extension, ExtensionKey } +import akka.actor.{ActorSystem, ExtendedActorSystem, Extension, ExtensionId, ExtensionIdProvider} import akka.http.scaladsl.model.StatusCodes.CustomStatusCode import akka.http.scaladsl.model.headers.RawHeader import com.typesafe.config.Config -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ import scala.concurrent.duration.FiniteDuration class ApiSettings(config: Config) extends Extension { @@ -32,4 +32,13 @@ class ApiSettings(config: Config) extends Extension { } } -object ApiSettings extends ExtensionKey[ApiSettings] +object ApiSettings extends ExtensionId[ApiSettings] with ExtensionIdProvider { + + override def lookup = ApiSettings + + override def createExtension(system: ExtendedActorSystem): ApiSettings = + new ApiSettings(system) + + // needed to get the type right when used from Java + override def get(system: ActorSystem): ApiSettings = super.get(system) +} diff --git a/modules/openapi-generator/src/main/resources/scala-akka-client/build.sbt.mustache b/modules/openapi-generator/src/main/resources/scala-akka-client/build.sbt.mustache index c26dae841c7b..e4c21c19d0c0 100644 --- a/modules/openapi-generator/src/main/resources/scala-akka-client/build.sbt.mustache +++ b/modules/openapi-generator/src/main/resources/scala-akka-client/build.sbt.mustache @@ -1,22 +1,26 @@ version := "{{artifactVersion}}" name := "{{artifactId}}" organization := "{{groupId}}" -scalaVersion := "2.12.8" + +scalaVersion := "2.12.13" +crossScalaVersions := Seq(scalaVersion.value, "2.13.4") + libraryDependencies ++= Seq( - "com.typesafe" % "config" % "1.3.3", - "com.typesafe.akka" %% "akka-actor" % "2.5.21", - "com.typesafe.akka" %% "akka-stream" % "2.5.21", - "com.typesafe.akka" %% "akka-http" % "10.1.7", + "com.typesafe" % "config" % "1.4.1", + "com.typesafe.akka" %% "akka-actor" % "2.6.12", + "com.typesafe.akka" %% "akka-stream" % "2.6.12", + "com.typesafe.akka" %% "akka-http" % "10.2.3", {{#joda}} "joda-time" % "joda-time" % "2.10.1", {{/joda}} - "org.json4s" %% "json4s-jackson" % "3.6.5", - "org.json4s" %% "json4s-ext" % "3.6.5", - "de.heikoseeberger" %% "akka-http-json4s" % "1.25.2", + "org.json4s" %% "json4s-jackson" % "3.6.7", + "org.json4s" %% "json4s-ext" % "3.6.7", + "de.heikoseeberger" %% "akka-http-json4s" % "1.27.0", + "org.scala-lang.modules" %% "scala-collection-compat" % "2.4.1", // test dependencies - "org.scalatest" %% "scalatest" % "3.0.5" % "test", - "junit" % "junit" % "4.13.1" % "test" + "org.scalatest" %% "scalatest" % "3.2.3" % "test", + "org.scalatestplus" %% "junit-4-13" % "3.2.3.0" % "test" ) resolvers ++= Seq(Resolver.mavenLocal) diff --git a/modules/openapi-generator/src/main/resources/scala-akka-client/pom.mustache b/modules/openapi-generator/src/main/resources/scala-akka-client/pom.mustache index 78cbec12128a..e82df0c17b9a 100644 --- a/modules/openapi-generator/src/main/resources/scala-akka-client/pom.mustache +++ b/modules/openapi-generator/src/main/resources/scala-akka-client/pom.mustache @@ -15,18 +15,19 @@ UTF-8 1.8 - 2.12.8 - 3.5.3 - 3.2.11 - 2.5.21 - 10.1.7 + 2.12.13 + 3.6.7 + 3.6.7 + 2.6.12 + 10.2.3 {{#joda}} 2.10.1 {{/joda}} - 1.3.3 - 1.25.2 - 4.13.1 - 3.0.5 + 1.4.1 + 1.27.0 + 2.4.1 + 3.2.3 + 3.2.3.0 3.3.1 @@ -80,6 +81,11 @@ akka-http-json4s_2.12 ${akka.http.json4s.version} + + org.scala-lang.modules + scala-collection-compat_2.12 + ${scala.compat.version} + @@ -89,9 +95,9 @@ test - junit - junit - ${junit.version} + org.scalatestplus + junit-4-13_2.12 + ${scala.test.plus.version} test diff --git a/modules/openapi-generator/src/main/resources/scala-akka-client/project/build.properties.mustache b/modules/openapi-generator/src/main/resources/scala-akka-client/project/build.properties.mustache new file mode 100644 index 000000000000..dc07aed85e00 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/scala-akka-client/project/build.properties.mustache @@ -0,0 +1 @@ +sbt.version=1.3.10 \ No newline at end of file diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/scalaakka/ScalaAkkaClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/scalaakka/ScalaAkkaClientCodegenTest.java index d78b487d2860..4304e092bb16 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/scalaakka/ScalaAkkaClientCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/scalaakka/ScalaAkkaClientCodegenTest.java @@ -472,7 +472,7 @@ public void mainPackageTest() throws Exception { Generator gen = generator.opts(clientOptInput); List files = gen.generate(); - Assert.assertEquals(files.size(), 15); + Assert.assertEquals(files.size(), 16); TestUtils.ensureContainsFile(files, output, "src/main/scala/hello/world/model/SomeObj.scala"); TestUtils.ensureContainsFile(files, output, "src/main/scala/hello/world/core/ApiSettings.scala"); @@ -509,7 +509,7 @@ public void overridePackagesTest() throws Exception { Generator gen = generator.opts(clientOptInput); List files = gen.generate(); - Assert.assertEquals(files.size(), 15); + Assert.assertEquals(files.size(), 16); TestUtils.ensureContainsFile(files, output, "src/main/scala/hello/world/model/package/SomeObj.scala"); TestUtils.ensureContainsFile(files, output, "src/main/scala/hello/world/package/invoker/ApiSettings.scala"); diff --git a/samples/client/petstore/scala-akka/.openapi-generator/FILES b/samples/client/petstore/scala-akka/.openapi-generator/FILES index 8d22043b5a91..2cd9737cf183 100644 --- a/samples/client/petstore/scala-akka/.openapi-generator/FILES +++ b/samples/client/petstore/scala-akka/.openapi-generator/FILES @@ -1,5 +1,6 @@ README.md build.sbt +project/build.properties src/main/resources/reference.conf src/main/scala/org/openapitools/client/api/EnumsSerializers.scala src/main/scala/org/openapitools/client/api/PetApi.scala diff --git a/samples/client/petstore/scala-akka/build.sbt b/samples/client/petstore/scala-akka/build.sbt index 038757790a5a..e9915b07f85f 100644 --- a/samples/client/petstore/scala-akka/build.sbt +++ b/samples/client/petstore/scala-akka/build.sbt @@ -1,19 +1,23 @@ version := "1.0.0" name := "scala-akka-petstore-client" organization := "org.openapitools" -scalaVersion := "2.12.8" + +scalaVersion := "2.12.13" +crossScalaVersions := Seq(scalaVersion.value, "2.13.4") + libraryDependencies ++= Seq( - "com.typesafe" % "config" % "1.3.3", - "com.typesafe.akka" %% "akka-actor" % "2.5.21", - "com.typesafe.akka" %% "akka-stream" % "2.5.21", - "com.typesafe.akka" %% "akka-http" % "10.1.7", - "org.json4s" %% "json4s-jackson" % "3.6.5", - "org.json4s" %% "json4s-ext" % "3.6.5", - "de.heikoseeberger" %% "akka-http-json4s" % "1.25.2", + "com.typesafe" % "config" % "1.4.1", + "com.typesafe.akka" %% "akka-actor" % "2.6.12", + "com.typesafe.akka" %% "akka-stream" % "2.6.12", + "com.typesafe.akka" %% "akka-http" % "10.2.3", + "org.json4s" %% "json4s-jackson" % "3.6.7", + "org.json4s" %% "json4s-ext" % "3.6.7", + "de.heikoseeberger" %% "akka-http-json4s" % "1.27.0", + "org.scala-lang.modules" %% "scala-collection-compat" % "2.4.1", // test dependencies - "org.scalatest" %% "scalatest" % "3.0.5" % "test", - "junit" % "junit" % "4.13.1" % "test" + "org.scalatest" %% "scalatest" % "3.2.3" % "test", + "org.scalatestplus" %% "junit-4-13" % "3.2.3.0" % "test" ) resolvers ++= Seq(Resolver.mavenLocal) diff --git a/samples/client/petstore/scala-akka/pom.xml b/samples/client/petstore/scala-akka/pom.xml index 42e08693b641..0f93bcb372b4 100644 --- a/samples/client/petstore/scala-akka/pom.xml +++ b/samples/client/petstore/scala-akka/pom.xml @@ -15,15 +15,16 @@ UTF-8 1.8 - 2.12.8 - 3.5.3 - 3.2.11 - 2.5.21 - 10.1.7 - 1.3.3 - 1.25.2 - 4.13 - 3.0.5 + 2.12.13 + 3.6.7 + 3.6.7 + 2.6.12 + 10.2.3 + 1.4.1 + 1.27.0 + 2.4.1 + 3.2.3 + 3.2.3.0 3.3.1 @@ -70,6 +71,11 @@ akka-http-json4s_2.12 ${akka.http.json4s.version} + + org.scala-lang.modules + scala-collection-compat_2.12 + ${scala.compat.version} + @@ -79,9 +85,9 @@ test - junit - junit - ${junit.version} + org.scalatestplus + junit-4-13_2.12 + ${scala.test.plus.version} test diff --git a/samples/client/petstore/scala-akka/project/build.properties b/samples/client/petstore/scala-akka/project/build.properties new file mode 100644 index 000000000000..dc07aed85e00 --- /dev/null +++ b/samples/client/petstore/scala-akka/project/build.properties @@ -0,0 +1 @@ +sbt.version=1.3.10 \ No newline at end of file diff --git a/samples/client/petstore/scala-akka/src/main/scala/org/openapitools/client/core/ApiInvoker.scala b/samples/client/petstore/scala-akka/src/main/scala/org/openapitools/client/core/ApiInvoker.scala index d3ff4cadb8ec..fe3910967139 100644 --- a/samples/client/petstore/scala-akka/src/main/scala/org/openapitools/client/core/ApiInvoker.scala +++ b/samples/client/petstore/scala-akka/src/main/scala/org/openapitools/client/core/ApiInvoker.scala @@ -28,6 +28,7 @@ import de.heikoseeberger.akkahttpjson4s.Json4sSupport import org.json4s._ import org.json4s.jackson.JsonMethods._ import org.json4s.jackson.Serialization +import scala.collection.compat._ import scala.collection.immutable import scala.concurrent.{ ExecutionContext, ExecutionContextExecutor, Future } @@ -96,7 +97,7 @@ class ApiInvoker(formats: Formats)(implicit system: ActorSystem) extends CustomC private val http = Http() - val CompressionFilter: HttpMessage ⇒ Boolean = (msg: HttpMessage) => + val CompressionFilter: HttpMessage => Boolean = (msg: HttpMessage) => Seq( { _: HttpMessage => settings.compressionEnabled }, Encoder.DefaultFilter, @@ -125,7 +126,7 @@ class ApiInvoker(formats: Formats)(implicit system: ActorSystem) extends CustomC private def headers(headers: Map[String, Any]): immutable.Seq[HttpHeader] = headers.asFormattedParams .map { case (name, value) => RawHeader(name, value.toString) } - .to[immutable.Seq] + .to(immutable.Seq) private def bodyPart(name: String, value: Any): BodyPart = { @@ -157,9 +158,9 @@ class ApiInvoker(formats: Formats)(implicit system: ActorSystem) extends CustomC case MediaTypes.`multipart/form-data` => Multipart.FormData(Source(params.toList.map { case (name, value) => bodyPart(name, value) })) case MediaTypes.`application/x-www-form-urlencoded` => - FormData(params.mapValues(_.toString)) + FormData(params.view.mapValues(_.toString).toMap) case _: MediaType => // Default : application/x-www-form-urlencoded. - FormData(params.mapValues(_.toString)) + FormData(params.view.mapValues(_.toString).toMap) } ) } @@ -197,7 +198,9 @@ class ApiInvoker(formats: Formats)(implicit system: ActorSystem) extends CustomC params + (keyName -> key.value) case (params, _) => params }.asFormattedParams + .view .mapValues(_.toString) + .toMap .foldRight[Query](Uri.Query.Empty) { case ((name, value), acc) => acc.+:(name, value) } @@ -206,7 +209,9 @@ class ApiInvoker(formats: Formats)(implicit system: ActorSystem) extends CustomC def makeUri(r: ApiRequest[_]): Uri = { val opPath = r.operationPath.replaceAll("\\{format\\}", "json") val opPathWithParams = r.pathParams.asFormattedParams + .view .mapValues(_.toString) + .toMap .foldLeft(opPath) { case (path, (name, value)) => path.replaceAll(s"\\{$name\\}", value) } @@ -223,13 +228,13 @@ class ApiInvoker(formats: Formats)(implicit system: ActorSystem) extends CustomC http .singleRequest(request) .map { response => - val decoder: Coder with StreamDecoder = response.encoding match { - case HttpEncodings.gzip ⇒ - Gzip - case HttpEncodings.deflate ⇒ - Deflate - case HttpEncodings.identity ⇒ - NoCoding + val decoder: Decoder with Decoder = response.encoding match { + case HttpEncodings.gzip => + Coders.Gzip + case HttpEncodings.deflate => + Coders.Deflate + case HttpEncodings.identity => + Coders.NoCoding case HttpEncoding(encoding) => throw new IllegalArgumentException(s"Unsupported encoding: $encoding") } @@ -257,13 +262,13 @@ class ApiInvoker(formats: Formats)(implicit system: ActorSystem) extends CustomC request .responseForCode(response.status.intValue) match { case Some((Manifest.Unit, state: ResponseState)) => - Future(responseForState(state, Unit).asInstanceOf[ApiResponse[T]]) + Future(responseForState(state, ()).asInstanceOf[ApiResponse[T]]) case Some((manifest, state: ResponseState)) if manifest == mf => implicit val m: Unmarshaller[HttpEntity, T] = unmarshaller[T](mf, serialization, formats) Unmarshal(response.entity) .to[T] .recoverWith { - case e ⇒ throw ApiError(response.status.intValue, s"Unable to unmarshall content to [$manifest]", Some(response.entity.toString), e) + case e => throw ApiError(response.status.intValue, s"Unable to unmarshall content to [$manifest]", Some(response.entity.toString), e) } .map(value => responseForState(state, value)) case None | Some(_) => diff --git a/samples/client/petstore/scala-akka/src/main/scala/org/openapitools/client/core/ApiSettings.scala b/samples/client/petstore/scala-akka/src/main/scala/org/openapitools/client/core/ApiSettings.scala index 2553aeb3c875..2c02c47c7bac 100644 --- a/samples/client/petstore/scala-akka/src/main/scala/org/openapitools/client/core/ApiSettings.scala +++ b/samples/client/petstore/scala-akka/src/main/scala/org/openapitools/client/core/ApiSettings.scala @@ -13,12 +13,12 @@ package org.openapitools.client.core import java.util.concurrent.TimeUnit -import akka.actor.{ ExtendedActorSystem, Extension, ExtensionKey } +import akka.actor.{ActorSystem, ExtendedActorSystem, Extension, ExtensionId, ExtensionIdProvider} import akka.http.scaladsl.model.StatusCodes.CustomStatusCode import akka.http.scaladsl.model.headers.RawHeader import com.typesafe.config.Config -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ import scala.concurrent.duration.FiniteDuration class ApiSettings(config: Config) extends Extension { @@ -42,4 +42,13 @@ class ApiSettings(config: Config) extends Extension { } } -object ApiSettings extends ExtensionKey[ApiSettings] +object ApiSettings extends ExtensionId[ApiSettings] with ExtensionIdProvider { + + override def lookup = ApiSettings + + override def createExtension(system: ExtendedActorSystem): ApiSettings = + new ApiSettings(system) + + // needed to get the type right when used from Java + override def get(system: ActorSystem): ApiSettings = super.get(system) +} diff --git a/samples/client/petstore/scala-akka/src/test/scala/PetApiTest.scala b/samples/client/petstore/scala-akka/src/test/scala/PetApiTest.scala index e6229fb05f3a..48c8d4c644fd 100644 --- a/samples/client/petstore/scala-akka/src/test/scala/PetApiTest.scala +++ b/samples/client/petstore/scala-akka/src/test/scala/PetApiTest.scala @@ -5,18 +5,19 @@ import org.openapitools.client.api._ import org.openapitools.client.core.{ApiInvoker, ApiKeyValue} import org.openapitools.client.model._ import org.scalatest.Inspectors._ -import org.scalatest._ -import org.scalatest.junit.JUnitRunner +import org.scalatest.flatspec.AsyncFlatSpec +import org.scalatest.matchers.should.Matchers +import org.scalatestplus.junit.JUnitRunner @RunWith(classOf[JUnitRunner]) class PetApiTest extends AsyncFlatSpec with Matchers { - private implicit val system: ActorSystem = ActorSystem() + implicit private val system: ActorSystem = ActorSystem() behavior of "PetApi" - val api: PetApi = PetApi() - val invoker: ApiInvoker = ApiInvoker(EnumsSerializers.all) - private implicit val apiKey: ApiKeyValue = ApiKeyValue("special-key") + val api: PetApi = PetApi() + val invoker: ApiInvoker = ApiInvoker(EnumsSerializers.all) + implicit private val apiKey: ApiKeyValue = ApiKeyValue("special-key") it should "add and fetch a pet" in { val petId = 1000 @@ -34,7 +35,7 @@ class PetApiTest extends AsyncFlatSpec with Matchers { for { addResponse <- invoker.execute(addPetRequest) - response <- invoker.execute(getPetRequest) + response <- invoker.execute(getPetRequest) } yield { addResponse.code should be(200) @@ -54,7 +55,7 @@ class PetApiTest extends AsyncFlatSpec with Matchers { } it should "update a pet" in { - val petId = (Math.random()*1000000000).toLong + val petId = (Math.random() * 1000000000).toLong val createdPet = Pet( Some(petId), Some(Category(Some(1), Some("sold"))), @@ -64,12 +65,12 @@ class PetApiTest extends AsyncFlatSpec with Matchers { Some(PetEnums.Status.Available) ) - for { - createdPet <- invoker.execute(api.addPet(createdPet)) + for { + createdPet <- invoker.execute(api.addPet(createdPet)) pet: core.ApiResponse[Pet] <- invoker.execute(api.getPetById(createdPet.content.id.get)) updatedPet = pet.content.copy(status = Some(PetEnums.Status.Sold), name = "developer") updatedPetResponse: core.ApiResponse[Pet] <- invoker.execute(api.updatePet(updatedPet)) - updatedRequested: core.ApiResponse[Pet] <- invoker.execute(api.getPetById(createdPet.content.id.get)) + updatedRequested: core.ApiResponse[Pet] <- invoker.execute(api.getPetById(createdPet.content.id.get)) } yield { pet.content.name should be("programmer") pet.content.status should be(Some(PetEnums.Status.Available)) @@ -120,4 +121,3 @@ class PetApiTest extends AsyncFlatSpec with Matchers { } */ } - From a88313c40ce5fcc3264119670756ce5813bb24ac Mon Sep 17 00:00:00 2001 From: johnthagen Date: Fri, 30 Apr 2021 14:59:33 -0400 Subject: [PATCH 05/18] [Python] Avoid DeprecationWarning in inspect.getargspec on Python 3 (#9271) * Avoid DeprecationWarning in inspect.getargspec on Python 3 * Regenerate samples --- .../src/main/resources/python-legacy/model.mustache | 7 +++++-- .../petstore_api/models/additional_properties_any_type.py | 7 +++++-- .../petstore_api/models/additional_properties_array.py | 7 +++++-- .../petstore_api/models/additional_properties_boolean.py | 7 +++++-- .../petstore_api/models/additional_properties_class.py | 7 +++++-- .../petstore_api/models/additional_properties_integer.py | 7 +++++-- .../petstore_api/models/additional_properties_number.py | 7 +++++-- .../petstore_api/models/additional_properties_object.py | 7 +++++-- .../petstore_api/models/additional_properties_string.py | 7 +++++-- .../petstore/python-asyncio/petstore_api/models/animal.py | 7 +++++-- .../python-asyncio/petstore_api/models/api_response.py | 7 +++++-- .../petstore_api/models/array_of_array_of_number_only.py | 7 +++++-- .../petstore_api/models/array_of_number_only.py | 7 +++++-- .../python-asyncio/petstore_api/models/array_test.py | 7 +++++-- .../petstore/python-asyncio/petstore_api/models/big_cat.py | 7 +++++-- .../python-asyncio/petstore_api/models/big_cat_all_of.py | 7 +++++-- .../python-asyncio/petstore_api/models/capitalization.py | 7 +++++-- .../petstore/python-asyncio/petstore_api/models/cat.py | 7 +++++-- .../python-asyncio/petstore_api/models/cat_all_of.py | 7 +++++-- .../python-asyncio/petstore_api/models/category.py | 7 +++++-- .../python-asyncio/petstore_api/models/class_model.py | 7 +++++-- .../petstore/python-asyncio/petstore_api/models/client.py | 7 +++++-- .../petstore/python-asyncio/petstore_api/models/dog.py | 7 +++++-- .../python-asyncio/petstore_api/models/dog_all_of.py | 7 +++++-- .../python-asyncio/petstore_api/models/enum_arrays.py | 7 +++++-- .../python-asyncio/petstore_api/models/enum_class.py | 7 +++++-- .../python-asyncio/petstore_api/models/enum_test.py | 7 +++++-- .../petstore/python-asyncio/petstore_api/models/file.py | 7 +++++-- .../petstore_api/models/file_schema_test_class.py | 7 +++++-- .../python-asyncio/petstore_api/models/format_test.py | 7 +++++-- .../petstore_api/models/has_only_read_only.py | 7 +++++-- .../petstore/python-asyncio/petstore_api/models/list.py | 7 +++++-- .../python-asyncio/petstore_api/models/map_test.py | 7 +++++-- .../mixed_properties_and_additional_properties_class.py | 7 +++++-- .../petstore_api/models/model200_response.py | 7 +++++-- .../python-asyncio/petstore_api/models/model_return.py | 7 +++++-- .../petstore/python-asyncio/petstore_api/models/name.py | 7 +++++-- .../python-asyncio/petstore_api/models/number_only.py | 7 +++++-- .../petstore/python-asyncio/petstore_api/models/order.py | 7 +++++-- .../python-asyncio/petstore_api/models/outer_composite.py | 7 +++++-- .../python-asyncio/petstore_api/models/outer_enum.py | 7 +++++-- .../petstore/python-asyncio/petstore_api/models/pet.py | 7 +++++-- .../python-asyncio/petstore_api/models/read_only_first.py | 7 +++++-- .../petstore_api/models/special_model_name.py | 7 +++++-- .../petstore/python-asyncio/petstore_api/models/tag.py | 7 +++++-- .../petstore_api/models/type_holder_default.py | 7 +++++-- .../petstore_api/models/type_holder_example.py | 7 +++++-- .../petstore/python-asyncio/petstore_api/models/user.py | 7 +++++-- .../python-asyncio/petstore_api/models/xml_item.py | 7 +++++-- .../petstore_api/models/additional_properties_any_type.py | 7 +++++-- .../petstore_api/models/additional_properties_array.py | 7 +++++-- .../petstore_api/models/additional_properties_boolean.py | 7 +++++-- .../petstore_api/models/additional_properties_class.py | 7 +++++-- .../petstore_api/models/additional_properties_integer.py | 7 +++++-- .../petstore_api/models/additional_properties_number.py | 7 +++++-- .../petstore_api/models/additional_properties_object.py | 7 +++++-- .../petstore_api/models/additional_properties_string.py | 7 +++++-- .../petstore/python-legacy/petstore_api/models/animal.py | 7 +++++-- .../python-legacy/petstore_api/models/api_response.py | 7 +++++-- .../petstore_api/models/array_of_array_of_number_only.py | 7 +++++-- .../petstore_api/models/array_of_number_only.py | 7 +++++-- .../python-legacy/petstore_api/models/array_test.py | 7 +++++-- .../petstore/python-legacy/petstore_api/models/big_cat.py | 7 +++++-- .../python-legacy/petstore_api/models/big_cat_all_of.py | 7 +++++-- .../python-legacy/petstore_api/models/capitalization.py | 7 +++++-- .../petstore/python-legacy/petstore_api/models/cat.py | 7 +++++-- .../python-legacy/petstore_api/models/cat_all_of.py | 7 +++++-- .../petstore/python-legacy/petstore_api/models/category.py | 7 +++++-- .../python-legacy/petstore_api/models/class_model.py | 7 +++++-- .../petstore/python-legacy/petstore_api/models/client.py | 7 +++++-- .../petstore/python-legacy/petstore_api/models/dog.py | 7 +++++-- .../python-legacy/petstore_api/models/dog_all_of.py | 7 +++++-- .../python-legacy/petstore_api/models/enum_arrays.py | 7 +++++-- .../python-legacy/petstore_api/models/enum_class.py | 7 +++++-- .../python-legacy/petstore_api/models/enum_test.py | 7 +++++-- .../petstore/python-legacy/petstore_api/models/file.py | 7 +++++-- .../petstore_api/models/file_schema_test_class.py | 7 +++++-- .../python-legacy/petstore_api/models/format_test.py | 7 +++++-- .../petstore_api/models/has_only_read_only.py | 7 +++++-- .../petstore/python-legacy/petstore_api/models/list.py | 7 +++++-- .../petstore/python-legacy/petstore_api/models/map_test.py | 7 +++++-- .../mixed_properties_and_additional_properties_class.py | 7 +++++-- .../python-legacy/petstore_api/models/model200_response.py | 7 +++++-- .../python-legacy/petstore_api/models/model_return.py | 7 +++++-- .../petstore/python-legacy/petstore_api/models/name.py | 7 +++++-- .../python-legacy/petstore_api/models/number_only.py | 7 +++++-- .../petstore/python-legacy/petstore_api/models/order.py | 7 +++++-- .../python-legacy/petstore_api/models/outer_composite.py | 7 +++++-- .../python-legacy/petstore_api/models/outer_enum.py | 7 +++++-- .../petstore/python-legacy/petstore_api/models/pet.py | 7 +++++-- .../python-legacy/petstore_api/models/read_only_first.py | 7 +++++-- .../petstore_api/models/special_model_name.py | 7 +++++-- .../petstore/python-legacy/petstore_api/models/tag.py | 7 +++++-- .../petstore_api/models/type_holder_default.py | 7 +++++-- .../petstore_api/models/type_holder_example.py | 7 +++++-- .../petstore/python-legacy/petstore_api/models/user.py | 7 +++++-- .../petstore/python-legacy/petstore_api/models/xml_item.py | 7 +++++-- .../petstore_api/models/additional_properties_any_type.py | 7 +++++-- .../petstore_api/models/additional_properties_array.py | 7 +++++-- .../petstore_api/models/additional_properties_boolean.py | 7 +++++-- .../petstore_api/models/additional_properties_class.py | 7 +++++-- .../petstore_api/models/additional_properties_integer.py | 7 +++++-- .../petstore_api/models/additional_properties_number.py | 7 +++++-- .../petstore_api/models/additional_properties_object.py | 7 +++++-- .../petstore_api/models/additional_properties_string.py | 7 +++++-- .../petstore/python-tornado/petstore_api/models/animal.py | 7 +++++-- .../python-tornado/petstore_api/models/api_response.py | 7 +++++-- .../petstore_api/models/array_of_array_of_number_only.py | 7 +++++-- .../petstore_api/models/array_of_number_only.py | 7 +++++-- .../python-tornado/petstore_api/models/array_test.py | 7 +++++-- .../petstore/python-tornado/petstore_api/models/big_cat.py | 7 +++++-- .../python-tornado/petstore_api/models/big_cat_all_of.py | 7 +++++-- .../python-tornado/petstore_api/models/capitalization.py | 7 +++++-- .../petstore/python-tornado/petstore_api/models/cat.py | 7 +++++-- .../python-tornado/petstore_api/models/cat_all_of.py | 7 +++++-- .../python-tornado/petstore_api/models/category.py | 7 +++++-- .../python-tornado/petstore_api/models/class_model.py | 7 +++++-- .../petstore/python-tornado/petstore_api/models/client.py | 7 +++++-- .../petstore/python-tornado/petstore_api/models/dog.py | 7 +++++-- .../python-tornado/petstore_api/models/dog_all_of.py | 7 +++++-- .../python-tornado/petstore_api/models/enum_arrays.py | 7 +++++-- .../python-tornado/petstore_api/models/enum_class.py | 7 +++++-- .../python-tornado/petstore_api/models/enum_test.py | 7 +++++-- .../petstore/python-tornado/petstore_api/models/file.py | 7 +++++-- .../petstore_api/models/file_schema_test_class.py | 7 +++++-- .../python-tornado/petstore_api/models/format_test.py | 7 +++++-- .../petstore_api/models/has_only_read_only.py | 7 +++++-- .../petstore/python-tornado/petstore_api/models/list.py | 7 +++++-- .../python-tornado/petstore_api/models/map_test.py | 7 +++++-- .../mixed_properties_and_additional_properties_class.py | 7 +++++-- .../petstore_api/models/model200_response.py | 7 +++++-- .../python-tornado/petstore_api/models/model_return.py | 7 +++++-- .../petstore/python-tornado/petstore_api/models/name.py | 7 +++++-- .../python-tornado/petstore_api/models/number_only.py | 7 +++++-- .../petstore/python-tornado/petstore_api/models/order.py | 7 +++++-- .../python-tornado/petstore_api/models/outer_composite.py | 7 +++++-- .../python-tornado/petstore_api/models/outer_enum.py | 7 +++++-- .../petstore/python-tornado/petstore_api/models/pet.py | 7 +++++-- .../python-tornado/petstore_api/models/read_only_first.py | 7 +++++-- .../petstore_api/models/special_model_name.py | 7 +++++-- .../petstore/python-tornado/petstore_api/models/tag.py | 7 +++++-- .../petstore_api/models/type_holder_default.py | 7 +++++-- .../petstore_api/models/type_holder_example.py | 7 +++++-- .../petstore/python-tornado/petstore_api/models/user.py | 7 +++++-- .../python-tornado/petstore_api/models/xml_item.py | 7 +++++-- .../petstore_api/models/additional_properties_class.py | 7 +++++-- .../petstore/python-legacy/petstore_api/models/animal.py | 7 +++++-- .../python-legacy/petstore_api/models/api_response.py | 7 +++++-- .../petstore_api/models/array_of_array_of_number_only.py | 7 +++++-- .../petstore_api/models/array_of_number_only.py | 7 +++++-- .../python-legacy/petstore_api/models/array_test.py | 7 +++++-- .../python-legacy/petstore_api/models/capitalization.py | 7 +++++-- .../petstore/python-legacy/petstore_api/models/cat.py | 7 +++++-- .../python-legacy/petstore_api/models/cat_all_of.py | 7 +++++-- .../petstore/python-legacy/petstore_api/models/category.py | 7 +++++-- .../python-legacy/petstore_api/models/class_model.py | 7 +++++-- .../petstore/python-legacy/petstore_api/models/client.py | 7 +++++-- .../petstore/python-legacy/petstore_api/models/dog.py | 7 +++++-- .../python-legacy/petstore_api/models/dog_all_of.py | 7 +++++-- .../python-legacy/petstore_api/models/enum_arrays.py | 7 +++++-- .../python-legacy/petstore_api/models/enum_class.py | 7 +++++-- .../python-legacy/petstore_api/models/enum_test.py | 7 +++++-- .../petstore/python-legacy/petstore_api/models/file.py | 7 +++++-- .../petstore_api/models/file_schema_test_class.py | 7 +++++-- .../petstore/python-legacy/petstore_api/models/foo.py | 7 +++++-- .../python-legacy/petstore_api/models/format_test.py | 7 +++++-- .../petstore_api/models/has_only_read_only.py | 7 +++++-- .../petstore_api/models/health_check_result.py | 7 +++++-- .../petstore_api/models/inline_response_default.py | 7 +++++-- .../petstore/python-legacy/petstore_api/models/list.py | 7 +++++-- .../petstore/python-legacy/petstore_api/models/map_test.py | 7 +++++-- .../mixed_properties_and_additional_properties_class.py | 7 +++++-- .../python-legacy/petstore_api/models/model200_response.py | 7 +++++-- .../python-legacy/petstore_api/models/model_return.py | 7 +++++-- .../petstore/python-legacy/petstore_api/models/name.py | 7 +++++-- .../python-legacy/petstore_api/models/nullable_class.py | 7 +++++-- .../python-legacy/petstore_api/models/number_only.py | 7 +++++-- .../petstore/python-legacy/petstore_api/models/order.py | 7 +++++-- .../python-legacy/petstore_api/models/outer_composite.py | 7 +++++-- .../python-legacy/petstore_api/models/outer_enum.py | 7 +++++-- .../petstore_api/models/outer_enum_default_value.py | 7 +++++-- .../petstore_api/models/outer_enum_integer.py | 7 +++++-- .../models/outer_enum_integer_default_value.py | 7 +++++-- .../petstore_api/models/outer_object_with_enum_property.py | 7 +++++-- .../petstore/python-legacy/petstore_api/models/pet.py | 7 +++++-- .../python-legacy/petstore_api/models/read_only_first.py | 7 +++++-- .../petstore_api/models/special_model_name.py | 7 +++++-- .../petstore/python-legacy/petstore_api/models/tag.py | 7 +++++-- .../petstore/python-legacy/petstore_api/models/user.py | 7 +++++-- 189 files changed, 945 insertions(+), 378 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/python-legacy/model.mustache b/modules/openapi-generator/src/main/resources/python-legacy/model.mustache index 5b4048915eb8..236b8f8c3a2e 100644 --- a/modules/openapi-generator/src/main/resources/python-legacy/model.mustache +++ b/modules/openapi-generator/src/main/resources/python-legacy/model.mustache @@ -2,7 +2,10 @@ {{>partial_header}} -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -203,7 +206,7 @@ class {{classname}}(object): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/additional_properties_any_type.py b/samples/client/petstore/python-asyncio/petstore_api/models/additional_properties_any_type.py index 30e6e9b81766..01457faa3a33 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/additional_properties_any_type.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/additional_properties_any_type.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/additional_properties_array.py b/samples/client/petstore/python-asyncio/petstore_api/models/additional_properties_array.py index 2f939711e0af..c7283e161360 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/additional_properties_array.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/additional_properties_array.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/additional_properties_boolean.py b/samples/client/petstore/python-asyncio/petstore_api/models/additional_properties_boolean.py index 32b58c24ffa8..3a8ec8f66aac 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/additional_properties_boolean.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/additional_properties_boolean.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/additional_properties_class.py b/samples/client/petstore/python-asyncio/petstore_api/models/additional_properties_class.py index dff689699744..52c475c4460c 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/additional_properties_class.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/additional_properties_class.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -339,7 +342,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/additional_properties_integer.py b/samples/client/petstore/python-asyncio/petstore_api/models/additional_properties_integer.py index bba82b9c8cf9..d9ee889d7a33 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/additional_properties_integer.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/additional_properties_integer.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/additional_properties_number.py b/samples/client/petstore/python-asyncio/petstore_api/models/additional_properties_number.py index 9adeedb7e792..756fc037970f 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/additional_properties_number.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/additional_properties_number.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/additional_properties_object.py b/samples/client/petstore/python-asyncio/petstore_api/models/additional_properties_object.py index 85f94ac205df..bfbe2db1bef9 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/additional_properties_object.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/additional_properties_object.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/additional_properties_string.py b/samples/client/petstore/python-asyncio/petstore_api/models/additional_properties_string.py index ee8d6383348c..7c33a16fe8fc 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/additional_properties_string.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/additional_properties_string.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/animal.py b/samples/client/petstore/python-asyncio/petstore_api/models/animal.py index a791a5173ba1..eee29f37f881 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/animal.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/animal.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -118,7 +121,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/api_response.py b/samples/client/petstore/python-asyncio/petstore_api/models/api_response.py index ab5e7999dd2f..bddac1eb10a3 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/api_response.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/api_response.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -131,7 +134,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/array_of_array_of_number_only.py b/samples/client/petstore/python-asyncio/petstore_api/models/array_of_array_of_number_only.py index c9b65c7e5315..2975adc20e31 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/array_of_array_of_number_only.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/array_of_array_of_number_only.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/array_of_number_only.py b/samples/client/petstore/python-asyncio/petstore_api/models/array_of_number_only.py index 870286e0fc08..2a3400e76660 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/array_of_number_only.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/array_of_number_only.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/array_test.py b/samples/client/petstore/python-asyncio/petstore_api/models/array_test.py index 04d2cb6ec602..11394dcb7bc1 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/array_test.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/array_test.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -131,7 +134,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/big_cat.py b/samples/client/petstore/python-asyncio/petstore_api/models/big_cat.py index 7136aa867207..9a108ce3717e 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/big_cat.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/big_cat.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -85,7 +88,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/big_cat_all_of.py b/samples/client/petstore/python-asyncio/petstore_api/models/big_cat_all_of.py index 127e7c6da31a..6d6c9aeb5c0c 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/big_cat_all_of.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/big_cat_all_of.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -85,7 +88,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/capitalization.py b/samples/client/petstore/python-asyncio/petstore_api/models/capitalization.py index 064dc2eb2ff5..cb8b0d985842 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/capitalization.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/capitalization.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -211,7 +214,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/cat.py b/samples/client/petstore/python-asyncio/petstore_api/models/cat.py index 3b6e6aa4c2e8..0d9a0b20bf1a 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/cat.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/cat.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/cat_all_of.py b/samples/client/petstore/python-asyncio/petstore_api/models/cat_all_of.py index 7755fd65b0c3..0633bbf58d0d 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/cat_all_of.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/cat_all_of.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/category.py b/samples/client/petstore/python-asyncio/petstore_api/models/category.py index c3dd5a4b9a17..ef52dcbf8c91 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/category.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/category.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -106,7 +109,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/class_model.py b/samples/client/petstore/python-asyncio/petstore_api/models/class_model.py index cd9439763d20..84c0de65b472 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/class_model.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/class_model.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/client.py b/samples/client/petstore/python-asyncio/petstore_api/models/client.py index f896b35240c7..8d7c83ecfe6b 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/client.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/client.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/dog.py b/samples/client/petstore/python-asyncio/petstore_api/models/dog.py index 39514284d5f2..61acd35cdfe2 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/dog.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/dog.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/dog_all_of.py b/samples/client/petstore/python-asyncio/petstore_api/models/dog_all_of.py index 207103a48745..3a052c3258ae 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/dog_all_of.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/dog_all_of.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/enum_arrays.py b/samples/client/petstore/python-asyncio/petstore_api/models/enum_arrays.py index b87cd37456e1..eb4f3ea4ca32 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/enum_arrays.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/enum_arrays.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -119,7 +122,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/enum_class.py b/samples/client/petstore/python-asyncio/petstore_api/models/enum_class.py index 4b11877863ac..79aac3570cb9 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/enum_class.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/enum_class.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -60,7 +63,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/enum_test.py b/samples/client/petstore/python-asyncio/petstore_api/models/enum_test.py index d1778410dee2..1f3d7cb29b89 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/enum_test.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/enum_test.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -208,7 +211,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/file.py b/samples/client/petstore/python-asyncio/petstore_api/models/file.py index e40cd04b0149..2c1cccac0e11 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/file.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/file.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -81,7 +84,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/file_schema_test_class.py b/samples/client/petstore/python-asyncio/petstore_api/models/file_schema_test_class.py index d266755d260a..c5a23842d4f6 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/file_schema_test_class.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/file_schema_test_class.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -105,7 +108,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/format_test.py b/samples/client/petstore/python-asyncio/petstore_api/models/format_test.py index c193f9313e96..452582251a59 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/format_test.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/format_test.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -463,7 +466,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/has_only_read_only.py b/samples/client/petstore/python-asyncio/petstore_api/models/has_only_read_only.py index dac8cfaff937..7175c2acc721 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/has_only_read_only.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/has_only_read_only.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -105,7 +108,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/list.py b/samples/client/petstore/python-asyncio/petstore_api/models/list.py index b44257224741..6e1dea4e33b5 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/list.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/list.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/map_test.py b/samples/client/petstore/python-asyncio/petstore_api/models/map_test.py index 406f35db7500..21bd2ccda980 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/map_test.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/map_test.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -165,7 +168,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/mixed_properties_and_additional_properties_class.py b/samples/client/petstore/python-asyncio/petstore_api/models/mixed_properties_and_additional_properties_class.py index 14428a6536a8..9e727b07d5c7 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/mixed_properties_and_additional_properties_class.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/mixed_properties_and_additional_properties_class.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -131,7 +134,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/model200_response.py b/samples/client/petstore/python-asyncio/petstore_api/models/model200_response.py index 5c90147467b5..db587fd24e2f 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/model200_response.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/model200_response.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -105,7 +108,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/model_return.py b/samples/client/petstore/python-asyncio/petstore_api/models/model_return.py index 88174ef23083..5354fd56e2ce 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/model_return.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/model_return.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/name.py b/samples/client/petstore/python-asyncio/petstore_api/models/name.py index 528988ebd437..0191a3a934ae 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/name.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/name.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -158,7 +161,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/number_only.py b/samples/client/petstore/python-asyncio/petstore_api/models/number_only.py index ebbcc8996d01..59a252e0bb66 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/number_only.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/number_only.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/order.py b/samples/client/petstore/python-asyncio/petstore_api/models/order.py index 6513d48a3a5e..a267324d0d19 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/order.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/order.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -217,7 +220,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/outer_composite.py b/samples/client/petstore/python-asyncio/petstore_api/models/outer_composite.py index 44124e13c09b..e26160ab4302 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/outer_composite.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/outer_composite.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -131,7 +134,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/outer_enum.py b/samples/client/petstore/python-asyncio/petstore_api/models/outer_enum.py index 77624ba15408..27cdfd1fb791 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/outer_enum.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/outer_enum.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -60,7 +63,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/pet.py b/samples/client/petstore/python-asyncio/petstore_api/models/pet.py index e71589429ca0..22bb4a585e47 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/pet.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/pet.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -219,7 +222,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/read_only_first.py b/samples/client/petstore/python-asyncio/petstore_api/models/read_only_first.py index 3a320fe64f06..c2888eba7500 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/read_only_first.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/read_only_first.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -105,7 +108,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/special_model_name.py b/samples/client/petstore/python-asyncio/petstore_api/models/special_model_name.py index 7669a508789f..4c848e1887c0 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/special_model_name.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/special_model_name.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/tag.py b/samples/client/petstore/python-asyncio/petstore_api/models/tag.py index dbac885ad8e9..a3e6789078d8 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/tag.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/tag.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -105,7 +108,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/type_holder_default.py b/samples/client/petstore/python-asyncio/petstore_api/models/type_holder_default.py index c890f5531927..582b4c8d6dc2 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/type_holder_default.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/type_holder_default.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -188,7 +191,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/type_holder_example.py b/samples/client/petstore/python-asyncio/petstore_api/models/type_holder_example.py index d52425d442ea..268595ed8681 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/type_holder_example.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/type_holder_example.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -215,7 +218,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/user.py b/samples/client/petstore/python-asyncio/petstore_api/models/user.py index b70d84a6b40e..7ae2898f6c5a 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/user.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/user.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -263,7 +266,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-asyncio/petstore_api/models/xml_item.py b/samples/client/petstore/python-asyncio/petstore_api/models/xml_item.py index d63ab77acfde..5e6fecdd71c8 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/models/xml_item.py +++ b/samples/client/petstore/python-asyncio/petstore_api/models/xml_item.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -807,7 +810,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/additional_properties_any_type.py b/samples/client/petstore/python-legacy/petstore_api/models/additional_properties_any_type.py index 30e6e9b81766..01457faa3a33 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/additional_properties_any_type.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/additional_properties_any_type.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/additional_properties_array.py b/samples/client/petstore/python-legacy/petstore_api/models/additional_properties_array.py index 2f939711e0af..c7283e161360 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/additional_properties_array.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/additional_properties_array.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/additional_properties_boolean.py b/samples/client/petstore/python-legacy/petstore_api/models/additional_properties_boolean.py index 32b58c24ffa8..3a8ec8f66aac 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/additional_properties_boolean.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/additional_properties_boolean.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/additional_properties_class.py b/samples/client/petstore/python-legacy/petstore_api/models/additional_properties_class.py index dff689699744..52c475c4460c 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/additional_properties_class.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/additional_properties_class.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -339,7 +342,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/additional_properties_integer.py b/samples/client/petstore/python-legacy/petstore_api/models/additional_properties_integer.py index bba82b9c8cf9..d9ee889d7a33 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/additional_properties_integer.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/additional_properties_integer.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/additional_properties_number.py b/samples/client/petstore/python-legacy/petstore_api/models/additional_properties_number.py index 9adeedb7e792..756fc037970f 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/additional_properties_number.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/additional_properties_number.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/additional_properties_object.py b/samples/client/petstore/python-legacy/petstore_api/models/additional_properties_object.py index 85f94ac205df..bfbe2db1bef9 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/additional_properties_object.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/additional_properties_object.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/additional_properties_string.py b/samples/client/petstore/python-legacy/petstore_api/models/additional_properties_string.py index ee8d6383348c..7c33a16fe8fc 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/additional_properties_string.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/additional_properties_string.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/animal.py b/samples/client/petstore/python-legacy/petstore_api/models/animal.py index a791a5173ba1..eee29f37f881 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/animal.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/animal.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -118,7 +121,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/api_response.py b/samples/client/petstore/python-legacy/petstore_api/models/api_response.py index ab5e7999dd2f..bddac1eb10a3 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/api_response.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/api_response.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -131,7 +134,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/array_of_array_of_number_only.py b/samples/client/petstore/python-legacy/petstore_api/models/array_of_array_of_number_only.py index c9b65c7e5315..2975adc20e31 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/array_of_array_of_number_only.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/array_of_array_of_number_only.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/array_of_number_only.py b/samples/client/petstore/python-legacy/petstore_api/models/array_of_number_only.py index 870286e0fc08..2a3400e76660 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/array_of_number_only.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/array_of_number_only.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/array_test.py b/samples/client/petstore/python-legacy/petstore_api/models/array_test.py index 04d2cb6ec602..11394dcb7bc1 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/array_test.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/array_test.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -131,7 +134,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/big_cat.py b/samples/client/petstore/python-legacy/petstore_api/models/big_cat.py index 7136aa867207..9a108ce3717e 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/big_cat.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/big_cat.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -85,7 +88,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/big_cat_all_of.py b/samples/client/petstore/python-legacy/petstore_api/models/big_cat_all_of.py index 127e7c6da31a..6d6c9aeb5c0c 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/big_cat_all_of.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/big_cat_all_of.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -85,7 +88,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/capitalization.py b/samples/client/petstore/python-legacy/petstore_api/models/capitalization.py index 064dc2eb2ff5..cb8b0d985842 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/capitalization.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/capitalization.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -211,7 +214,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/cat.py b/samples/client/petstore/python-legacy/petstore_api/models/cat.py index 3b6e6aa4c2e8..0d9a0b20bf1a 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/cat.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/cat.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/cat_all_of.py b/samples/client/petstore/python-legacy/petstore_api/models/cat_all_of.py index 7755fd65b0c3..0633bbf58d0d 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/cat_all_of.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/cat_all_of.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/category.py b/samples/client/petstore/python-legacy/petstore_api/models/category.py index c3dd5a4b9a17..ef52dcbf8c91 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/category.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/category.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -106,7 +109,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/class_model.py b/samples/client/petstore/python-legacy/petstore_api/models/class_model.py index cd9439763d20..84c0de65b472 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/class_model.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/class_model.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/client.py b/samples/client/petstore/python-legacy/petstore_api/models/client.py index f896b35240c7..8d7c83ecfe6b 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/client.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/client.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/dog.py b/samples/client/petstore/python-legacy/petstore_api/models/dog.py index 39514284d5f2..61acd35cdfe2 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/dog.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/dog.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/dog_all_of.py b/samples/client/petstore/python-legacy/petstore_api/models/dog_all_of.py index 207103a48745..3a052c3258ae 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/dog_all_of.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/dog_all_of.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/enum_arrays.py b/samples/client/petstore/python-legacy/petstore_api/models/enum_arrays.py index b87cd37456e1..eb4f3ea4ca32 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/enum_arrays.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/enum_arrays.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -119,7 +122,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/enum_class.py b/samples/client/petstore/python-legacy/petstore_api/models/enum_class.py index 4b11877863ac..79aac3570cb9 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/enum_class.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/enum_class.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -60,7 +63,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/enum_test.py b/samples/client/petstore/python-legacy/petstore_api/models/enum_test.py index d1778410dee2..1f3d7cb29b89 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/enum_test.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/enum_test.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -208,7 +211,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/file.py b/samples/client/petstore/python-legacy/petstore_api/models/file.py index e40cd04b0149..2c1cccac0e11 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/file.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/file.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -81,7 +84,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/file_schema_test_class.py b/samples/client/petstore/python-legacy/petstore_api/models/file_schema_test_class.py index d266755d260a..c5a23842d4f6 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/file_schema_test_class.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/file_schema_test_class.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -105,7 +108,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/format_test.py b/samples/client/petstore/python-legacy/petstore_api/models/format_test.py index c193f9313e96..452582251a59 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/format_test.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/format_test.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -463,7 +466,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/has_only_read_only.py b/samples/client/petstore/python-legacy/petstore_api/models/has_only_read_only.py index dac8cfaff937..7175c2acc721 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/has_only_read_only.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/has_only_read_only.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -105,7 +108,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/list.py b/samples/client/petstore/python-legacy/petstore_api/models/list.py index b44257224741..6e1dea4e33b5 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/list.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/list.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/map_test.py b/samples/client/petstore/python-legacy/petstore_api/models/map_test.py index 406f35db7500..21bd2ccda980 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/map_test.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/map_test.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -165,7 +168,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/mixed_properties_and_additional_properties_class.py b/samples/client/petstore/python-legacy/petstore_api/models/mixed_properties_and_additional_properties_class.py index 14428a6536a8..9e727b07d5c7 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/mixed_properties_and_additional_properties_class.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/mixed_properties_and_additional_properties_class.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -131,7 +134,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/model200_response.py b/samples/client/petstore/python-legacy/petstore_api/models/model200_response.py index 5c90147467b5..db587fd24e2f 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/model200_response.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/model200_response.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -105,7 +108,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/model_return.py b/samples/client/petstore/python-legacy/petstore_api/models/model_return.py index 88174ef23083..5354fd56e2ce 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/model_return.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/model_return.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/name.py b/samples/client/petstore/python-legacy/petstore_api/models/name.py index 528988ebd437..0191a3a934ae 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/name.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/name.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -158,7 +161,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/number_only.py b/samples/client/petstore/python-legacy/petstore_api/models/number_only.py index ebbcc8996d01..59a252e0bb66 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/number_only.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/number_only.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/order.py b/samples/client/petstore/python-legacy/petstore_api/models/order.py index 6513d48a3a5e..a267324d0d19 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/order.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/order.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -217,7 +220,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/outer_composite.py b/samples/client/petstore/python-legacy/petstore_api/models/outer_composite.py index 44124e13c09b..e26160ab4302 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/outer_composite.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/outer_composite.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -131,7 +134,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/outer_enum.py b/samples/client/petstore/python-legacy/petstore_api/models/outer_enum.py index 77624ba15408..27cdfd1fb791 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/outer_enum.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/outer_enum.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -60,7 +63,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/pet.py b/samples/client/petstore/python-legacy/petstore_api/models/pet.py index e71589429ca0..22bb4a585e47 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/pet.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/pet.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -219,7 +222,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/read_only_first.py b/samples/client/petstore/python-legacy/petstore_api/models/read_only_first.py index 3a320fe64f06..c2888eba7500 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/read_only_first.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/read_only_first.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -105,7 +108,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/special_model_name.py b/samples/client/petstore/python-legacy/petstore_api/models/special_model_name.py index 7669a508789f..4c848e1887c0 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/special_model_name.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/special_model_name.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/tag.py b/samples/client/petstore/python-legacy/petstore_api/models/tag.py index dbac885ad8e9..a3e6789078d8 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/tag.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/tag.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -105,7 +108,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/type_holder_default.py b/samples/client/petstore/python-legacy/petstore_api/models/type_holder_default.py index c890f5531927..582b4c8d6dc2 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/type_holder_default.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/type_holder_default.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -188,7 +191,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/type_holder_example.py b/samples/client/petstore/python-legacy/petstore_api/models/type_holder_example.py index d52425d442ea..268595ed8681 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/type_holder_example.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/type_holder_example.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -215,7 +218,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/user.py b/samples/client/petstore/python-legacy/petstore_api/models/user.py index b70d84a6b40e..7ae2898f6c5a 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/user.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/user.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -263,7 +266,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-legacy/petstore_api/models/xml_item.py b/samples/client/petstore/python-legacy/petstore_api/models/xml_item.py index d63ab77acfde..5e6fecdd71c8 100644 --- a/samples/client/petstore/python-legacy/petstore_api/models/xml_item.py +++ b/samples/client/petstore/python-legacy/petstore_api/models/xml_item.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -807,7 +810,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/additional_properties_any_type.py b/samples/client/petstore/python-tornado/petstore_api/models/additional_properties_any_type.py index 30e6e9b81766..01457faa3a33 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/additional_properties_any_type.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/additional_properties_any_type.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/additional_properties_array.py b/samples/client/petstore/python-tornado/petstore_api/models/additional_properties_array.py index 2f939711e0af..c7283e161360 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/additional_properties_array.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/additional_properties_array.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/additional_properties_boolean.py b/samples/client/petstore/python-tornado/petstore_api/models/additional_properties_boolean.py index 32b58c24ffa8..3a8ec8f66aac 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/additional_properties_boolean.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/additional_properties_boolean.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/additional_properties_class.py b/samples/client/petstore/python-tornado/petstore_api/models/additional_properties_class.py index dff689699744..52c475c4460c 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/additional_properties_class.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/additional_properties_class.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -339,7 +342,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/additional_properties_integer.py b/samples/client/petstore/python-tornado/petstore_api/models/additional_properties_integer.py index bba82b9c8cf9..d9ee889d7a33 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/additional_properties_integer.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/additional_properties_integer.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/additional_properties_number.py b/samples/client/petstore/python-tornado/petstore_api/models/additional_properties_number.py index 9adeedb7e792..756fc037970f 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/additional_properties_number.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/additional_properties_number.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/additional_properties_object.py b/samples/client/petstore/python-tornado/petstore_api/models/additional_properties_object.py index 85f94ac205df..bfbe2db1bef9 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/additional_properties_object.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/additional_properties_object.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/additional_properties_string.py b/samples/client/petstore/python-tornado/petstore_api/models/additional_properties_string.py index ee8d6383348c..7c33a16fe8fc 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/additional_properties_string.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/additional_properties_string.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/animal.py b/samples/client/petstore/python-tornado/petstore_api/models/animal.py index a791a5173ba1..eee29f37f881 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/animal.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/animal.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -118,7 +121,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/api_response.py b/samples/client/petstore/python-tornado/petstore_api/models/api_response.py index ab5e7999dd2f..bddac1eb10a3 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/api_response.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/api_response.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -131,7 +134,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/array_of_array_of_number_only.py b/samples/client/petstore/python-tornado/petstore_api/models/array_of_array_of_number_only.py index c9b65c7e5315..2975adc20e31 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/array_of_array_of_number_only.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/array_of_array_of_number_only.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/array_of_number_only.py b/samples/client/petstore/python-tornado/petstore_api/models/array_of_number_only.py index 870286e0fc08..2a3400e76660 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/array_of_number_only.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/array_of_number_only.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/array_test.py b/samples/client/petstore/python-tornado/petstore_api/models/array_test.py index 04d2cb6ec602..11394dcb7bc1 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/array_test.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/array_test.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -131,7 +134,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/big_cat.py b/samples/client/petstore/python-tornado/petstore_api/models/big_cat.py index 7136aa867207..9a108ce3717e 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/big_cat.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/big_cat.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -85,7 +88,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/big_cat_all_of.py b/samples/client/petstore/python-tornado/petstore_api/models/big_cat_all_of.py index 127e7c6da31a..6d6c9aeb5c0c 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/big_cat_all_of.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/big_cat_all_of.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -85,7 +88,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/capitalization.py b/samples/client/petstore/python-tornado/petstore_api/models/capitalization.py index 064dc2eb2ff5..cb8b0d985842 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/capitalization.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/capitalization.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -211,7 +214,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/cat.py b/samples/client/petstore/python-tornado/petstore_api/models/cat.py index 3b6e6aa4c2e8..0d9a0b20bf1a 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/cat.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/cat.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/cat_all_of.py b/samples/client/petstore/python-tornado/petstore_api/models/cat_all_of.py index 7755fd65b0c3..0633bbf58d0d 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/cat_all_of.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/cat_all_of.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/category.py b/samples/client/petstore/python-tornado/petstore_api/models/category.py index c3dd5a4b9a17..ef52dcbf8c91 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/category.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/category.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -106,7 +109,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/class_model.py b/samples/client/petstore/python-tornado/petstore_api/models/class_model.py index cd9439763d20..84c0de65b472 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/class_model.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/class_model.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/client.py b/samples/client/petstore/python-tornado/petstore_api/models/client.py index f896b35240c7..8d7c83ecfe6b 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/client.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/client.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/dog.py b/samples/client/petstore/python-tornado/petstore_api/models/dog.py index 39514284d5f2..61acd35cdfe2 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/dog.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/dog.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/dog_all_of.py b/samples/client/petstore/python-tornado/petstore_api/models/dog_all_of.py index 207103a48745..3a052c3258ae 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/dog_all_of.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/dog_all_of.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/enum_arrays.py b/samples/client/petstore/python-tornado/petstore_api/models/enum_arrays.py index b87cd37456e1..eb4f3ea4ca32 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/enum_arrays.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/enum_arrays.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -119,7 +122,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/enum_class.py b/samples/client/petstore/python-tornado/petstore_api/models/enum_class.py index 4b11877863ac..79aac3570cb9 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/enum_class.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/enum_class.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -60,7 +63,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/enum_test.py b/samples/client/petstore/python-tornado/petstore_api/models/enum_test.py index d1778410dee2..1f3d7cb29b89 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/enum_test.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/enum_test.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -208,7 +211,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/file.py b/samples/client/petstore/python-tornado/petstore_api/models/file.py index e40cd04b0149..2c1cccac0e11 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/file.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/file.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -81,7 +84,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/file_schema_test_class.py b/samples/client/petstore/python-tornado/petstore_api/models/file_schema_test_class.py index d266755d260a..c5a23842d4f6 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/file_schema_test_class.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/file_schema_test_class.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -105,7 +108,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/format_test.py b/samples/client/petstore/python-tornado/petstore_api/models/format_test.py index c193f9313e96..452582251a59 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/format_test.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/format_test.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -463,7 +466,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/has_only_read_only.py b/samples/client/petstore/python-tornado/petstore_api/models/has_only_read_only.py index dac8cfaff937..7175c2acc721 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/has_only_read_only.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/has_only_read_only.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -105,7 +108,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/list.py b/samples/client/petstore/python-tornado/petstore_api/models/list.py index b44257224741..6e1dea4e33b5 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/list.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/list.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/map_test.py b/samples/client/petstore/python-tornado/petstore_api/models/map_test.py index 406f35db7500..21bd2ccda980 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/map_test.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/map_test.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -165,7 +168,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/mixed_properties_and_additional_properties_class.py b/samples/client/petstore/python-tornado/petstore_api/models/mixed_properties_and_additional_properties_class.py index 14428a6536a8..9e727b07d5c7 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/mixed_properties_and_additional_properties_class.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/mixed_properties_and_additional_properties_class.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -131,7 +134,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/model200_response.py b/samples/client/petstore/python-tornado/petstore_api/models/model200_response.py index 5c90147467b5..db587fd24e2f 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/model200_response.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/model200_response.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -105,7 +108,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/model_return.py b/samples/client/petstore/python-tornado/petstore_api/models/model_return.py index 88174ef23083..5354fd56e2ce 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/model_return.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/model_return.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/name.py b/samples/client/petstore/python-tornado/petstore_api/models/name.py index 528988ebd437..0191a3a934ae 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/name.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/name.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -158,7 +161,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/number_only.py b/samples/client/petstore/python-tornado/petstore_api/models/number_only.py index ebbcc8996d01..59a252e0bb66 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/number_only.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/number_only.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/order.py b/samples/client/petstore/python-tornado/petstore_api/models/order.py index 6513d48a3a5e..a267324d0d19 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/order.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/order.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -217,7 +220,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/outer_composite.py b/samples/client/petstore/python-tornado/petstore_api/models/outer_composite.py index 44124e13c09b..e26160ab4302 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/outer_composite.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/outer_composite.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -131,7 +134,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/outer_enum.py b/samples/client/petstore/python-tornado/petstore_api/models/outer_enum.py index 77624ba15408..27cdfd1fb791 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/outer_enum.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/outer_enum.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -60,7 +63,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/pet.py b/samples/client/petstore/python-tornado/petstore_api/models/pet.py index e71589429ca0..22bb4a585e47 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/pet.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/pet.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -219,7 +222,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/read_only_first.py b/samples/client/petstore/python-tornado/petstore_api/models/read_only_first.py index 3a320fe64f06..c2888eba7500 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/read_only_first.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/read_only_first.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -105,7 +108,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/special_model_name.py b/samples/client/petstore/python-tornado/petstore_api/models/special_model_name.py index 7669a508789f..4c848e1887c0 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/special_model_name.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/special_model_name.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/tag.py b/samples/client/petstore/python-tornado/petstore_api/models/tag.py index dbac885ad8e9..a3e6789078d8 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/tag.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/tag.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -105,7 +108,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/type_holder_default.py b/samples/client/petstore/python-tornado/petstore_api/models/type_holder_default.py index c890f5531927..582b4c8d6dc2 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/type_holder_default.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/type_holder_default.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -188,7 +191,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/type_holder_example.py b/samples/client/petstore/python-tornado/petstore_api/models/type_holder_example.py index d52425d442ea..268595ed8681 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/type_holder_example.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/type_holder_example.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -215,7 +218,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/user.py b/samples/client/petstore/python-tornado/petstore_api/models/user.py index b70d84a6b40e..7ae2898f6c5a 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/user.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/user.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -263,7 +266,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/client/petstore/python-tornado/petstore_api/models/xml_item.py b/samples/client/petstore/python-tornado/petstore_api/models/xml_item.py index d63ab77acfde..5e6fecdd71c8 100644 --- a/samples/client/petstore/python-tornado/petstore_api/models/xml_item.py +++ b/samples/client/petstore/python-tornado/petstore_api/models/xml_item.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -807,7 +810,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/additional_properties_class.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/additional_properties_class.py index a846775889f8..f8303e680b26 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/additional_properties_class.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -105,7 +108,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/animal.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/animal.py index 2427f910a97e..1a36f3398fff 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/animal.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/animal.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -117,7 +120,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/api_response.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/api_response.py index ab5e7999dd2f..bddac1eb10a3 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/api_response.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/api_response.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -131,7 +134,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/array_of_array_of_number_only.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/array_of_array_of_number_only.py index c9b65c7e5315..2975adc20e31 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/array_of_array_of_number_only.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/array_of_array_of_number_only.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/array_of_number_only.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/array_of_number_only.py index 870286e0fc08..2a3400e76660 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/array_of_number_only.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/array_of_number_only.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/array_test.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/array_test.py index 0e0c17ef1909..5501a637f633 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/array_test.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/array_test.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -137,7 +140,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/capitalization.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/capitalization.py index 064dc2eb2ff5..cb8b0d985842 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/capitalization.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/capitalization.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -211,7 +214,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/cat.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/cat.py index 3b6e6aa4c2e8..0d9a0b20bf1a 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/cat.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/cat.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/cat_all_of.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/cat_all_of.py index 7755fd65b0c3..0633bbf58d0d 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/cat_all_of.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/cat_all_of.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/category.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/category.py index c3dd5a4b9a17..ef52dcbf8c91 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/category.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/category.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -106,7 +109,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/class_model.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/class_model.py index cd9439763d20..84c0de65b472 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/class_model.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/class_model.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/client.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/client.py index f896b35240c7..8d7c83ecfe6b 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/client.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/client.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/dog.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/dog.py index 39514284d5f2..61acd35cdfe2 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/dog.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/dog.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/dog_all_of.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/dog_all_of.py index 207103a48745..3a052c3258ae 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/dog_all_of.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/dog_all_of.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/enum_arrays.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/enum_arrays.py index b87cd37456e1..eb4f3ea4ca32 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/enum_arrays.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/enum_arrays.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -119,7 +122,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/enum_class.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/enum_class.py index 4b11877863ac..79aac3570cb9 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/enum_class.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/enum_class.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -60,7 +63,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/enum_test.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/enum_test.py index 09d7d1e3d809..93333df88781 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/enum_test.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/enum_test.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -285,7 +288,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/file.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/file.py index e40cd04b0149..2c1cccac0e11 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/file.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/file.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -81,7 +84,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/file_schema_test_class.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/file_schema_test_class.py index d266755d260a..c5a23842d4f6 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/file_schema_test_class.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/file_schema_test_class.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -105,7 +108,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/foo.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/foo.py index 05abc6e9b9fe..cab632f369c4 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/foo.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/foo.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/format_test.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/format_test.py index a8323ade641e..4e96a7b9175e 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/format_test.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/format_test.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -522,7 +525,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/has_only_read_only.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/has_only_read_only.py index dac8cfaff937..7175c2acc721 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/has_only_read_only.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/has_only_read_only.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -105,7 +108,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/health_check_result.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/health_check_result.py index cde33f5146a4..64a3f4b2b903 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/health_check_result.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/health_check_result.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -78,7 +81,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/inline_response_default.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/inline_response_default.py index d9da22a5fd3e..a199122621ff 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/inline_response_default.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/inline_response_default.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/list.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/list.py index b44257224741..6e1dea4e33b5 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/list.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/list.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/map_test.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/map_test.py index 406f35db7500..21bd2ccda980 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/map_test.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/map_test.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -165,7 +168,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/mixed_properties_and_additional_properties_class.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/mixed_properties_and_additional_properties_class.py index 14428a6536a8..9e727b07d5c7 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/mixed_properties_and_additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/mixed_properties_and_additional_properties_class.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -131,7 +134,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/model200_response.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/model200_response.py index 5c90147467b5..db587fd24e2f 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/model200_response.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/model200_response.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -105,7 +108,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/model_return.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/model_return.py index 88174ef23083..5354fd56e2ce 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/model_return.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/model_return.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/name.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/name.py index 528988ebd437..0191a3a934ae 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/name.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/name.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -158,7 +161,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/nullable_class.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/nullable_class.py index 490eb2ba7d01..d36862f8526d 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/nullable_class.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/nullable_class.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -355,7 +358,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/number_only.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/number_only.py index ebbcc8996d01..59a252e0bb66 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/number_only.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/number_only.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/order.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/order.py index 6513d48a3a5e..a267324d0d19 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/order.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/order.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -217,7 +220,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/outer_composite.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/outer_composite.py index 44124e13c09b..e26160ab4302 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/outer_composite.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/outer_composite.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -131,7 +134,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/outer_enum.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/outer_enum.py index 77624ba15408..27cdfd1fb791 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/outer_enum.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/outer_enum.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -60,7 +63,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/outer_enum_default_value.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/outer_enum_default_value.py index aae43db66e67..982e9599d0e5 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/outer_enum_default_value.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/outer_enum_default_value.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -60,7 +63,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/outer_enum_integer.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/outer_enum_integer.py index d3d9ca3dbf9f..3feec9c5a5a2 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/outer_enum_integer.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/outer_enum_integer.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -60,7 +63,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/outer_enum_integer_default_value.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/outer_enum_integer_default_value.py index 9e0ed2c1a8b1..6757a4d63674 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/outer_enum_integer_default_value.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/outer_enum_integer_default_value.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -60,7 +63,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/outer_object_with_enum_property.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/outer_object_with_enum_property.py index 8a50b129a7fb..b9572300b6f6 100644 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/outer_object_with_enum_property.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/outer_object_with_enum_property.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -80,7 +83,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/pet.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/pet.py index e71589429ca0..22bb4a585e47 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/pet.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/pet.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -219,7 +222,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/read_only_first.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/read_only_first.py index 3a320fe64f06..c2888eba7500 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/read_only_first.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/read_only_first.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -105,7 +108,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/special_model_name.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/special_model_name.py index 7669a508789f..4c848e1887c0 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/special_model_name.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/special_model_name.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -79,7 +82,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/tag.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/tag.py index dbac885ad8e9..a3e6789078d8 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/tag.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/tag.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -105,7 +108,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: diff --git a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/user.py b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/user.py index b70d84a6b40e..7ae2898f6c5a 100755 --- a/samples/openapi3/client/petstore/python-legacy/petstore_api/models/user.py +++ b/samples/openapi3/client/petstore/python-legacy/petstore_api/models/user.py @@ -10,7 +10,10 @@ """ -import inspect +try: + from inspect import getfullargspec +except ImportError: + from inspect import getargspec as getfullargspec import pprint import re # noqa: F401 import six @@ -263,7 +266,7 @@ def to_dict(self, serialize=False): def convert(x): if hasattr(x, "to_dict"): - args = inspect.getargspec(x.to_dict).args + args = getfullargspec(x.to_dict).args if len(args) == 1: return x.to_dict() else: From 3da1999135e8fdde892d67ade26e89559d30cab4 Mon Sep 17 00:00:00 2001 From: Matthew Date: Mon, 3 May 2021 10:45:55 -0400 Subject: [PATCH 06/18] Fix typo in readme (#9387) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c27f86b1531d..2e3ff4b34d77 100644 --- a/README.md +++ b/README.md @@ -562,7 +562,7 @@ When code is generated from this project, it shall be considered **AS IS** and o ### [3.5 - IDE Integration](#table-of-contents) -Here is a list of community-conitributed IDE plug-ins that integrate with OpenAPI Generator: +Here is a list of community-contributed IDE plug-ins that integrate with OpenAPI Generator: - Eclipse: [Codewind OpenAPI Tools for Eclipse](https://www.eclipse.org/codewind/open-api-tools-for-eclipse.html) by [IBM](https://www.ibm.com) - IntelliJ IDEA: [OpenAPI Generator](https://plugins.jetbrains.com/plugin/8433-openapi-generator) by [Jim Schubert](https://jimschubert.us/#/) From d21743e9e59114814d703e8ff4b42598ba885138 Mon Sep 17 00:00:00 2001 From: Stefan Wendt Date: Mon, 3 May 2021 18:15:52 +0200 Subject: [PATCH 07/18] [TypeScript-fetch] Fix issue 9360 (#9362) * [TypeScript] Fix misplaced parentheses * [TypeScript] Run PR relevant scripts * [TypeScript] ensure up to date * Revert "[TypeScript] ensure up to date" This reverts commit 320ec45f * Revert "[TypeScript] Run PR relevant scripts" This reverts commit 23cda753 Co-authored-by: Stefan Wendt --- .../src/main/resources/typescript-fetch/modelGeneric.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache index 00d4e010fa0d..3036e3662907 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache @@ -109,7 +109,7 @@ export function {{classname}}ToJSON(value?: {{classname}} | null): any { {{^isPrimitiveType}} {{#isArray}} {{#uniqueItems}} - '{{baseName}}': {{^required}}value.{{name}} === undefined ? undefined : {{/required}}({{#isNullable}}value.{{name}} === null ? null : {{/isNullable}}Array.from((value.{{name}} as Set).map({{#items}}{{datatype}}{{/items}}ToJSON))), + '{{baseName}}': {{^required}}value.{{name}} === undefined ? undefined : {{/required}}({{#isNullable}}value.{{name}} === null ? null : {{/isNullable}}Array.from(value.{{name}} as Set).map({{#items}}{{datatype}}{{/items}}ToJSON)), {{/uniqueItems}} {{^uniqueItems}} '{{baseName}}': {{^required}}value.{{name}} === undefined ? undefined : {{/required}}({{#isNullable}}value.{{name}} === null ? null : {{/isNullable}}(value.{{name}} as Array).map({{#items}}{{datatype}}{{/items}}ToJSON)), From e9fa93688617d0cb602c5805c48d80750d570289 Mon Sep 17 00:00:00 2001 From: Luca Mazzanti Date: Tue, 4 May 2021 17:58:20 +0200 Subject: [PATCH 08/18] [csharp][netcore-httpclient] Refactor of constructors: removed obsolete attribute (#9373) * Removed obsolete attribute on constructors without HttpClient prameter * add clickable link in the tooltip * update doc, add tests Co-authored-by: William Cheng --- .../resources/csharp-netcore/README.mustache | 11 +++ .../resources/csharp-netcore/api_doc.mustache | 11 +++ .../libraries/httpclient/ApiClient.mustache | 6 +- .../libraries/httpclient/api.mustache | 9 +- .../OpenAPIClient-httpclient/README.md | 6 +- .../docs/AnotherFakeApi.md | 6 +- .../docs/DefaultApi.md | 6 +- .../OpenAPIClient-httpclient/docs/FakeApi.md | 90 +++++++++++++++---- .../docs/FakeClassnameTags123Api.md | 6 +- .../OpenAPIClient-httpclient/docs/PetApi.md | 54 +++++++++-- .../OpenAPIClient-httpclient/docs/StoreApi.md | 24 ++++- .../OpenAPIClient-httpclient/docs/UserApi.md | 48 ++++++++-- .../Org.OpenAPITools.Test/Api/PetApiTests.cs | 12 ++- .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 9 +- .../src/Org.OpenAPITools/Api/DefaultApi.cs | 9 +- .../src/Org.OpenAPITools/Api/FakeApi.cs | 9 +- .../Api/FakeClassnameTags123Api.cs | 9 +- .../src/Org.OpenAPITools/Api/PetApi.cs | 9 +- .../src/Org.OpenAPITools/Api/StoreApi.cs | 9 +- .../src/Org.OpenAPITools/Api/UserApi.cs | 9 +- .../src/Org.OpenAPITools/Client/ApiClient.cs | 6 +- 21 files changed, 287 insertions(+), 71 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/README.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/README.mustache index c5f3c0eadfa9..b15d2a25bf19 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/README.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/README.mustache @@ -137,6 +137,9 @@ services.AddHttpClient(httpClient => ```csharp using System.Collections.Generic; using System.Diagnostics; +{{#useHttpClient}} +using System.Net.Http; +{{/useHttpClient}} using {{packageName}}.{{apiPackage}}; using {{packageName}}.Client; using {{packageName}}.{{modelPackage}}; @@ -174,7 +177,15 @@ namespace Example {{/authMethods}} {{/hasAuthMethods}} + {{#useHttpClient}} + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new {{classname}}(httpClient, config, httpClientHandler); + {{/useHttpClient}} + {{^useHttpClient}} var apiInstance = new {{classname}}(config); + {{/useHttpClient}} {{#allParams}} {{#isPrimitiveType}} var {{paramName}} = {{{example}}}; // {{{dataType}}} | {{{description}}}{{^required}} (optional) {{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/api_doc.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/api_doc.mustache index 0fd9f8790611..d12ee22ea388 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/api_doc.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/api_doc.mustache @@ -22,6 +22,9 @@ Method | HTTP request | Description ```csharp using System.Collections.Generic; using System.Diagnostics; +{{#useHttpClient}} +using System.Net.Http; +{{/useHttpClient}} using {{packageName}}.{{apiPackage}}; using {{packageName}}.Client; using {{packageName}}.{{modelPackage}}; @@ -58,7 +61,15 @@ namespace Example {{/authMethods}} {{/hasAuthMethods}} + {{#useHttpClient}} + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new {{classname}}(httpClient, config, httpClientHandler); + {{/useHttpClient}} + {{^useHttpClient}} var apiInstance = new {{classname}}(config); + {{/useHttpClient}} {{#allParams}} {{#isPrimitiveType}} var {{paramName}} = {{{example}}}; // {{{dataType}}} | {{{description}}}{{^required}} (optional) {{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiClient.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiClient.mustache index 619bcb6bfbb5..640e0335c119 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiClient.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiClient.mustache @@ -191,8 +191,9 @@ namespace {{packageName}}.Client /// /// Initializes a new instance of the , defaulting to the global configurations' base url. + /// **IMPORTANT** This will also create an istance of HttpClient, which is less than ideal. + /// It's better to reuse the HttpClient and HttpClientHander. /// - [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public ApiClient() : this({{packageName}}.Client.GlobalConfiguration.Instance.BasePath) { @@ -200,10 +201,11 @@ namespace {{packageName}}.Client /// /// Initializes a new instance of the . + /// **IMPORTANT** This will also create an istance of HttpClient, which is less than ideal. + /// It's better to reuse the HttpClient and HttpClientHander. /// /// The target service's base path in URL format. /// - [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public ApiClient(String basePath) { if (string.IsNullOrEmpty(basePath)) throw new ArgumentException("basePath cannot be empty"); diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api.mustache index efa52cfbd418..0a3389d0a450 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api.mustache @@ -106,20 +106,22 @@ namespace {{packageName}}.{{apiPackage}} /// /// Initializes a new instance of the class. + /// **IMPORTANT** This will also create an istance of HttpClient, which is less than ideal. + /// It's better to reuse the HttpClient and HttpClientHander. /// /// - [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public {{classname}}() : this((string)null) { } /// /// Initializes a new instance of the class. + /// **IMPORTANT** This will also create an istance of HttpClient, which is less than ideal. + /// It's better to reuse the HttpClient and HttpClientHander. /// /// The target service's base path in URL format. /// /// - [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public {{classname}}(String basePath) { this.Configuration = {{packageName}}.Client.Configuration.MergeConfigurations( @@ -136,11 +138,12 @@ namespace {{packageName}}.{{apiPackage}} /// /// Initializes a new instance of the class using Configuration object. + /// **IMPORTANT** This will also create an istance of HttpClient, which is less than ideal. + /// It's better to reuse the HttpClient and HttpClientHander. /// /// An instance of Configuration. /// /// - [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public {{classname}}({{packageName}}.Client.Configuration configuration) { if (configuration == null) throw new ArgumentNullException("configuration"); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/README.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/README.md index e16da183ea85..48379909c58f 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/README.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/README.md @@ -83,6 +83,7 @@ services.AddHttpClient(httpClient => ```csharp using System.Collections.Generic; using System.Diagnostics; +using System.Net.Http; using Org.OpenAPITools.Api; using Org.OpenAPITools.Client; using Org.OpenAPITools.Model; @@ -96,7 +97,10 @@ namespace Example Configuration config = new Configuration(); config.BasePath = "http://petstore.swagger.io:80/v2"; - var apiInstance = new AnotherFakeApi(config); + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new AnotherFakeApi(httpClient, config, httpClientHandler); var modelClient = new ModelClient(); // ModelClient | client model try diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/docs/AnotherFakeApi.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/docs/AnotherFakeApi.md index 93fca7e408ac..83cdaf2ae930 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/docs/AnotherFakeApi.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/docs/AnotherFakeApi.md @@ -19,6 +19,7 @@ To test special tags and operation ID starting with number ```csharp using System.Collections.Generic; using System.Diagnostics; +using System.Net.Http; using Org.OpenAPITools.Api; using Org.OpenAPITools.Client; using Org.OpenAPITools.Model; @@ -31,7 +32,10 @@ namespace Example { Configuration config = new Configuration(); config.BasePath = "http://petstore.swagger.io:80/v2"; - var apiInstance = new AnotherFakeApi(config); + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new AnotherFakeApi(httpClient, config, httpClientHandler); var modelClient = new ModelClient(); // ModelClient | client model try diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/docs/DefaultApi.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/docs/DefaultApi.md index 6f5de6b68511..ec7241832837 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/docs/DefaultApi.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/docs/DefaultApi.md @@ -17,6 +17,7 @@ Method | HTTP request | Description ```csharp using System.Collections.Generic; using System.Diagnostics; +using System.Net.Http; using Org.OpenAPITools.Api; using Org.OpenAPITools.Client; using Org.OpenAPITools.Model; @@ -29,7 +30,10 @@ namespace Example { Configuration config = new Configuration(); config.BasePath = "http://petstore.swagger.io:80/v2"; - var apiInstance = new DefaultApi(config); + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new DefaultApi(httpClient, config, httpClientHandler); try { diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/docs/FakeApi.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/docs/FakeApi.md index af8d565abfb1..947fbb114ef3 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/docs/FakeApi.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/docs/FakeApi.md @@ -31,6 +31,7 @@ Health check endpoint ```csharp using System.Collections.Generic; using System.Diagnostics; +using System.Net.Http; using Org.OpenAPITools.Api; using Org.OpenAPITools.Client; using Org.OpenAPITools.Model; @@ -43,7 +44,10 @@ namespace Example { Configuration config = new Configuration(); config.BasePath = "http://petstore.swagger.io:80/v2"; - var apiInstance = new FakeApi(config); + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new FakeApi(httpClient, config, httpClientHandler); try { @@ -98,6 +102,7 @@ Test serialization of outer boolean types ```csharp using System.Collections.Generic; using System.Diagnostics; +using System.Net.Http; using Org.OpenAPITools.Api; using Org.OpenAPITools.Client; using Org.OpenAPITools.Model; @@ -110,7 +115,10 @@ namespace Example { Configuration config = new Configuration(); config.BasePath = "http://petstore.swagger.io:80/v2"; - var apiInstance = new FakeApi(config); + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new FakeApi(httpClient, config, httpClientHandler); var body = true; // bool? | Input boolean as post body (optional) try @@ -168,6 +176,7 @@ Test serialization of object with outer number type ```csharp using System.Collections.Generic; using System.Diagnostics; +using System.Net.Http; using Org.OpenAPITools.Api; using Org.OpenAPITools.Client; using Org.OpenAPITools.Model; @@ -180,7 +189,10 @@ namespace Example { Configuration config = new Configuration(); config.BasePath = "http://petstore.swagger.io:80/v2"; - var apiInstance = new FakeApi(config); + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new FakeApi(httpClient, config, httpClientHandler); var outerComposite = new OuterComposite(); // OuterComposite | Input composite as post body (optional) try @@ -238,6 +250,7 @@ Test serialization of outer number types ```csharp using System.Collections.Generic; using System.Diagnostics; +using System.Net.Http; using Org.OpenAPITools.Api; using Org.OpenAPITools.Client; using Org.OpenAPITools.Model; @@ -250,7 +263,10 @@ namespace Example { Configuration config = new Configuration(); config.BasePath = "http://petstore.swagger.io:80/v2"; - var apiInstance = new FakeApi(config); + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new FakeApi(httpClient, config, httpClientHandler); var body = 8.14; // decimal? | Input number as post body (optional) try @@ -308,6 +324,7 @@ Test serialization of outer string types ```csharp using System.Collections.Generic; using System.Diagnostics; +using System.Net.Http; using Org.OpenAPITools.Api; using Org.OpenAPITools.Client; using Org.OpenAPITools.Model; @@ -320,7 +337,10 @@ namespace Example { Configuration config = new Configuration(); config.BasePath = "http://petstore.swagger.io:80/v2"; - var apiInstance = new FakeApi(config); + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new FakeApi(httpClient, config, httpClientHandler); var body = body_example; // string | Input string as post body (optional) try @@ -376,6 +396,7 @@ Array of Enums ```csharp using System.Collections.Generic; using System.Diagnostics; +using System.Net.Http; using Org.OpenAPITools.Api; using Org.OpenAPITools.Client; using Org.OpenAPITools.Model; @@ -388,7 +409,10 @@ namespace Example { Configuration config = new Configuration(); config.BasePath = "http://petstore.swagger.io:80/v2"; - var apiInstance = new FakeApi(config); + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new FakeApi(httpClient, config, httpClientHandler); try { @@ -443,6 +467,7 @@ For this test, the body for this request much reference a schema named `File`. ```csharp using System.Collections.Generic; using System.Diagnostics; +using System.Net.Http; using Org.OpenAPITools.Api; using Org.OpenAPITools.Client; using Org.OpenAPITools.Model; @@ -455,7 +480,10 @@ namespace Example { Configuration config = new Configuration(); config.BasePath = "http://petstore.swagger.io:80/v2"; - var apiInstance = new FakeApi(config); + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new FakeApi(httpClient, config, httpClientHandler); var fileSchemaTestClass = new FileSchemaTestClass(); // FileSchemaTestClass | try @@ -510,6 +538,7 @@ No authorization required ```csharp using System.Collections.Generic; using System.Diagnostics; +using System.Net.Http; using Org.OpenAPITools.Api; using Org.OpenAPITools.Client; using Org.OpenAPITools.Model; @@ -522,7 +551,10 @@ namespace Example { Configuration config = new Configuration(); config.BasePath = "http://petstore.swagger.io:80/v2"; - var apiInstance = new FakeApi(config); + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new FakeApi(httpClient, config, httpClientHandler); var query = query_example; // string | var user = new User(); // User | @@ -581,6 +613,7 @@ To test \"client\" model ```csharp using System.Collections.Generic; using System.Diagnostics; +using System.Net.Http; using Org.OpenAPITools.Api; using Org.OpenAPITools.Client; using Org.OpenAPITools.Model; @@ -593,7 +626,10 @@ namespace Example { Configuration config = new Configuration(); config.BasePath = "http://petstore.swagger.io:80/v2"; - var apiInstance = new FakeApi(config); + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new FakeApi(httpClient, config, httpClientHandler); var modelClient = new ModelClient(); // ModelClient | client model try @@ -652,6 +688,7 @@ Fake endpoint for testing various parameters 假端點 偽のエンドポイン ```csharp using System.Collections.Generic; using System.Diagnostics; +using System.Net.Http; using Org.OpenAPITools.Api; using Org.OpenAPITools.Client; using Org.OpenAPITools.Model; @@ -668,7 +705,10 @@ namespace Example config.Username = "YOUR_USERNAME"; config.Password = "YOUR_PASSWORD"; - var apiInstance = new FakeApi(config); + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new FakeApi(httpClient, config, httpClientHandler); var number = 8.14; // decimal | None var _double = 1.2D; // double | None var patternWithoutDelimiter = patternWithoutDelimiter_example; // string | None @@ -753,6 +793,7 @@ To test enum parameters ```csharp using System.Collections.Generic; using System.Diagnostics; +using System.Net.Http; using Org.OpenAPITools.Api; using Org.OpenAPITools.Client; using Org.OpenAPITools.Model; @@ -765,7 +806,10 @@ namespace Example { Configuration config = new Configuration(); config.BasePath = "http://petstore.swagger.io:80/v2"; - var apiInstance = new FakeApi(config); + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new FakeApi(httpClient, config, httpClientHandler); var enumHeaderStringArray = enumHeaderStringArray_example; // List | Header parameter enum test (string array) (optional) var enumHeaderString = enumHeaderString_example; // string | Header parameter enum test (string) (optional) (default to -efg) var enumQueryStringArray = enumQueryStringArray_example; // List | Query parameter enum test (string array) (optional) @@ -838,6 +882,7 @@ Fake endpoint to test group parameters (optional) ```csharp using System.Collections.Generic; using System.Diagnostics; +using System.Net.Http; using Org.OpenAPITools.Api; using Org.OpenAPITools.Client; using Org.OpenAPITools.Model; @@ -853,7 +898,10 @@ namespace Example // Configure Bearer token for authorization: bearer_test config.AccessToken = "YOUR_BEARER_TOKEN"; - var apiInstance = new FakeApi(config); + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new FakeApi(httpClient, config, httpClientHandler); var requiredStringGroup = 56; // int | Required String in group parameters var requiredBooleanGroup = true; // bool | Required Boolean in group parameters var requiredInt64Group = 789; // long | Required Integer in group parameters @@ -919,6 +967,7 @@ test inline additionalProperties ```csharp using System.Collections.Generic; using System.Diagnostics; +using System.Net.Http; using Org.OpenAPITools.Api; using Org.OpenAPITools.Client; using Org.OpenAPITools.Model; @@ -931,7 +980,10 @@ namespace Example { Configuration config = new Configuration(); config.BasePath = "http://petstore.swagger.io:80/v2"; - var apiInstance = new FakeApi(config); + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new FakeApi(httpClient, config, httpClientHandler); var requestBody = new Dictionary(); // Dictionary | request body try @@ -987,6 +1039,7 @@ test json serialization of form data ```csharp using System.Collections.Generic; using System.Diagnostics; +using System.Net.Http; using Org.OpenAPITools.Api; using Org.OpenAPITools.Client; using Org.OpenAPITools.Model; @@ -999,7 +1052,10 @@ namespace Example { Configuration config = new Configuration(); config.BasePath = "http://petstore.swagger.io:80/v2"; - var apiInstance = new FakeApi(config); + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new FakeApi(httpClient, config, httpClientHandler); var param = param_example; // string | field1 var param2 = param2_example; // string | field2 @@ -1059,6 +1115,7 @@ To test the collection format in query parameters ```csharp using System.Collections.Generic; using System.Diagnostics; +using System.Net.Http; using Org.OpenAPITools.Api; using Org.OpenAPITools.Client; using Org.OpenAPITools.Model; @@ -1071,7 +1128,10 @@ namespace Example { Configuration config = new Configuration(); config.BasePath = "http://petstore.swagger.io:80/v2"; - var apiInstance = new FakeApi(config); + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new FakeApi(httpClient, config, httpClientHandler); var pipe = new List(); // List | var ioutil = new List(); // List | var http = new List(); // List | diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/docs/FakeClassnameTags123Api.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/docs/FakeClassnameTags123Api.md index 13235fbd10f0..4c748ad71c8e 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/docs/FakeClassnameTags123Api.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/docs/FakeClassnameTags123Api.md @@ -19,6 +19,7 @@ To test class name in snake case ```csharp using System.Collections.Generic; using System.Diagnostics; +using System.Net.Http; using Org.OpenAPITools.Api; using Org.OpenAPITools.Client; using Org.OpenAPITools.Model; @@ -36,7 +37,10 @@ namespace Example // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // config.AddApiKeyPrefix("api_key_query", "Bearer"); - var apiInstance = new FakeClassnameTags123Api(config); + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new FakeClassnameTags123Api(httpClient, config, httpClientHandler); var modelClient = new ModelClient(); // ModelClient | client model try diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/docs/PetApi.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/docs/PetApi.md index 47820f406dd2..9f4ec108d05f 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/docs/PetApi.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/docs/PetApi.md @@ -25,6 +25,7 @@ Add a new pet to the store ```csharp using System.Collections.Generic; using System.Diagnostics; +using System.Net.Http; using Org.OpenAPITools.Api; using Org.OpenAPITools.Client; using Org.OpenAPITools.Model; @@ -40,7 +41,10 @@ namespace Example // Configure OAuth2 access token for authorization: petstore_auth config.AccessToken = "YOUR_ACCESS_TOKEN"; - var apiInstance = new PetApi(config); + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new PetApi(httpClient, config, httpClientHandler); var pet = new Pet(); // Pet | Pet object that needs to be added to the store try @@ -96,6 +100,7 @@ Deletes a pet ```csharp using System.Collections.Generic; using System.Diagnostics; +using System.Net.Http; using Org.OpenAPITools.Api; using Org.OpenAPITools.Client; using Org.OpenAPITools.Model; @@ -111,7 +116,10 @@ namespace Example // Configure OAuth2 access token for authorization: petstore_auth config.AccessToken = "YOUR_ACCESS_TOKEN"; - var apiInstance = new PetApi(config); + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new PetApi(httpClient, config, httpClientHandler); var petId = 789; // long | Pet id to delete var apiKey = apiKey_example; // string | (optional) @@ -171,6 +179,7 @@ Multiple status values can be provided with comma separated strings ```csharp using System.Collections.Generic; using System.Diagnostics; +using System.Net.Http; using Org.OpenAPITools.Api; using Org.OpenAPITools.Client; using Org.OpenAPITools.Model; @@ -186,7 +195,10 @@ namespace Example // Configure OAuth2 access token for authorization: petstore_auth config.AccessToken = "YOUR_ACCESS_TOKEN"; - var apiInstance = new PetApi(config); + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new PetApi(httpClient, config, httpClientHandler); var status = status_example; // List | Status values that need to be considered for filter try @@ -246,6 +258,7 @@ Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 ```csharp using System.Collections.Generic; using System.Diagnostics; +using System.Net.Http; using Org.OpenAPITools.Api; using Org.OpenAPITools.Client; using Org.OpenAPITools.Model; @@ -261,7 +274,10 @@ namespace Example // Configure OAuth2 access token for authorization: petstore_auth config.AccessToken = "YOUR_ACCESS_TOKEN"; - var apiInstance = new PetApi(config); + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new PetApi(httpClient, config, httpClientHandler); var tags = new List(); // List | Tags to filter by try @@ -321,6 +337,7 @@ Returns a single pet ```csharp using System.Collections.Generic; using System.Diagnostics; +using System.Net.Http; using Org.OpenAPITools.Api; using Org.OpenAPITools.Client; using Org.OpenAPITools.Model; @@ -338,7 +355,10 @@ namespace Example // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // config.AddApiKeyPrefix("api_key", "Bearer"); - var apiInstance = new PetApi(config); + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new PetApi(httpClient, config, httpClientHandler); var petId = 789; // long | ID of pet to return try @@ -397,6 +417,7 @@ Update an existing pet ```csharp using System.Collections.Generic; using System.Diagnostics; +using System.Net.Http; using Org.OpenAPITools.Api; using Org.OpenAPITools.Client; using Org.OpenAPITools.Model; @@ -412,7 +433,10 @@ namespace Example // Configure OAuth2 access token for authorization: petstore_auth config.AccessToken = "YOUR_ACCESS_TOKEN"; - var apiInstance = new PetApi(config); + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new PetApi(httpClient, config, httpClientHandler); var pet = new Pet(); // Pet | Pet object that needs to be added to the store try @@ -470,6 +494,7 @@ Updates a pet in the store with form data ```csharp using System.Collections.Generic; using System.Diagnostics; +using System.Net.Http; using Org.OpenAPITools.Api; using Org.OpenAPITools.Client; using Org.OpenAPITools.Model; @@ -485,7 +510,10 @@ namespace Example // Configure OAuth2 access token for authorization: petstore_auth config.AccessToken = "YOUR_ACCESS_TOKEN"; - var apiInstance = new PetApi(config); + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new PetApi(httpClient, config, httpClientHandler); var petId = 789; // long | ID of pet that needs to be updated var name = name_example; // string | Updated name of the pet (optional) var status = status_example; // string | Updated status of the pet (optional) @@ -545,6 +573,7 @@ uploads an image ```csharp using System.Collections.Generic; using System.Diagnostics; +using System.Net.Http; using Org.OpenAPITools.Api; using Org.OpenAPITools.Client; using Org.OpenAPITools.Model; @@ -560,7 +589,10 @@ namespace Example // Configure OAuth2 access token for authorization: petstore_auth config.AccessToken = "YOUR_ACCESS_TOKEN"; - var apiInstance = new PetApi(config); + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new PetApi(httpClient, config, httpClientHandler); var petId = 789; // long | ID of pet to update var additionalMetadata = additionalMetadata_example; // string | Additional data to pass to server (optional) var file = BINARY_DATA_HERE; // System.IO.Stream | file to upload (optional) @@ -621,6 +653,7 @@ uploads an image (required) ```csharp using System.Collections.Generic; using System.Diagnostics; +using System.Net.Http; using Org.OpenAPITools.Api; using Org.OpenAPITools.Client; using Org.OpenAPITools.Model; @@ -636,7 +669,10 @@ namespace Example // Configure OAuth2 access token for authorization: petstore_auth config.AccessToken = "YOUR_ACCESS_TOKEN"; - var apiInstance = new PetApi(config); + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new PetApi(httpClient, config, httpClientHandler); var petId = 789; // long | ID of pet to update var requiredFile = BINARY_DATA_HERE; // System.IO.Stream | file to upload var additionalMetadata = additionalMetadata_example; // string | Additional data to pass to server (optional) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/docs/StoreApi.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/docs/StoreApi.md index 24e2480d5deb..248bf31f849c 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/docs/StoreApi.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/docs/StoreApi.md @@ -22,6 +22,7 @@ For valid response try integer IDs with value < 1000. Anything above 1000 or non ```csharp using System.Collections.Generic; using System.Diagnostics; +using System.Net.Http; using Org.OpenAPITools.Api; using Org.OpenAPITools.Client; using Org.OpenAPITools.Model; @@ -34,7 +35,10 @@ namespace Example { Configuration config = new Configuration(); config.BasePath = "http://petstore.swagger.io:80/v2"; - var apiInstance = new StoreApi(config); + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new StoreApi(httpClient, config, httpClientHandler); var orderId = orderId_example; // string | ID of the order that needs to be deleted try @@ -93,6 +97,7 @@ Returns a map of status codes to quantities ```csharp using System.Collections.Generic; using System.Diagnostics; +using System.Net.Http; using Org.OpenAPITools.Api; using Org.OpenAPITools.Client; using Org.OpenAPITools.Model; @@ -110,7 +115,10 @@ namespace Example // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // config.AddApiKeyPrefix("api_key", "Bearer"); - var apiInstance = new StoreApi(config); + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new StoreApi(httpClient, config, httpClientHandler); try { @@ -165,6 +173,7 @@ For valid response try integer IDs with value <= 5 or > 10. Other values will ge ```csharp using System.Collections.Generic; using System.Diagnostics; +using System.Net.Http; using Org.OpenAPITools.Api; using Org.OpenAPITools.Client; using Org.OpenAPITools.Model; @@ -177,7 +186,10 @@ namespace Example { Configuration config = new Configuration(); config.BasePath = "http://petstore.swagger.io:80/v2"; - var apiInstance = new StoreApi(config); + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new StoreApi(httpClient, config, httpClientHandler); var orderId = 789; // long | ID of pet that needs to be fetched try @@ -236,6 +248,7 @@ Place an order for a pet ```csharp using System.Collections.Generic; using System.Diagnostics; +using System.Net.Http; using Org.OpenAPITools.Api; using Org.OpenAPITools.Client; using Org.OpenAPITools.Model; @@ -248,7 +261,10 @@ namespace Example { Configuration config = new Configuration(); config.BasePath = "http://petstore.swagger.io:80/v2"; - var apiInstance = new StoreApi(config); + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new StoreApi(httpClient, config, httpClientHandler); var order = new Order(); // Order | order placed for purchasing the pet try diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/docs/UserApi.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/docs/UserApi.md index aa12c26c69f1..417d9002cf94 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/docs/UserApi.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/docs/UserApi.md @@ -26,6 +26,7 @@ This can only be done by the logged in user. ```csharp using System.Collections.Generic; using System.Diagnostics; +using System.Net.Http; using Org.OpenAPITools.Api; using Org.OpenAPITools.Client; using Org.OpenAPITools.Model; @@ -38,7 +39,10 @@ namespace Example { Configuration config = new Configuration(); config.BasePath = "http://petstore.swagger.io:80/v2"; - var apiInstance = new UserApi(config); + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new UserApi(httpClient, config, httpClientHandler); var user = new User(); // User | Created user object try @@ -94,6 +98,7 @@ Creates list of users with given input array ```csharp using System.Collections.Generic; using System.Diagnostics; +using System.Net.Http; using Org.OpenAPITools.Api; using Org.OpenAPITools.Client; using Org.OpenAPITools.Model; @@ -106,7 +111,10 @@ namespace Example { Configuration config = new Configuration(); config.BasePath = "http://petstore.swagger.io:80/v2"; - var apiInstance = new UserApi(config); + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new UserApi(httpClient, config, httpClientHandler); var user = new List(); // List | List of user object try @@ -162,6 +170,7 @@ Creates list of users with given input array ```csharp using System.Collections.Generic; using System.Diagnostics; +using System.Net.Http; using Org.OpenAPITools.Api; using Org.OpenAPITools.Client; using Org.OpenAPITools.Model; @@ -174,7 +183,10 @@ namespace Example { Configuration config = new Configuration(); config.BasePath = "http://petstore.swagger.io:80/v2"; - var apiInstance = new UserApi(config); + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new UserApi(httpClient, config, httpClientHandler); var user = new List(); // List | List of user object try @@ -232,6 +244,7 @@ This can only be done by the logged in user. ```csharp using System.Collections.Generic; using System.Diagnostics; +using System.Net.Http; using Org.OpenAPITools.Api; using Org.OpenAPITools.Client; using Org.OpenAPITools.Model; @@ -244,7 +257,10 @@ namespace Example { Configuration config = new Configuration(); config.BasePath = "http://petstore.swagger.io:80/v2"; - var apiInstance = new UserApi(config); + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new UserApi(httpClient, config, httpClientHandler); var username = username_example; // string | The name that needs to be deleted try @@ -301,6 +317,7 @@ Get user by user name ```csharp using System.Collections.Generic; using System.Diagnostics; +using System.Net.Http; using Org.OpenAPITools.Api; using Org.OpenAPITools.Client; using Org.OpenAPITools.Model; @@ -313,7 +330,10 @@ namespace Example { Configuration config = new Configuration(); config.BasePath = "http://petstore.swagger.io:80/v2"; - var apiInstance = new UserApi(config); + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new UserApi(httpClient, config, httpClientHandler); var username = username_example; // string | The name that needs to be fetched. Use user1 for testing. try @@ -372,6 +392,7 @@ Logs user into the system ```csharp using System.Collections.Generic; using System.Diagnostics; +using System.Net.Http; using Org.OpenAPITools.Api; using Org.OpenAPITools.Client; using Org.OpenAPITools.Model; @@ -384,7 +405,10 @@ namespace Example { Configuration config = new Configuration(); config.BasePath = "http://petstore.swagger.io:80/v2"; - var apiInstance = new UserApi(config); + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new UserApi(httpClient, config, httpClientHandler); var username = username_example; // string | The user name for login var password = password_example; // string | The password for login in clear text @@ -444,6 +468,7 @@ Logs out current logged in user session ```csharp using System.Collections.Generic; using System.Diagnostics; +using System.Net.Http; using Org.OpenAPITools.Api; using Org.OpenAPITools.Client; using Org.OpenAPITools.Model; @@ -456,7 +481,10 @@ namespace Example { Configuration config = new Configuration(); config.BasePath = "http://petstore.swagger.io:80/v2"; - var apiInstance = new UserApi(config); + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new UserApi(httpClient, config, httpClientHandler); try { @@ -510,6 +538,7 @@ This can only be done by the logged in user. ```csharp using System.Collections.Generic; using System.Diagnostics; +using System.Net.Http; using Org.OpenAPITools.Api; using Org.OpenAPITools.Client; using Org.OpenAPITools.Model; @@ -522,7 +551,10 @@ namespace Example { Configuration config = new Configuration(); config.BasePath = "http://petstore.swagger.io:80/v2"; - var apiInstance = new UserApi(config); + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new UserApi(httpClient, config, httpClientHandler); var username = username_example; // string | name that need to be deleted var user = new User(); // User | Updated user object diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools.Test/Api/PetApiTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools.Test/Api/PetApiTests.cs index eca3164a17fd..04ef8503f955 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools.Test/Api/PetApiTests.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools.Test/Api/PetApiTests.cs @@ -16,6 +16,8 @@ using System.Reflection; using Xunit; +using System.Net.Http; + using Org.OpenAPITools.Client; using Org.OpenAPITools.Api; using Org.OpenAPITools.Model; @@ -73,8 +75,10 @@ private byte[] GetBytes(string str) } public PetApiTests() - { - instance = new PetApi(); + { + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + instance = new PetApi(httpClient, httpClientHandler); // create pet Pet p = createPet(); @@ -153,7 +157,9 @@ public void GetPetByIdTest() c1.Timeout = 10000; c1.UserAgent = "TEST_USER_AGENT"; - PetApi petApi = new PetApi(c1); + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + PetApi petApi = new PetApi(httpClient, c1, httpClientHandler); Pet response = petApi.GetPetById(petId); Assert.IsType(response); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/AnotherFakeApi.cs index 83a938cf365d..8498781b05c4 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/AnotherFakeApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/AnotherFakeApi.cs @@ -100,20 +100,22 @@ public partial class AnotherFakeApi : IDisposable, IAnotherFakeApi /// /// Initializes a new instance of the class. + /// **IMPORTANT** This will also create an istance of HttpClient, which is less than ideal. + /// It's better to reuse the HttpClient and HttpClientHander. /// /// - [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public AnotherFakeApi() : this((string)null) { } /// /// Initializes a new instance of the class. + /// **IMPORTANT** This will also create an istance of HttpClient, which is less than ideal. + /// It's better to reuse the HttpClient and HttpClientHander. /// /// The target service's base path in URL format. /// /// - [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public AnotherFakeApi(String basePath) { this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( @@ -128,11 +130,12 @@ public AnotherFakeApi(String basePath) /// /// Initializes a new instance of the class using Configuration object. + /// **IMPORTANT** This will also create an istance of HttpClient, which is less than ideal. + /// It's better to reuse the HttpClient and HttpClientHander. /// /// An instance of Configuration. /// /// - [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public AnotherFakeApi(Org.OpenAPITools.Client.Configuration configuration) { if (configuration == null) throw new ArgumentNullException("configuration"); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/DefaultApi.cs index 84b91a9a1712..299f2875b21c 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -93,20 +93,22 @@ public partial class DefaultApi : IDisposable, IDefaultApi /// /// Initializes a new instance of the class. + /// **IMPORTANT** This will also create an istance of HttpClient, which is less than ideal. + /// It's better to reuse the HttpClient and HttpClientHander. /// /// - [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public DefaultApi() : this((string)null) { } /// /// Initializes a new instance of the class. + /// **IMPORTANT** This will also create an istance of HttpClient, which is less than ideal. + /// It's better to reuse the HttpClient and HttpClientHander. /// /// The target service's base path in URL format. /// /// - [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public DefaultApi(String basePath) { this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( @@ -121,11 +123,12 @@ public DefaultApi(String basePath) /// /// Initializes a new instance of the class using Configuration object. + /// **IMPORTANT** This will also create an istance of HttpClient, which is less than ideal. + /// It's better to reuse the HttpClient and HttpClientHander. /// /// An instance of Configuration. /// /// - [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public DefaultApi(Org.OpenAPITools.Client.Configuration configuration) { if (configuration == null) throw new ArgumentNullException("configuration"); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeApi.cs index 305a59a6b5bd..66f86c619fcf 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeApi.cs @@ -817,20 +817,22 @@ public partial class FakeApi : IDisposable, IFakeApi /// /// Initializes a new instance of the class. + /// **IMPORTANT** This will also create an istance of HttpClient, which is less than ideal. + /// It's better to reuse the HttpClient and HttpClientHander. /// /// - [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public FakeApi() : this((string)null) { } /// /// Initializes a new instance of the class. + /// **IMPORTANT** This will also create an istance of HttpClient, which is less than ideal. + /// It's better to reuse the HttpClient and HttpClientHander. /// /// The target service's base path in URL format. /// /// - [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public FakeApi(String basePath) { this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( @@ -845,11 +847,12 @@ public FakeApi(String basePath) /// /// Initializes a new instance of the class using Configuration object. + /// **IMPORTANT** This will also create an istance of HttpClient, which is less than ideal. + /// It's better to reuse the HttpClient and HttpClientHander. /// /// An instance of Configuration. /// /// - [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public FakeApi(Org.OpenAPITools.Client.Configuration configuration) { if (configuration == null) throw new ArgumentNullException("configuration"); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs index f9c9d3b33cea..efec560791ec 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs @@ -100,20 +100,22 @@ public partial class FakeClassnameTags123Api : IDisposable, IFakeClassnameTags12 /// /// Initializes a new instance of the class. + /// **IMPORTANT** This will also create an istance of HttpClient, which is less than ideal. + /// It's better to reuse the HttpClient and HttpClientHander. /// /// - [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public FakeClassnameTags123Api() : this((string)null) { } /// /// Initializes a new instance of the class. + /// **IMPORTANT** This will also create an istance of HttpClient, which is less than ideal. + /// It's better to reuse the HttpClient and HttpClientHander. /// /// The target service's base path in URL format. /// /// - [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public FakeClassnameTags123Api(String basePath) { this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( @@ -128,11 +130,12 @@ public FakeClassnameTags123Api(String basePath) /// /// Initializes a new instance of the class using Configuration object. + /// **IMPORTANT** This will also create an istance of HttpClient, which is less than ideal. + /// It's better to reuse the HttpClient and HttpClientHander. /// /// An instance of Configuration. /// /// - [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public FakeClassnameTags123Api(Org.OpenAPITools.Client.Configuration configuration) { if (configuration == null) throw new ArgumentNullException("configuration"); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/PetApi.cs index b43e10ad1ffb..7f9a79b6bb3d 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/PetApi.cs @@ -462,20 +462,22 @@ public partial class PetApi : IDisposable, IPetApi /// /// Initializes a new instance of the class. + /// **IMPORTANT** This will also create an istance of HttpClient, which is less than ideal. + /// It's better to reuse the HttpClient and HttpClientHander. /// /// - [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public PetApi() : this((string)null) { } /// /// Initializes a new instance of the class. + /// **IMPORTANT** This will also create an istance of HttpClient, which is less than ideal. + /// It's better to reuse the HttpClient and HttpClientHander. /// /// The target service's base path in URL format. /// /// - [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public PetApi(String basePath) { this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( @@ -490,11 +492,12 @@ public PetApi(String basePath) /// /// Initializes a new instance of the class using Configuration object. + /// **IMPORTANT** This will also create an istance of HttpClient, which is less than ideal. + /// It's better to reuse the HttpClient and HttpClientHander. /// /// An instance of Configuration. /// /// - [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public PetApi(Org.OpenAPITools.Client.Configuration configuration) { if (configuration == null) throw new ArgumentNullException("configuration"); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/StoreApi.cs index f174edf50628..d7b0b43698af 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/StoreApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/StoreApi.cs @@ -225,20 +225,22 @@ public partial class StoreApi : IDisposable, IStoreApi /// /// Initializes a new instance of the class. + /// **IMPORTANT** This will also create an istance of HttpClient, which is less than ideal. + /// It's better to reuse the HttpClient and HttpClientHander. /// /// - [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public StoreApi() : this((string)null) { } /// /// Initializes a new instance of the class. + /// **IMPORTANT** This will also create an istance of HttpClient, which is less than ideal. + /// It's better to reuse the HttpClient and HttpClientHander. /// /// The target service's base path in URL format. /// /// - [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public StoreApi(String basePath) { this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( @@ -253,11 +255,12 @@ public StoreApi(String basePath) /// /// Initializes a new instance of the class using Configuration object. + /// **IMPORTANT** This will also create an istance of HttpClient, which is less than ideal. + /// It's better to reuse the HttpClient and HttpClientHander. /// /// An instance of Configuration. /// /// - [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public StoreApi(Org.OpenAPITools.Client.Configuration configuration) { if (configuration == null) throw new ArgumentNullException("configuration"); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/UserApi.cs index 0426a00745eb..9b4826f955eb 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/UserApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/UserApi.cs @@ -397,20 +397,22 @@ public partial class UserApi : IDisposable, IUserApi /// /// Initializes a new instance of the class. + /// **IMPORTANT** This will also create an istance of HttpClient, which is less than ideal. + /// It's better to reuse the HttpClient and HttpClientHander. /// /// - [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public UserApi() : this((string)null) { } /// /// Initializes a new instance of the class. + /// **IMPORTANT** This will also create an istance of HttpClient, which is less than ideal. + /// It's better to reuse the HttpClient and HttpClientHander. /// /// The target service's base path in URL format. /// /// - [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public UserApi(String basePath) { this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( @@ -425,11 +427,12 @@ public UserApi(String basePath) /// /// Initializes a new instance of the class using Configuration object. + /// **IMPORTANT** This will also create an istance of HttpClient, which is less than ideal. + /// It's better to reuse the HttpClient and HttpClientHander. /// /// An instance of Configuration. /// /// - [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public UserApi(Org.OpenAPITools.Client.Configuration configuration) { if (configuration == null) throw new ArgumentNullException("configuration"); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/ApiClient.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/ApiClient.cs index 26695dd48d45..9bdab1cf4c87 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/ApiClient.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/ApiClient.cs @@ -191,8 +191,9 @@ public partial class ApiClient : IDisposable, ISynchronousClient, IAsynchronousC /// /// Initializes a new instance of the , defaulting to the global configurations' base url. + /// **IMPORTANT** This will also create an istance of HttpClient, which is less than ideal. + /// It's better to reuse the HttpClient and HttpClientHander. /// - [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public ApiClient() : this(Org.OpenAPITools.Client.GlobalConfiguration.Instance.BasePath) { @@ -200,10 +201,11 @@ public ApiClient() : /// /// Initializes a new instance of the . + /// **IMPORTANT** This will also create an istance of HttpClient, which is less than ideal. + /// It's better to reuse the HttpClient and HttpClientHander. /// /// The target service's base path in URL format. /// - [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public ApiClient(String basePath) { if (string.IsNullOrEmpty(basePath)) throw new ArgumentException("basePath cannot be empty"); From 4d2b022619ccf85fe30f9dbf33f7c12e24933abf Mon Sep 17 00:00:00 2001 From: shylacs Date: Tue, 4 May 2021 09:08:15 -0700 Subject: [PATCH 09/18] Add VMware to users list (#9388) * Add VMware to users list LMK if I can provide the png for company logo. I tried uploading to img folder and could not. * add logo, update readme Co-authored-by: William Cheng --- README.md | 1 + website/src/dynamic/users.yml | 5 +++++ website/static/img/companies/vmware.png | Bin 0 -> 3140 bytes 3 files changed, 6 insertions(+) create mode 100644 website/static/img/companies/vmware.png diff --git a/README.md b/README.md index 2e3ff4b34d77..c994f615fa62 100644 --- a/README.md +++ b/README.md @@ -666,6 +666,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in - [Twitter](https://twitter.com) - [unblu inc.](https://www.unblu.com/) - [Veamly](https://www.veamly.com/) +- [VMWare](https://www.vmware.com/) - [wbt-solutions](https://www.wbt-solutions.de/) - [Woleet](https://www.woleet.io/) - [WSO2](https://wso2.com/) diff --git a/website/src/dynamic/users.yml b/website/src/dynamic/users.yml index 38104947192d..7b955bfe3372 100644 --- a/website/src/dynamic/users.yml +++ b/website/src/dynamic/users.yml @@ -453,6 +453,11 @@ image: "img/companies/viadee.jpg" infoLink: "https://www.viadee.de" pinned: false +- + caption: "VMware" + image: "img/companies/vmware.png" + infoLink: "https://www.vmware.com/" + pinned: false - caption: Vonage image: "img/companies/vonage.png" diff --git a/website/static/img/companies/vmware.png b/website/static/img/companies/vmware.png new file mode 100644 index 0000000000000000000000000000000000000000..7e697256a9e1771186befa93dea15f8564c7e95b GIT binary patch literal 3140 zcmV-K47>A*P)|O0~+%^z}ZuDQ53dBqb(76K96^O3DR0XCgFjYa$6_~0ZR0XCg2vtBPR0mWA z32|B42m~y!z=C&@4>KIu5{a+fefxF+f+qsXZ|B+N^rN1xT>L1#{M}zq!@XFbOntbR zew5IMjo}vApKiLgQ=gs)^`0s9%4=<@TV5@7yi@&G(~koBZ0h$g*A4YQ6Z^iab9(L} z;oM)&eWlDTv5oWTM>bvK)W#!2UrnW_%rCLc4C;Rj9JgQ?`Nb6Bwk%DPV?SBTN4lOT)rxR@Pt6}+c*{s5)cOU}h;kg-U>|AH7u89B$Q93=?e1@!$BfVN&TlQ-9l zF3O$)9jVT2YoBq0jAoWy&0~Y{%=nP62u4*W0E@2-_1058-(bKqo$8tTE781zI(L&Q z+tR##Xpzsi;CXFro7yPnu`(HQVfk~(DC)v8mcrsdh5+W~l4ApUavsokQ^}CN=bnAC z$^}?|7XcP?ALY3JoOKu}6@H^#4Rx;*)!*n~3_|J>8#AVqYlnhS;$j=fwl1%o zNR}NlXmmu|7)`pWfW^kMP4yamblAaY2hG+irQV$`k^v)t(wWLu9Lo#P@ci8lFk-_J zkfTd6Ie^Jl$BWel$eD}?xXko;Gu?ZlUH~>Z+|zr8gVCWKFbiLn-p~0BJ=v>(#oD1G z1&sNPPl`j{0Y5JYO&vRY?HI zSuqDiY31{48C%QbwgeT^s)tO{!QbRP??CxGM|{7H)a6eOdze?maxn6DGGT2Y?9qY`L;6p{1;ne4hkBv(QQYdm-xi8cPq#uFjWj z6{Cd&Rj3^P^aSoQWOYGdF@w!uQ|nHY4|5I(Nu;2dts1VvZHa zPBIe>vh9=P09Q0y@6{T;04dWa}%{h#kFjY!pa_G-0Qn@S7$@xg6{S8A> ztW9)p>bj}*lnjPEC?2heRV;+Xj7z=wY-0i`3^7nw7flEwPG?Qo#I}m`>Ln+zFtQ6l zq`e{GPOMj3JS;&BdCLq;R;n%DRv9C7HQxgRYl(e%QBL((XHu$$pd7o+Mp!}&5<3*i z*Kx*g`z{i=ra54VL#KLr%Unu%-Nxh-4};( zUs=M>fw-!63F9h=;cTvZO#tj(&~sHO!_AG&F(hV0Q8}Dbizn*{G({%FE= zH0Sydau;v80GQjnzcl8X07GsqVU#H}^$AOYS4Rvdj2&_b&P^f5L}Z7~uvZqvd>{gb zZ8so=T@0b`Ec}ElgJP)I-?5B5Ir)i%BfX1iEAM=`z+wd5+=6lGSC=>s5Dgfwxtu!U zWnWsj*6AuJKt|}xkzM!$#%M6C3<(WwhTLLwdwR~)4wf$|Lu3p6YaAdU|L(J)=~fGg z=d(a_<}hb?LptRRuq#Ai?ue68MX-xeyuBs2RAI?;fcFm#6Ixro#9;JiA?+xyc4K{z zTeokht7meqlvm#0!@E9*P!0uboQGXg7{;8-@HJ$qNLS#QE{JHp-N$y}SI#m@3ozVx z8nVxlpsgKKz69Hd^z3jnwlE~=Y4!UGNgx+xG~k${BlecV&{zg#Q&VMO8^>^jmu1-A zV9kKu>xN7UM?Bgo2rS0saBQroJ7BO7BK{pA)AMVt1D^K+7y-tdD<32BEzOZ#1eL}! z{3tA*%s0X83`-CegKh;!cAip0+SgcY3?+XHfI&gij@XC#X!~gZ0}DqO*k9>k+^%+P zV9}@8z{GSOEm!G00snOYh9k*lDoej)_Opg1*vmv$uDk+6JB0^exY+52J3kNzQ2Qv> zoUJT%`d7n!ujA;!hUv>> z7h;)rOF}{87MX(@KFS;&j={H2bT&x-lHrOtxCarR!9KoZ#_y%t1V-;0{-gqzO#Jr^ z)Uyaf`6PaP^6!ufmW-_ezdAq9!Tb?%mW1yr;F;LmLvu9qy|9dd;UqI3*|h=R<-iVh z=?%MAT}E;Rp9j!&bv#7jfm}-DmR$UIR>oJK^EZJ}e1y+QGzegJ)NKu?0fW1nI#P?U zHSJL>lkDsR`t_PwhLnlx90`tjZ$0X1iG7!6ZqKsjRq3`Le0ta>n?A9^&TsvwT#&G0+#v;<}laTY0zm|igVIDRj&2HD-H&kL? z>RUxLUJ?d1#wJ||r-1c=N!6P9KK&V=uxA@#aM(w+Im5svGRNU#EFD8X2QUuxTc>>> z;4B)(D&IJ*8QYPv$zm5ARuO}mKLzL#ZVw30;o%C0&?#YyNm;iZ==>NlSEGX_-ZIS3 z$ONF+SV{}nJun%|dzh~fw$+22e$~fq+4tZ&ys0thT(bmY0e#3I1rP#u1B_P!#WlxU z;VdT*!P3o~Y}!Cad!VT7OQ^71Rw%J_56Tt&syu8Ms-W%+0I?V0U$|21K3D3_m3i87 zZIg#K<})yoEn!2perAoyw)w-dYA*0(UJsX7)?Yh5vhg@?^i0w3y}i-^vdy6%*jx-E e(f57+6<`32R!k6Gk%emj0000 Date: Wed, 5 May 2021 10:52:47 +0200 Subject: [PATCH 10/18] [C++] [Pistache] Model validation, general overhaul (#9251) * overhaul pistache templates * fix function signature in model-source return type now aligns with definition in model-header * use default keyword for destructors * generate pistache samples * move bin/configs/other/cpp-pistache-server-cpp-pistache.yaml to bin/configs/cpp-pistache-server-cpp-pistache.yaml * Only generate validation body if necessary * generate pistache samples --- .../cpp-pistache-server-cpp-pistache.yaml | 0 .../languages/CppPistacheServerCodegen.java | 1 + .../cpp-pistache-server/api-header.mustache | 37 ++-- .../api-impl-header.mustache | 15 +- .../api-impl-source.mustache | 7 +- .../cpp-pistache-server/api-source.mustache | 60 ++++-- .../helpers-header.mustache | 86 ++++++-- .../helpers-source.mustache | 76 +++++-- .../cpp-pistache-server/model-header.mustache | 31 ++- .../cpp-pistache-server/model-source.mustache | 78 +++++-- .../model-struct-header.mustache | 11 +- .../model-struct-source.mustache | 9 +- .../model-validation-body.mustache | 124 +++++++++++ .../cpp-pistache/.openapi-generator/VERSION | 2 +- .../petstore/cpp-pistache/api/PetApi.cpp | 174 ++++++++++------ .../server/petstore/cpp-pistache/api/PetApi.h | 45 ++-- .../petstore/cpp-pistache/api/StoreApi.cpp | 106 ++++++---- .../petstore/cpp-pistache/api/StoreApi.h | 39 ++-- .../petstore/cpp-pistache/api/UserApi.cpp | 194 ++++++++++++------ .../petstore/cpp-pistache/api/UserApi.h | 45 ++-- .../petstore/cpp-pistache/impl/PetApiImpl.cpp | 5 +- .../petstore/cpp-pistache/impl/PetApiImpl.h | 17 +- .../cpp-pistache/impl/StoreApiImpl.cpp | 5 +- .../petstore/cpp-pistache/impl/StoreApiImpl.h | 17 +- .../cpp-pistache/impl/UserApiImpl.cpp | 5 +- .../petstore/cpp-pistache/impl/UserApiImpl.h | 17 +- .../cpp-pistache/model/ApiResponse.cpp | 59 +++++- .../petstore/cpp-pistache/model/ApiResponse.h | 31 ++- .../petstore/cpp-pistache/model/Category.cpp | 55 ++++- .../petstore/cpp-pistache/model/Category.h | 31 ++- .../petstore/cpp-pistache/model/Helpers.cpp | 78 +++++-- .../petstore/cpp-pistache/model/Helpers.h | 88 ++++++-- .../petstore/cpp-pistache/model/Order.cpp | 71 ++++++- .../petstore/cpp-pistache/model/Order.h | 31 ++- .../petstore/cpp-pistache/model/Pet.cpp | 117 +++++++++-- .../server/petstore/cpp-pistache/model/Pet.h | 35 ++-- .../petstore/cpp-pistache/model/Tag.cpp | 55 ++++- .../server/petstore/cpp-pistache/model/Tag.h | 31 ++- .../petstore/cpp-pistache/model/User.cpp | 79 ++++++- .../server/petstore/cpp-pistache/model/User.h | 31 ++- 40 files changed, 1461 insertions(+), 537 deletions(-) rename bin/configs/{other => }/cpp-pistache-server-cpp-pistache.yaml (100%) create mode 100644 modules/openapi-generator/src/main/resources/cpp-pistache-server/model-validation-body.mustache diff --git a/bin/configs/other/cpp-pistache-server-cpp-pistache.yaml b/bin/configs/cpp-pistache-server-cpp-pistache.yaml similarity index 100% rename from bin/configs/other/cpp-pistache-server-cpp-pistache.yaml rename to bin/configs/cpp-pistache-server-cpp-pistache.yaml diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppPistacheServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppPistacheServerCodegen.java index bf49fd425e05..3064af52c20d 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppPistacheServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppPistacheServerCodegen.java @@ -128,6 +128,7 @@ public CppPistacheServerCodegen() { typeMapping.put("boolean", "bool"); typeMapping.put("array", "std::vector"); typeMapping.put("map", "std::map"); + typeMapping.put("set", "std::vector"); typeMapping.put("file", "std::string"); typeMapping.put("object", "Object"); typeMapping.put("binary", "std::string"); diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-header.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-header.mustache index 7beb0990a960..f614d478e96c 100644 --- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-header.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-header.mustache @@ -14,24 +14,21 @@ #include #include {{^hasModelImport}}#include {{/hasModelImport}} +#include {{#imports}}{{{import}}} {{/imports}} -{{#apiNamespaceDeclarations}} -namespace {{this}} { -{{/apiNamespaceDeclarations}} - -{{#hasModelImport}} -using namespace {{modelNamespace}};{{/hasModelImport}} +namespace {{apiNamespace}} +{ class {{declspec}} {{classname}} { public: - {{classname}}(std::shared_ptr); - virtual ~{{classname}}() {} + explicit {{classname}}(const std::shared_ptr& rtr); + virtual ~{{classname}}() = default; void init(); - const std::string base = "{{basePathWithoutHost}}"; + static const std::string base; private: void setupRoutes(); @@ -41,9 +38,21 @@ private: {{/operation}} void {{classnameSnakeLowerCase}}_default_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response); - std::shared_ptr router; - {{#operation}} + const std::shared_ptr router; + + /// + /// Helper function to handle unexpected Exceptions during Parameter parsing and validation. + /// May be overriden to return custom error formats. + /// + virtual std::pair handleParsingException(const std::exception& ex) const noexcept; + /// + /// Helper function to handle unexpected Exceptions during processing of the request in handler functions. + /// May be overriden to return custom error formats. + /// + virtual std::pair handleOperationException(const std::exception& ex) const noexcept; + + {{#operation}} /// /// {{summary}} /// @@ -54,7 +63,7 @@ private: {{#allParams}} /// {{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}} {{/allParams}} - virtual void {{operationIdSnakeCase}}({{#allParams}}const {{{dataType}}} &{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#hasParams}}, {{/hasParams}}Pistache::Http::ResponseWriter &response) = 0; + virtual void {{operationIdSnakeCase}}({{#allParams}}const {{#isModel}}{{modelNamespace}}::{{/isModel}}{{{dataType}}} &{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#hasParams}}, {{/hasParams}}Pistache::Http::ResponseWriter &response) = 0; {{/vendorExtensions.x-codegen-pistache-is-parsing-supported}} {{^vendorExtensions.x-codegen-pistache-is-parsing-supported}} virtual void {{operationIdSnakeCase}}(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter &response) = 0; @@ -63,9 +72,7 @@ private: }; -{{#apiNamespaceDeclarations}} -} -{{/apiNamespaceDeclarations}} +} // namespace {{apiNamespace}} #endif /* {{classname}}_H_ */ diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-impl-header.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-impl-header.mustache index 18ff119ae208..bd20c1bdf5ab 100644 --- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-impl-header.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-impl-header.mustache @@ -22,17 +22,16 @@ {{#imports}}{{{import}}} {{/imports}} -{{#apiNamespaceDeclarations}} -namespace {{this}} { -{{/apiNamespaceDeclarations}} +namespace {{apiNamespace}} +{ {{#hasModelImport}} using namespace {{modelNamespace}};{{/hasModelImport}} class {{classname}}Impl : public {{apiNamespace}}::{{classname}} { public: - {{classname}}Impl(std::shared_ptr); - ~{{classname}}Impl() {} + explicit {{classname}}Impl(const std::shared_ptr& rtr); + ~{{classname}}Impl() override = default; {{#operation}} {{#vendorExtensions.x-codegen-pistache-is-parsing-supported}} @@ -45,11 +44,9 @@ public: }; -{{#apiNamespaceDeclarations}} -} -{{/apiNamespaceDeclarations}} +} // namespace {{apiNamespace}} {{/operations}} -#endif \ No newline at end of file +#endif diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-impl-source.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-impl-source.mustache index e5517bb487c1..2e25a8034b30 100644 --- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-impl-source.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-impl-source.mustache @@ -10,9 +10,10 @@ namespace {{this}} { {{#hasModelImport}} using namespace {{modelNamespace}};{{/hasModelImport}} -{{classname}}Impl::{{classname}}Impl(std::shared_ptr rtr) +{{classname}}Impl::{{classname}}Impl(const std::shared_ptr& rtr) : {{classname}}(rtr) - { } +{ +} {{#operation}} {{#vendorExtensions.x-codegen-pistache-is-parsing-supported}} @@ -31,4 +32,4 @@ void {{classname}}Impl::{{operationIdSnakeCase}}(const Pistache::Rest::Request & } {{/apiNamespaceDeclarations}} -{{/operations}} \ No newline at end of file +{{/operations}} diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-source.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-source.mustache index 9225a5610c70..9814ba0cd626 100644 --- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-source.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-source.mustache @@ -4,16 +4,18 @@ #include "{{classname}}.h" #include "{{prefix}}Helpers.h" -{{#apiNamespaceDeclarations}} -namespace {{this}} { -{{/apiNamespaceDeclarations}} +namespace {{apiNamespace}} +{ using namespace {{helpersNamespace}}; {{#hasModelImport}} using namespace {{modelNamespace}};{{/hasModelImport}} -{{classname}}::{{classname}}(std::shared_ptr rtr) { - router = rtr; +const std::string {{classname}}::base = "{{basePathWithoutHost}}"; + +{{classname}}::{{classname}}(const std::shared_ptr& rtr) + : router(rtr) +{ } void {{classname}}::init() { @@ -31,8 +33,26 @@ void {{classname}}::setupRoutes() { router->addCustomHandler(Routes::bind(&{{classname}}::{{classnameSnakeLowerCase}}_default_handler, this)); } +std::pair {{classname}}::handleParsingException(const std::exception& ex) const noexcept +{ + try { + throw ex; + } catch (nlohmann::detail::exception &e) { + return std::make_pair(Pistache::Http::Code::Bad_Request, e.what()); + } catch ({{helpersNamespace}}::ValidationException &e) { + return std::make_pair(Pistache::Http::Code::Bad_Request, e.what()); + } +} + +std::pair {{classname}}::handleOperationException(const std::exception& ex) const noexcept +{ + return std::make_pair(Pistache::Http::Code::Internal_Server_Error, ex.what()); +} + {{#operation}} void {{classname}}::{{operationIdSnakeCase}}_handler(const Pistache::Rest::Request &{{#hasParams}}request{{/hasParams}}, Pistache::Http::ResponseWriter response) { + try { + {{#vendorExtensions.x-codegen-pistache-is-parsing-supported}} {{#hasPathParams}} // Getting the path params @@ -71,32 +91,40 @@ void {{classname}}::{{operationIdSnakeCase}}_handler(const Pistache::Rest::Reque {{#hasBodyParam}} {{#bodyParam}} {{^isPrimitiveType}} - nlohmann::json::parse(request.body()).get_to({{paramName}}); + nlohmann::json::parse(request.body()).get_to({{paramName}}); + {{paramName}}.validate(); {{/isPrimitiveType}} {{#isPrimitiveType}} - {{paramName}} = request.body(); + {{paramName}} = request.body(); {{/isPrimitiveType}} + } catch (std::exception &e) { + const std::pair errorInfo = this->handleParsingException(e); + response.send(errorInfo.first, errorInfo.second); + return; + } + + try { {{/bodyParam}} {{/hasBodyParam}} - this->{{operationIdSnakeCase}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#hasParams}}, {{/hasParams}}response); + this->{{operationIdSnakeCase}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#hasParams}}, {{/hasParams}}response); {{/vendorExtensions.x-codegen-pistache-is-parsing-supported}} {{^vendorExtensions.x-codegen-pistache-is-parsing-supported}} try { this->{{operationIdSnakeCase}}(request, response); {{/vendorExtensions.x-codegen-pistache-is-parsing-supported}} - } catch (nlohmann::detail::exception &e) { - //send a 400 error - response.send(Pistache::Http::Code::Bad_Request, e.what()); - return; } catch (Pistache::Http::HttpError &e) { response.send(static_cast(e.code()), e.what()); return; } catch (std::exception &e) { - //send a 500 error - response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + const std::pair errorInfo = this->handleOperationException(e); + response.send(errorInfo.first, errorInfo.second); return; } + } catch (std::exception &e) { + response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + } + } {{/operation}} @@ -104,8 +132,6 @@ void {{classname}}::{{classnameSnakeLowerCase}}_default_handler(const Pistache:: response.send(Pistache::Http::Code::Not_Found, "The requested method does not exist"); } -{{#apiNamespaceDeclarations}} -} -{{/apiNamespaceDeclarations}} +} // namespace {{apiNamespace}} {{/operations}} diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/helpers-header.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/helpers-header.mustache index c39cca04fe10..d3489fad4026 100644 --- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/helpers-header.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/helpers-header.mustache @@ -14,16 +14,80 @@ #include #include -{{#helpersNamespaceDeclarations}} -namespace {{this}} { -{{/helpersNamespaceDeclarations}} +namespace {{helpersNamespace}} +{ + + class ValidationException : public std::runtime_error + { + public: + explicit ValidationException(const std::string& what) + : std::runtime_error(what) + { } + ~ValidationException() override = default; + }; + + /// + /// Validate a string against the full-date definition of RFC 3339, section 5.6. + /// + bool validateRfc3339_date(const std::string& str); + + /// + /// Validate a string against the date-time definition of RFC 3339, section 5.6. + /// + bool validateRfc3339_date_time(const std::string& str); + + namespace sfinae_helpers + { + struct NoType {}; + template NoType operator==(const T1&, const T2&); + + template class EqualsOperatorAvailable + { + public: + enum + { + value = !std::is_same< decltype(std::declval() == std::declval()), NoType >::value + }; + }; + } // namespace sfinae_helpers + + + /// + /// Determine if the given vector only has unique elements. T must provide the == operator. + /// + template + bool hasOnlyUniqueItems(const std::vector& vec) + { + static_assert(sfinae_helpers::EqualsOperatorAvailable::value, + "hasOnlyUniqueItems cannot be called, passed template type does not provide == operator."); + if (vec.size() <= 1) + { + return true; + } + // Compare every element of vec to every other element of vec. + // This isn't an elegant way to do this, since it's O(n^2), + // but it's the best solution working only with the == operator. + // This could be greatly improved if our models provided a valid hash + // and/or the < operator + for (size_t i = 0; i < vec.size() - 1; i++) + { + for (size_t j = i + 1; j < vec.size(); j++) + { + if (vec[i] == vec[j]) + { + return false; + } + } + } + return true; + } std::string toStringValue(const std::string &value); - std::string toStringValue(const int32_t &value); - std::string toStringValue(const int64_t &value); - std::string toStringValue(const bool &value); - std::string toStringValue(const float &value); - std::string toStringValue(const double &value); + std::string toStringValue(const int32_t value); + std::string toStringValue(const int64_t value); + std::string toStringValue(const bool value); + std::string toStringValue(const float value); + std::string toStringValue(const double value); bool fromStringValue(const std::string &inStr, std::string &value); bool fromStringValue(const std::string &inStr, int32_t &value); @@ -57,8 +121,6 @@ namespace {{this}} { return fromStringValue(inStrings, value); } -{{#helpersNamespaceDeclarations}} -} -{{/helpersNamespaceDeclarations}} +} // namespace {{helpersNamespace}} -#endif // {{prefix}}Helpers_H_ \ No newline at end of file +#endif // {{prefix}}Helpers_H_ diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/helpers-source.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/helpers-source.mustache index 82b4e2d81ef6..214086354d51 100644 --- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/helpers-source.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/helpers-source.mustache @@ -1,32 +1,74 @@ {{>licenseInfo}} #include "{{prefix}}Helpers.h" +#include -{{#helpersNamespaceDeclarations}} -namespace {{this}} { -{{/helpersNamespaceDeclarations}} +namespace {{helpersNamespace}} +{ +const std::regex regexRfc3339_date(R"(^(\d{4})\-(\d{2})\-(\d{2})$)"); +const std::regex regexRfc3339_date_time( + R"(^(\d{4})\-(\d{2})\-(\d{2})[Tt](\d{2}):(\d{2}):(\d{2})(\.\d+)?([Zz]|([\+\-])(\d{2}):(\d{2}))$)" +); + + +namespace +{ + // Determine if given year is a leap year + // See RFC 3339, Appendix C https://tools.ietf.org/html/rfc3339#appendix-C + bool isLeapYear(const uint16_t year) { + return (year % 4 == 0) && ((year % 100 != 0) || (year % 400 == 0)); + } + + bool validateDateValues(const uint16_t year, const uint16_t month, const uint16_t day) { + return !( + (month == 0 || month > 12) + || (day == 0) + || (month == 2 && day > (28 + (isLeapYear(year) ? 1 : 0))) + || (month <= 7 && day > (30 + month % 2)) + || (month >= 8 && day > (31 - month % 2)) + ); + } + + bool validateTimeValues(const uint16_t hours, const uint16_t minutes, const uint16_t seconds) { + return (hours <= 23) && (minutes <= 59) && (seconds <= 60); + } +} + +bool validateRfc3339_date(const std::string& str) { + std::smatch match; + const bool found = std::regex_search(str, match, regexRfc3339_date); + return found && validateDateValues(std::stoi(match[1]), std::stoi(match[2]), std::stoi(match[3])); +} + +bool validateRfc3339_date_time(const std::string& str) { + std::smatch match; + const bool found = std::regex_search(str, match, regexRfc3339_date_time); + return found + && validateDateValues(std::stoi(match[1]), std::stoi(match[2]), std::stoi(match[3])) + && validateTimeValues(std::stoi(match[4]), std::stoi(match[5]), std::stoi(match[6])); +} std::string toStringValue(const std::string &value){ return std::string(value); } -std::string toStringValue(const int32_t &value){ +std::string toStringValue(const int32_t value){ return std::to_string(value); } -std::string toStringValue(const int64_t &value){ +std::string toStringValue(const int64_t value){ return std::to_string(value); } -std::string toStringValue(const bool &value){ - return value?std::string("true"):std::string("false"); +std::string toStringValue(const bool value){ + return value ? std::string("true") : std::string("false"); } -std::string toStringValue(const float &value){ +std::string toStringValue(const float value){ return std::to_string(value); } -std::string toStringValue(const double &value){ +std::string toStringValue(const double value){ return std::to_string(value); } @@ -56,9 +98,15 @@ bool fromStringValue(const std::string &inStr, int64_t &value){ } bool fromStringValue(const std::string &inStr, bool &value){ - bool result = true; - inStr == "true"?value = true: inStr == "false"?value = false: result = false; - return result; + if (inStr == "true") { + value = true; + return true; + } + if (inStr == "false") { + value = false; + return true; + } + return false; } bool fromStringValue(const std::string &inStr, float &value){ @@ -81,6 +129,4 @@ bool fromStringValue(const std::string &inStr, double &value){ return true; } -{{#helpersNamespaceDeclarations}} -} -{{/helpersNamespaceDeclarations}} \ No newline at end of file +} // namespace {{helpersNamespace}} diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-header.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-header.mustache index c16fdbb09467..cb6d8d98ee06 100644 --- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-header.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-header.mustache @@ -13,9 +13,8 @@ {{/imports}} #include -{{#modelNamespaceDeclarations}} -namespace {{this}} { -{{/modelNamespaceDeclarations}} +namespace {{modelNamespace}} +{ /// /// {{description}} @@ -24,7 +23,7 @@ class {{declspec}} {{classname}} { public: {{classname}}(); - virtual ~{{classname}}(); + virtual ~{{classname}}() = default; {{#isEnum}}{{#allowableValues}} enum class e{{classname}} { // To have a valid default value. @@ -35,7 +34,20 @@ public: {{{name}}}{{^-last}}, {{/-last}} {{/enumVars}} };{{/allowableValues}}{{/isEnum}} - void validate(); + + /// + /// Validate the current data in the model. Throws a ValidationException on failure. + /// + void validate() const; + + /// + /// Validate the current data in the model. Returns false on error and writes an error + /// message into the given stringstream. + /// + bool validate(std::stringstream& msg) const; + + bool operator==(const {{classname}}& rhs) const; + bool operator!=(const {{classname}}& rhs) const; ///////////////////////////////////////////// /// {{classname}} members @@ -44,7 +56,7 @@ public: /// /// {{description}} /// - {{{dataType}}}{{#isContainer}}&{{/isContainer}} {{getter}}(){{^isContainer}} const{{/isContainer}}; + {{{dataType}}} {{getter}}() const; void {{setter}}({{{dataType}}} const{{^isPrimitiveType}}&{{/isPrimitiveType}} value);{{^required}} bool {{nameInCamelCase}}IsSet() const; void unset{{name}}();{{/required}} @@ -65,11 +77,12 @@ protected: {{#isEnum}} {{classname}}::e{{classname}} m_value = {{classname}}::e{{classname}}::INVALID_VALUE_OPENAPI_GENERATED; {{/isEnum}} + + // Helper overload for validate. Used when one model stores another model and calls it's validate. + bool validate(std::stringstream& msg, const std::string& pathPrefix) const; }; -{{#modelNamespaceDeclarations}} -} -{{/modelNamespaceDeclarations}} +} // namespace {{modelNamespace}} #endif /* {{classname}}_H_ */ {{/model}} diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-source.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-source.mustache index d603dc2186e0..8ef6abf0e4c5 100644 --- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-source.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-source.mustache @@ -2,12 +2,12 @@ {{#models}}{{#model}} #include "{{classname}}.h" -{{#isEnum}}#include -#include {{/isEnum}} +#include "{{prefix}}Helpers.h" +{{#isEnum}}#include {{/isEnum}} +#include -{{#modelNamespaceDeclarations}} -namespace {{this}} { -{{/modelNamespaceDeclarations}} +namespace {{modelNamespace}} +{ {{classname}}::{{classname}}() { @@ -18,13 +18,69 @@ namespace {{this}} { {{/required}}{{/vars}} } -{{classname}}::~{{classname}}() +void {{classname}}::validate() const { + std::stringstream msg; + if (!validate(msg)) + { + throw {{helpersNamespace}}::ValidationException(msg.str()); + } } -void {{classname}}::validate() +bool {{classname}}::validate(std::stringstream& msg) const { - // TODO: implement validation + return validate(msg, ""); +} + +bool {{classname}}::validate(std::stringstream& msg, const std::string& pathPrefix) const +{ + bool success = true; + const std::string _pathPrefix = pathPrefix.empty() ? "{{classname}}" : pathPrefix; + + {{#isEnum}}{{! Special case for enum types }} + if (m_value == {{classname}}::e{{classname}}::INVALID_VALUE_OPENAPI_GENERATED) + { + success = false; + msg << _pathPrefix << ": has no value;"; + } + {{/isEnum}} + {{^isEnum}} + {{#vars}} + {{#isArray}} {{! Always generate validation body for array types }} + {{^required}}if ({{nameInCamelCase}}IsSet()){{/required}} + {{#required}}/* {{name}} */ {{/required}}{ + const {{{dataType}}}& value = m_{{name}}; + const std::string currentValuePath = _pathPrefix + ".{{nameInCamelCase}}"; + {{> model-validation-body }} + } + {{/isArray}}{{^isArray}}{{#hasValidation}} {{! Only generate validation if necessary }} + {{^required}}if ({{nameInCamelCase}}IsSet()){{/required}} + {{#required}}/* {{name}} */ {{/required}}{ + const {{{dataType}}}& value = m_{{name}}; + const std::string currentValuePath = _pathPrefix + ".{{nameInCamelCase}}"; + {{> model-validation-body }} + } + {{/hasValidation}}{{/isArray}} + {{/vars}} + {{/isEnum}} + + return success; +} + +bool {{classname}}::operator==(const {{classname}}& rhs) const +{ + return + {{#isEnum}}getValue() == rhs.getValue(){{/isEnum}} + {{^isEnum}}{{#vars}} + {{#required}}({{getter}}() == rhs.{{getter}}()){{/required}} + {{^required}}((!{{nameInCamelCase}}IsSet() && !rhs.{{nameInCamelCase}}IsSet()) || ({{nameInCamelCase}}IsSet() && rhs.{{nameInCamelCase}}IsSet() && {{getter}}() == rhs.{{getter}}())){{/required}}{{^-last}} &&{{/-last}} + {{/vars}}{{/isEnum}} + ; +} + +bool {{classname}}::operator!=(const {{classname}}& rhs) const +{ + return !(*this == rhs); } void to_json(nlohmann::json& j, const {{classname}}& o) @@ -74,7 +130,7 @@ void from_json(const nlohmann::json& j, {{classname}}& o) {{/enumVars}}{{/allowableValues}}{{/isEnum}} } -{{#vars}}{{{dataType}}}{{#isContainer}}&{{/isContainer}} {{classname}}::{{getter}}(){{^isContainer}} const{{/isContainer}} +{{#vars}}{{{dataType}}} {{classname}}::{{getter}}() const { return m_{{name}}; } @@ -102,9 +158,7 @@ void {{classname}}::setValue({{classname}}::e{{classname}} value) m_value = value; }{{/isEnum}} -{{#modelNamespaceDeclarations}} -} -{{/modelNamespaceDeclarations}} +} // namespace {{modelNamespace}} {{/model}} {{/models}} diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-struct-header.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-struct-header.mustache index bcc64257e409..be0ea874da8e 100644 --- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-struct-header.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-struct-header.mustache @@ -14,9 +14,8 @@ #include {{#hasOptional}}#include {{/hasOptional}} -{{#modelNamespaceDeclarations}} -namespace {{this}} { -{{/modelNamespaceDeclarations}} +namespace {{modelNamespace}} +{ struct {{classname}} { @@ -34,9 +33,9 @@ struct {{classname}} void to_json(nlohmann::json& j, const {{classname}}& o); void from_json(const nlohmann::json& j, {{classname}}& o); -{{#modelNamespaceDeclarations}} -} // {{this}} -{{/modelNamespaceDeclarations}} + +} // namespace {{modelNamespace}} + #endif /* {{classname}}_H_ */ {{/model}} diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-struct-source.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-struct-source.mustache index 52d3526e867a..987926b7c4eb 100644 --- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-struct-source.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-struct-source.mustache @@ -3,9 +3,8 @@ #include "{{classname}}.h" -{{#modelNamespaceDeclarations}} -namespace {{this}} { -{{/modelNamespaceDeclarations}} +namespace {{modelNamespace}} +{ nlohmann::json {{classname}}::to_json() const { @@ -51,9 +50,7 @@ void from_json(const nlohmann::json& j, {{classname}}& o) {{/vars}} } -{{#modelNamespaceDeclarations}} -} // {{this}} -{{/modelNamespaceDeclarations}} +} // namespace {{modelNamespace}} {{/model}} {{/models}} diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-validation-body.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-validation-body.mustache new file mode 100644 index 000000000000..ef92f2c3fbd4 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-validation-body.mustache @@ -0,0 +1,124 @@ +{{! +This template generates the validation logic for a model. +This template file calls itself recursively for arrays. +}} +{{! Check for eunm properties that are their own schema }} +{{! These are in their own class with a validate function, the way to check for this is quite a hack +since isEnum, isString and isModel are all false. }} + {{^isString}}{{#allowableValues.enumVars.0.value}} + success = value.validate(msg, currentValuePath) && success; + {{/allowableValues.enumVars.0.value}}{{/isString}} + {{#isModel}}success = value.validate(msg, currentValuePath + ".{{nameInCamelCase}}") && success;{{/isModel}} +{{! Date validation }} + {{#isDate}} + if (!{{helpersNamespace}}::validateRfc3339_date(value)) + { + success = false; + msg << currentValuePath << ": must be a valid RFC 3339 date-full string;"; + } + {{/isDate}} +{{! Date-Time validation }} + {{#isDateTime}} + if (!{{helpersNamespace}}::validateRfc3339_date_time(value)) + { + success = false; + msg << currentValuePath << ": must be a valid RFC 3339 date-time string;"; + } + {{/isDateTime}} +{{! string validation }} + {{#isString}} + {{#minLength}} + if (value.length() < {{minLength}}) + { + success = false; + msg << currentValuePath << ": must be at least {{minLength}} characters long;"; + } + {{/minLength}} + {{#maxLength}} + if (value.length() > {{maxLength}}) + { + success = false; + msg << currentValuePath << ": must be at most {{maxLength}} characters long;"; + } + {{/maxLength}} +{{! +TODO validate regex of string using pattern variable. This has two challenges + - Is compatibility with the given regex pattern guaranteed? + - Creating the std::regex on every validation would be rather slow. Ideally one would + initialize them for the class once as a static const and use them. +}} +{{! string encoded enum validation }} + {{#isEnum}} + {{#allowableValues}} + if ({{#enumVars}} + value != "{{value}}"{{^-last}} &&{{/-last}}{{/enumVars}} + ) { + success = false; + msg << currentValuePath << ": has invalid value \"" << value << "\";"; + } + {{/allowableValues}} + {{/isEnum}} + {{/isString}} +{{! numeric validation }} + {{#isNumeric}} + {{#minimum}} + if (value <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{#isFloat}}static_cast({{/isFloat}}{{minimum}}{{#isFloat}}){{/isFloat}}{{#isLong}}ll{{/isLong}}) + { + success = false; + msg << currentValuePath << ": must be greater than{{^exclusiveMinimum}} or equal to{{/exclusiveMinimum}} {{minimum}};"; + } + {{/minimum}} + {{#maximum}} + if (value >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{#isFloat}}static_cast({{/isFloat}}{{maximum}}{{#isFloat}}){{/isFloat}}{{#isLong}}ll{{/isLong}}) + { + success = false; + msg << currentValuePath << ": must be less than{{^exclusiveMaximum}} or equal to{{/exclusiveMaximum}} {{maximum}};"; + } + {{/maximum}} + {{#multipleOf}} + {{#isInteger}}if (value % {{multipleOf}}{{#isLong}}ll{{/isLong}} != 0){{/isInteger}} + {{#isFloat}}if (std::fmod(value, static_cast({{multipleOf}})) != 0){{/isFloat}} + {{#isDouble}}if (std::fmod(value, {{multipleOf}}) != 0){{/isDouble}} + { + success = false; + msg << currentValuePath << ": must be a multiple of {{multipleOf}};"; + } + {{/multipleOf}} + {{/isNumeric}} +{{! Array validation }} + {{#isArray}} + {{#minItems}} + if (value.size() < {{minItems}}) + { + success = false; + msg << currentValuePath << ": must have at least {{minItems}} elements;"; + } + {{/minItems}} + {{#maxItems}} + if (value.size() > {{maxItems}}) + { + success = false; + msg << currentValuePath << ": must have at most {{maxItems}} elements;"; + } + {{/maxItems}} + {{#uniqueItems}} + if (!{{helpersNamespace}}::hasOnlyUniqueItems(value)) + { + success = false; + msg << currentValuePath << ": may not contain the same item more than once;"; + } + {{/uniqueItems}} + { // Recursive validation of array elements + const std::string oldValuePath = currentValuePath; + int i = 0; + {{! the element var has the same name as the vector, so that the recursive template works - what a wonderful hack }} + for (const {{{items.dataType}}}& value : value) + { {{! and I do a similar hack with currentValuePath... }} + const std::string currentValuePath = oldValuePath + "[" + std::to_string(i) + "]"; + {{#items}} + {{> model-validation-body }} {{! Recursively apply template to array - this is where things will probbaly go wrong }} + {{/items}} + i++; + } + } + {{/isArray}} diff --git a/samples/server/petstore/cpp-pistache/.openapi-generator/VERSION b/samples/server/petstore/cpp-pistache/.openapi-generator/VERSION index c30f0ec2be7f..d509cc92aa80 100644 --- a/samples/server/petstore/cpp-pistache/.openapi-generator/VERSION +++ b/samples/server/petstore/cpp-pistache/.openapi-generator/VERSION @@ -1 +1 @@ -5.1.0-SNAPSHOT \ No newline at end of file +5.1.1-SNAPSHOT \ No newline at end of file diff --git a/samples/server/petstore/cpp-pistache/api/PetApi.cpp b/samples/server/petstore/cpp-pistache/api/PetApi.cpp index 80e15bd68625..7b3641599eef 100644 --- a/samples/server/petstore/cpp-pistache/api/PetApi.cpp +++ b/samples/server/petstore/cpp-pistache/api/PetApi.cpp @@ -13,16 +13,17 @@ #include "PetApi.h" #include "Helpers.h" -namespace org { -namespace openapitools { -namespace server { -namespace api { +namespace org::openapitools::server::api +{ using namespace org::openapitools::server::helpers; using namespace org::openapitools::server::model; -PetApi::PetApi(std::shared_ptr rtr) { - router = rtr; +const std::string PetApi::base = "/v2"; + +PetApi::PetApi(const std::shared_ptr& rtr) + : router(rtr) +{ } void PetApi::init() { @@ -45,30 +46,58 @@ void PetApi::setupRoutes() { router->addCustomHandler(Routes::bind(&PetApi::pet_api_default_handler, this)); } +std::pair PetApi::handleParsingException(const std::exception& ex) const noexcept +{ + try { + throw ex; + } catch (nlohmann::detail::exception &e) { + return std::make_pair(Pistache::Http::Code::Bad_Request, e.what()); + } catch (org::openapitools::server::helpers::ValidationException &e) { + return std::make_pair(Pistache::Http::Code::Bad_Request, e.what()); + } +} + +std::pair PetApi::handleOperationException(const std::exception& ex) const noexcept +{ + return std::make_pair(Pistache::Http::Code::Internal_Server_Error, ex.what()); +} + void PetApi::add_pet_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) { + try { + // Getting the body param Pet body; try { - nlohmann::json::parse(request.body()).get_to(body); - this->add_pet(body, response); - } catch (nlohmann::detail::exception &e) { - //send a 400 error - response.send(Pistache::Http::Code::Bad_Request, e.what()); + nlohmann::json::parse(request.body()).get_to(body); + body.validate(); + } catch (std::exception &e) { + const std::pair errorInfo = this->handleParsingException(e); + response.send(errorInfo.first, errorInfo.second); return; + } + + try { + this->add_pet(body, response); } catch (Pistache::Http::HttpError &e) { response.send(static_cast(e.code()), e.what()); return; } catch (std::exception &e) { - //send a 500 error - response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + const std::pair errorInfo = this->handleOperationException(e); + response.send(errorInfo.first, errorInfo.second); return; } + } catch (std::exception &e) { + response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + } + } void PetApi::delete_pet_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) { + try { + // Getting the path params auto petId = request.param(":petId").as(); @@ -76,22 +105,24 @@ void PetApi::delete_pet_handler(const Pistache::Rest::Request &request, Pistache auto apiKey = request.headers().tryGetRaw("api_key"); try { - this->delete_pet(petId, apiKey, response); - } catch (nlohmann::detail::exception &e) { - //send a 400 error - response.send(Pistache::Http::Code::Bad_Request, e.what()); - return; + this->delete_pet(petId, apiKey, response); } catch (Pistache::Http::HttpError &e) { response.send(static_cast(e.code()), e.what()); return; } catch (std::exception &e) { - //send a 500 error - response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + const std::pair errorInfo = this->handleOperationException(e); + response.send(errorInfo.first, errorInfo.second); return; } + } catch (std::exception &e) { + response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + } + } void PetApi::find_pets_by_status_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) { + try { + // Getting the query params auto statusQuery = request.query().get("status"); @@ -104,22 +135,24 @@ void PetApi::find_pets_by_status_handler(const Pistache::Rest::Request &request, } try { - this->find_pets_by_status(status, response); - } catch (nlohmann::detail::exception &e) { - //send a 400 error - response.send(Pistache::Http::Code::Bad_Request, e.what()); - return; + this->find_pets_by_status(status, response); } catch (Pistache::Http::HttpError &e) { response.send(static_cast(e.code()), e.what()); return; } catch (std::exception &e) { - //send a 500 error - response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + const std::pair errorInfo = this->handleOperationException(e); + response.send(errorInfo.first, errorInfo.second); return; } + } catch (std::exception &e) { + response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + } + } void PetApi::find_pets_by_tags_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) { + try { + // Getting the query params auto tagsQuery = request.query().get("tags"); @@ -132,105 +165,118 @@ void PetApi::find_pets_by_tags_handler(const Pistache::Rest::Request &request, P } try { - this->find_pets_by_tags(tags, response); - } catch (nlohmann::detail::exception &e) { - //send a 400 error - response.send(Pistache::Http::Code::Bad_Request, e.what()); - return; + this->find_pets_by_tags(tags, response); } catch (Pistache::Http::HttpError &e) { response.send(static_cast(e.code()), e.what()); return; } catch (std::exception &e) { - //send a 500 error - response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + const std::pair errorInfo = this->handleOperationException(e); + response.send(errorInfo.first, errorInfo.second); return; } + } catch (std::exception &e) { + response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + } + } void PetApi::get_pet_by_id_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) { + try { + // Getting the path params auto petId = request.param(":petId").as(); try { - this->get_pet_by_id(petId, response); - } catch (nlohmann::detail::exception &e) { - //send a 400 error - response.send(Pistache::Http::Code::Bad_Request, e.what()); - return; + this->get_pet_by_id(petId, response); } catch (Pistache::Http::HttpError &e) { response.send(static_cast(e.code()), e.what()); return; } catch (std::exception &e) { - //send a 500 error - response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + const std::pair errorInfo = this->handleOperationException(e); + response.send(errorInfo.first, errorInfo.second); return; } + } catch (std::exception &e) { + response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + } + } void PetApi::update_pet_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) { + try { + // Getting the body param Pet body; try { - nlohmann::json::parse(request.body()).get_to(body); - this->update_pet(body, response); - } catch (nlohmann::detail::exception &e) { - //send a 400 error - response.send(Pistache::Http::Code::Bad_Request, e.what()); + nlohmann::json::parse(request.body()).get_to(body); + body.validate(); + } catch (std::exception &e) { + const std::pair errorInfo = this->handleParsingException(e); + response.send(errorInfo.first, errorInfo.second); return; + } + + try { + this->update_pet(body, response); } catch (Pistache::Http::HttpError &e) { response.send(static_cast(e.code()), e.what()); return; } catch (std::exception &e) { - //send a 500 error - response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + const std::pair errorInfo = this->handleOperationException(e); + response.send(errorInfo.first, errorInfo.second); return; } + } catch (std::exception &e) { + response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + } + } void PetApi::update_pet_with_form_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) { + try { + try { this->update_pet_with_form(request, response); - } catch (nlohmann::detail::exception &e) { - //send a 400 error - response.send(Pistache::Http::Code::Bad_Request, e.what()); - return; } catch (Pistache::Http::HttpError &e) { response.send(static_cast(e.code()), e.what()); return; } catch (std::exception &e) { - //send a 500 error - response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + const std::pair errorInfo = this->handleOperationException(e); + response.send(errorInfo.first, errorInfo.second); return; } + } catch (std::exception &e) { + response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + } + } void PetApi::upload_file_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) { + try { + try { this->upload_file(request, response); - } catch (nlohmann::detail::exception &e) { - //send a 400 error - response.send(Pistache::Http::Code::Bad_Request, e.what()); - return; } catch (Pistache::Http::HttpError &e) { response.send(static_cast(e.code()), e.what()); return; } catch (std::exception &e) { - //send a 500 error - response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + const std::pair errorInfo = this->handleOperationException(e); + response.send(errorInfo.first, errorInfo.second); return; } + } catch (std::exception &e) { + response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + } + } void PetApi::pet_api_default_handler(const Pistache::Rest::Request &, Pistache::Http::ResponseWriter response) { response.send(Pistache::Http::Code::Not_Found, "The requested method does not exist"); } -} -} -} -} +} // namespace org::openapitools::server::api diff --git a/samples/server/petstore/cpp-pistache/api/PetApi.h b/samples/server/petstore/cpp-pistache/api/PetApi.h index d991d13abaed..f689a0675e15 100644 --- a/samples/server/petstore/cpp-pistache/api/PetApi.h +++ b/samples/server/petstore/cpp-pistache/api/PetApi.h @@ -24,25 +24,22 @@ #include #include +#include #include "ApiResponse.h" #include "Pet.h" #include -namespace org { -namespace openapitools { -namespace server { -namespace api { - -using namespace org::openapitools::server::model; +namespace org::openapitools::server::api +{ class PetApi { public: - PetApi(std::shared_ptr); - virtual ~PetApi() {} + explicit PetApi(const std::shared_ptr& rtr); + virtual ~PetApi() = default; void init(); - const std::string base = "/v2"; + static const std::string base; private: void setupRoutes(); @@ -57,7 +54,19 @@ class PetApi { void upload_file_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response); void pet_api_default_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response); - std::shared_ptr router; + const std::shared_ptr router; + + /// + /// Helper function to handle unexpected Exceptions during Parameter parsing and validation. + /// May be overriden to return custom error formats. + /// + virtual std::pair handleParsingException(const std::exception& ex) const noexcept; + + /// + /// Helper function to handle unexpected Exceptions during processing of the request in handler functions. + /// May be overriden to return custom error formats. + /// + virtual std::pair handleOperationException(const std::exception& ex) const noexcept; /// /// Add a new pet to the store @@ -66,8 +75,7 @@ class PetApi { /// /// /// Pet object that needs to be added to the store - virtual void add_pet(const Pet &body, Pistache::Http::ResponseWriter &response) = 0; - + virtual void add_pet(const org::openapitools::server::model::Pet &body, Pistache::Http::ResponseWriter &response) = 0; /// /// Deletes a pet /// @@ -77,7 +85,6 @@ class PetApi { /// Pet id to delete /// (optional, default to "") virtual void delete_pet(const int64_t &petId, const Pistache::Optional &apiKey, Pistache::Http::ResponseWriter &response) = 0; - /// /// Finds Pets by status /// @@ -86,7 +93,6 @@ class PetApi { /// /// Status values that need to be considered for filter virtual void find_pets_by_status(const Pistache::Optional> &status, Pistache::Http::ResponseWriter &response) = 0; - /// /// Finds Pets by tags /// @@ -95,7 +101,6 @@ class PetApi { /// /// Tags to filter by virtual void find_pets_by_tags(const Pistache::Optional> &tags, Pistache::Http::ResponseWriter &response) = 0; - /// /// Find pet by ID /// @@ -104,7 +109,6 @@ class PetApi { /// /// ID of pet to return virtual void get_pet_by_id(const int64_t &petId, Pistache::Http::ResponseWriter &response) = 0; - /// /// Update an existing pet /// @@ -112,8 +116,7 @@ class PetApi { /// /// /// Pet object that needs to be added to the store - virtual void update_pet(const Pet &body, Pistache::Http::ResponseWriter &response) = 0; - + virtual void update_pet(const org::openapitools::server::model::Pet &body, Pistache::Http::ResponseWriter &response) = 0; /// /// Updates a pet in the store with form data /// @@ -121,7 +124,6 @@ class PetApi { /// /// virtual void update_pet_with_form(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter &response) = 0; - /// /// uploads an image /// @@ -132,10 +134,7 @@ class PetApi { }; -} -} -} -} +} // namespace org::openapitools::server::api #endif /* PetApi_H_ */ diff --git a/samples/server/petstore/cpp-pistache/api/StoreApi.cpp b/samples/server/petstore/cpp-pistache/api/StoreApi.cpp index e3f1038f80a4..ea0c0e1793b8 100644 --- a/samples/server/petstore/cpp-pistache/api/StoreApi.cpp +++ b/samples/server/petstore/cpp-pistache/api/StoreApi.cpp @@ -13,16 +13,17 @@ #include "StoreApi.h" #include "Helpers.h" -namespace org { -namespace openapitools { -namespace server { -namespace api { +namespace org::openapitools::server::api +{ using namespace org::openapitools::server::helpers; using namespace org::openapitools::server::model; -StoreApi::StoreApi(std::shared_ptr rtr) { - router = rtr; +const std::string StoreApi::base = "/v2"; + +StoreApi::StoreApi(const std::shared_ptr& rtr) + : router(rtr) +{ } void StoreApi::init() { @@ -41,94 +42,123 @@ void StoreApi::setupRoutes() { router->addCustomHandler(Routes::bind(&StoreApi::store_api_default_handler, this)); } +std::pair StoreApi::handleParsingException(const std::exception& ex) const noexcept +{ + try { + throw ex; + } catch (nlohmann::detail::exception &e) { + return std::make_pair(Pistache::Http::Code::Bad_Request, e.what()); + } catch (org::openapitools::server::helpers::ValidationException &e) { + return std::make_pair(Pistache::Http::Code::Bad_Request, e.what()); + } +} + +std::pair StoreApi::handleOperationException(const std::exception& ex) const noexcept +{ + return std::make_pair(Pistache::Http::Code::Internal_Server_Error, ex.what()); +} + void StoreApi::delete_order_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) { + try { + // Getting the path params auto orderId = request.param(":orderId").as(); try { - this->delete_order(orderId, response); - } catch (nlohmann::detail::exception &e) { - //send a 400 error - response.send(Pistache::Http::Code::Bad_Request, e.what()); - return; + this->delete_order(orderId, response); } catch (Pistache::Http::HttpError &e) { response.send(static_cast(e.code()), e.what()); return; } catch (std::exception &e) { - //send a 500 error - response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + const std::pair errorInfo = this->handleOperationException(e); + response.send(errorInfo.first, errorInfo.second); return; } + } catch (std::exception &e) { + response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + } + } void StoreApi::get_inventory_handler(const Pistache::Rest::Request &, Pistache::Http::ResponseWriter response) { + try { + try { - this->get_inventory(response); - } catch (nlohmann::detail::exception &e) { - //send a 400 error - response.send(Pistache::Http::Code::Bad_Request, e.what()); - return; + this->get_inventory(response); } catch (Pistache::Http::HttpError &e) { response.send(static_cast(e.code()), e.what()); return; } catch (std::exception &e) { - //send a 500 error - response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + const std::pair errorInfo = this->handleOperationException(e); + response.send(errorInfo.first, errorInfo.second); return; } + } catch (std::exception &e) { + response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + } + } void StoreApi::get_order_by_id_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) { + try { + // Getting the path params auto orderId = request.param(":orderId").as(); try { - this->get_order_by_id(orderId, response); - } catch (nlohmann::detail::exception &e) { - //send a 400 error - response.send(Pistache::Http::Code::Bad_Request, e.what()); - return; + this->get_order_by_id(orderId, response); } catch (Pistache::Http::HttpError &e) { response.send(static_cast(e.code()), e.what()); return; } catch (std::exception &e) { - //send a 500 error - response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + const std::pair errorInfo = this->handleOperationException(e); + response.send(errorInfo.first, errorInfo.second); return; } + } catch (std::exception &e) { + response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + } + } void StoreApi::place_order_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) { + try { + // Getting the body param Order body; try { - nlohmann::json::parse(request.body()).get_to(body); - this->place_order(body, response); - } catch (nlohmann::detail::exception &e) { - //send a 400 error - response.send(Pistache::Http::Code::Bad_Request, e.what()); + nlohmann::json::parse(request.body()).get_to(body); + body.validate(); + } catch (std::exception &e) { + const std::pair errorInfo = this->handleParsingException(e); + response.send(errorInfo.first, errorInfo.second); return; + } + + try { + this->place_order(body, response); } catch (Pistache::Http::HttpError &e) { response.send(static_cast(e.code()), e.what()); return; } catch (std::exception &e) { - //send a 500 error - response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + const std::pair errorInfo = this->handleOperationException(e); + response.send(errorInfo.first, errorInfo.second); return; } + } catch (std::exception &e) { + response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + } + } void StoreApi::store_api_default_handler(const Pistache::Rest::Request &, Pistache::Http::ResponseWriter response) { response.send(Pistache::Http::Code::Not_Found, "The requested method does not exist"); } -} -} -} -} +} // namespace org::openapitools::server::api diff --git a/samples/server/petstore/cpp-pistache/api/StoreApi.h b/samples/server/petstore/cpp-pistache/api/StoreApi.h index f69875c4678d..6eb224387479 100644 --- a/samples/server/petstore/cpp-pistache/api/StoreApi.h +++ b/samples/server/petstore/cpp-pistache/api/StoreApi.h @@ -24,25 +24,22 @@ #include #include +#include #include "Order.h" #include #include -namespace org { -namespace openapitools { -namespace server { -namespace api { - -using namespace org::openapitools::server::model; +namespace org::openapitools::server::api +{ class StoreApi { public: - StoreApi(std::shared_ptr); - virtual ~StoreApi() {} + explicit StoreApi(const std::shared_ptr& rtr); + virtual ~StoreApi() = default; void init(); - const std::string base = "/v2"; + static const std::string base; private: void setupRoutes(); @@ -53,7 +50,19 @@ class StoreApi { void place_order_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response); void store_api_default_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response); - std::shared_ptr router; + const std::shared_ptr router; + + /// + /// Helper function to handle unexpected Exceptions during Parameter parsing and validation. + /// May be overriden to return custom error formats. + /// + virtual std::pair handleParsingException(const std::exception& ex) const noexcept; + + /// + /// Helper function to handle unexpected Exceptions during processing of the request in handler functions. + /// May be overriden to return custom error formats. + /// + virtual std::pair handleOperationException(const std::exception& ex) const noexcept; /// /// Delete purchase order by ID @@ -63,7 +72,6 @@ class StoreApi { /// /// ID of the order that needs to be deleted virtual void delete_order(const std::string &orderId, Pistache::Http::ResponseWriter &response) = 0; - /// /// Returns pet inventories by status /// @@ -71,7 +79,6 @@ class StoreApi { /// Returns a map of status codes to quantities /// virtual void get_inventory(Pistache::Http::ResponseWriter &response) = 0; - /// /// Find purchase order by ID /// @@ -80,7 +87,6 @@ class StoreApi { /// /// ID of pet that needs to be fetched virtual void get_order_by_id(const int64_t &orderId, Pistache::Http::ResponseWriter &response) = 0; - /// /// Place an order for a pet /// @@ -88,14 +94,11 @@ class StoreApi { /// /// /// order placed for purchasing the pet - virtual void place_order(const Order &body, Pistache::Http::ResponseWriter &response) = 0; + virtual void place_order(const org::openapitools::server::model::Order &body, Pistache::Http::ResponseWriter &response) = 0; }; -} -} -} -} +} // namespace org::openapitools::server::api #endif /* StoreApi_H_ */ diff --git a/samples/server/petstore/cpp-pistache/api/UserApi.cpp b/samples/server/petstore/cpp-pistache/api/UserApi.cpp index 93d275611d71..94903581dc4d 100644 --- a/samples/server/petstore/cpp-pistache/api/UserApi.cpp +++ b/samples/server/petstore/cpp-pistache/api/UserApi.cpp @@ -13,16 +13,17 @@ #include "UserApi.h" #include "Helpers.h" -namespace org { -namespace openapitools { -namespace server { -namespace api { +namespace org::openapitools::server::api +{ using namespace org::openapitools::server::helpers; using namespace org::openapitools::server::model; -UserApi::UserApi(std::shared_ptr rtr) { - router = rtr; +const std::string UserApi::base = "/v2"; + +UserApi::UserApi(const std::shared_ptr& rtr) + : router(rtr) +{ } void UserApi::init() { @@ -45,114 +46,166 @@ void UserApi::setupRoutes() { router->addCustomHandler(Routes::bind(&UserApi::user_api_default_handler, this)); } +std::pair UserApi::handleParsingException(const std::exception& ex) const noexcept +{ + try { + throw ex; + } catch (nlohmann::detail::exception &e) { + return std::make_pair(Pistache::Http::Code::Bad_Request, e.what()); + } catch (org::openapitools::server::helpers::ValidationException &e) { + return std::make_pair(Pistache::Http::Code::Bad_Request, e.what()); + } +} + +std::pair UserApi::handleOperationException(const std::exception& ex) const noexcept +{ + return std::make_pair(Pistache::Http::Code::Internal_Server_Error, ex.what()); +} + void UserApi::create_user_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) { + try { + // Getting the body param User body; try { - nlohmann::json::parse(request.body()).get_to(body); - this->create_user(body, response); - } catch (nlohmann::detail::exception &e) { - //send a 400 error - response.send(Pistache::Http::Code::Bad_Request, e.what()); + nlohmann::json::parse(request.body()).get_to(body); + body.validate(); + } catch (std::exception &e) { + const std::pair errorInfo = this->handleParsingException(e); + response.send(errorInfo.first, errorInfo.second); return; + } + + try { + this->create_user(body, response); } catch (Pistache::Http::HttpError &e) { response.send(static_cast(e.code()), e.what()); return; } catch (std::exception &e) { - //send a 500 error - response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + const std::pair errorInfo = this->handleOperationException(e); + response.send(errorInfo.first, errorInfo.second); return; } + } catch (std::exception &e) { + response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + } + } void UserApi::create_users_with_array_input_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) { + try { + // Getting the body param std::vector body; try { - nlohmann::json::parse(request.body()).get_to(body); - this->create_users_with_array_input(body, response); - } catch (nlohmann::detail::exception &e) { - //send a 400 error - response.send(Pistache::Http::Code::Bad_Request, e.what()); + nlohmann::json::parse(request.body()).get_to(body); + body.validate(); + } catch (std::exception &e) { + const std::pair errorInfo = this->handleParsingException(e); + response.send(errorInfo.first, errorInfo.second); return; + } + + try { + this->create_users_with_array_input(body, response); } catch (Pistache::Http::HttpError &e) { response.send(static_cast(e.code()), e.what()); return; } catch (std::exception &e) { - //send a 500 error - response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + const std::pair errorInfo = this->handleOperationException(e); + response.send(errorInfo.first, errorInfo.second); return; } + } catch (std::exception &e) { + response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + } + } void UserApi::create_users_with_list_input_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) { + try { + // Getting the body param std::vector body; try { - nlohmann::json::parse(request.body()).get_to(body); - this->create_users_with_list_input(body, response); - } catch (nlohmann::detail::exception &e) { - //send a 400 error - response.send(Pistache::Http::Code::Bad_Request, e.what()); + nlohmann::json::parse(request.body()).get_to(body); + body.validate(); + } catch (std::exception &e) { + const std::pair errorInfo = this->handleParsingException(e); + response.send(errorInfo.first, errorInfo.second); return; + } + + try { + this->create_users_with_list_input(body, response); } catch (Pistache::Http::HttpError &e) { response.send(static_cast(e.code()), e.what()); return; } catch (std::exception &e) { - //send a 500 error - response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + const std::pair errorInfo = this->handleOperationException(e); + response.send(errorInfo.first, errorInfo.second); return; } + } catch (std::exception &e) { + response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + } + } void UserApi::delete_user_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) { + try { + // Getting the path params auto username = request.param(":username").as(); try { - this->delete_user(username, response); - } catch (nlohmann::detail::exception &e) { - //send a 400 error - response.send(Pistache::Http::Code::Bad_Request, e.what()); - return; + this->delete_user(username, response); } catch (Pistache::Http::HttpError &e) { response.send(static_cast(e.code()), e.what()); return; } catch (std::exception &e) { - //send a 500 error - response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + const std::pair errorInfo = this->handleOperationException(e); + response.send(errorInfo.first, errorInfo.second); return; } + } catch (std::exception &e) { + response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + } + } void UserApi::get_user_by_name_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) { + try { + // Getting the path params auto username = request.param(":username").as(); try { - this->get_user_by_name(username, response); - } catch (nlohmann::detail::exception &e) { - //send a 400 error - response.send(Pistache::Http::Code::Bad_Request, e.what()); - return; + this->get_user_by_name(username, response); } catch (Pistache::Http::HttpError &e) { response.send(static_cast(e.code()), e.what()); return; } catch (std::exception &e) { - //send a 500 error - response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + const std::pair errorInfo = this->handleOperationException(e); + response.send(errorInfo.first, errorInfo.second); return; } + } catch (std::exception &e) { + response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + } + } void UserApi::login_user_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) { + try { + // Getting the query params auto usernameQuery = request.query().get("username"); @@ -173,40 +226,44 @@ void UserApi::login_user_handler(const Pistache::Rest::Request &request, Pistach } try { - this->login_user(username, password, response); - } catch (nlohmann::detail::exception &e) { - //send a 400 error - response.send(Pistache::Http::Code::Bad_Request, e.what()); - return; + this->login_user(username, password, response); } catch (Pistache::Http::HttpError &e) { response.send(static_cast(e.code()), e.what()); return; } catch (std::exception &e) { - //send a 500 error - response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + const std::pair errorInfo = this->handleOperationException(e); + response.send(errorInfo.first, errorInfo.second); return; } + } catch (std::exception &e) { + response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + } + } void UserApi::logout_user_handler(const Pistache::Rest::Request &, Pistache::Http::ResponseWriter response) { + try { + try { - this->logout_user(response); - } catch (nlohmann::detail::exception &e) { - //send a 400 error - response.send(Pistache::Http::Code::Bad_Request, e.what()); - return; + this->logout_user(response); } catch (Pistache::Http::HttpError &e) { response.send(static_cast(e.code()), e.what()); return; } catch (std::exception &e) { - //send a 500 error - response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + const std::pair errorInfo = this->handleOperationException(e); + response.send(errorInfo.first, errorInfo.second); return; } + } catch (std::exception &e) { + response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + } + } void UserApi::update_user_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) { + try { + // Getting the path params auto username = request.param(":username").as(); @@ -215,29 +272,34 @@ void UserApi::update_user_handler(const Pistache::Rest::Request &request, Pistac User body; try { - nlohmann::json::parse(request.body()).get_to(body); - this->update_user(username, body, response); - } catch (nlohmann::detail::exception &e) { - //send a 400 error - response.send(Pistache::Http::Code::Bad_Request, e.what()); + nlohmann::json::parse(request.body()).get_to(body); + body.validate(); + } catch (std::exception &e) { + const std::pair errorInfo = this->handleParsingException(e); + response.send(errorInfo.first, errorInfo.second); return; + } + + try { + this->update_user(username, body, response); } catch (Pistache::Http::HttpError &e) { response.send(static_cast(e.code()), e.what()); return; } catch (std::exception &e) { - //send a 500 error - response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + const std::pair errorInfo = this->handleOperationException(e); + response.send(errorInfo.first, errorInfo.second); return; } + } catch (std::exception &e) { + response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + } + } void UserApi::user_api_default_handler(const Pistache::Rest::Request &, Pistache::Http::ResponseWriter response) { response.send(Pistache::Http::Code::Not_Found, "The requested method does not exist"); } -} -} -} -} +} // namespace org::openapitools::server::api diff --git a/samples/server/petstore/cpp-pistache/api/UserApi.h b/samples/server/petstore/cpp-pistache/api/UserApi.h index 6c589979dbc9..003b6db4df41 100644 --- a/samples/server/petstore/cpp-pistache/api/UserApi.h +++ b/samples/server/petstore/cpp-pistache/api/UserApi.h @@ -24,25 +24,22 @@ #include #include +#include #include "User.h" #include #include -namespace org { -namespace openapitools { -namespace server { -namespace api { - -using namespace org::openapitools::server::model; +namespace org::openapitools::server::api +{ class UserApi { public: - UserApi(std::shared_ptr); - virtual ~UserApi() {} + explicit UserApi(const std::shared_ptr& rtr); + virtual ~UserApi() = default; void init(); - const std::string base = "/v2"; + static const std::string base; private: void setupRoutes(); @@ -57,7 +54,19 @@ class UserApi { void update_user_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response); void user_api_default_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response); - std::shared_ptr router; + const std::shared_ptr router; + + /// + /// Helper function to handle unexpected Exceptions during Parameter parsing and validation. + /// May be overriden to return custom error formats. + /// + virtual std::pair handleParsingException(const std::exception& ex) const noexcept; + + /// + /// Helper function to handle unexpected Exceptions during processing of the request in handler functions. + /// May be overriden to return custom error formats. + /// + virtual std::pair handleOperationException(const std::exception& ex) const noexcept; /// /// Create user @@ -66,8 +75,7 @@ class UserApi { /// This can only be done by the logged in user. /// /// Created user object - virtual void create_user(const User &body, Pistache::Http::ResponseWriter &response) = 0; - + virtual void create_user(const org::openapitools::server::model::User &body, Pistache::Http::ResponseWriter &response) = 0; /// /// Creates list of users with given input array /// @@ -76,7 +84,6 @@ class UserApi { /// /// List of user object virtual void create_users_with_array_input(const std::vector &body, Pistache::Http::ResponseWriter &response) = 0; - /// /// Creates list of users with given input array /// @@ -85,7 +92,6 @@ class UserApi { /// /// List of user object virtual void create_users_with_list_input(const std::vector &body, Pistache::Http::ResponseWriter &response) = 0; - /// /// Delete user /// @@ -94,7 +100,6 @@ class UserApi { /// /// The name that needs to be deleted virtual void delete_user(const std::string &username, Pistache::Http::ResponseWriter &response) = 0; - /// /// Get user by user name /// @@ -103,7 +108,6 @@ class UserApi { /// /// The name that needs to be fetched. Use user1 for testing. virtual void get_user_by_name(const std::string &username, Pistache::Http::ResponseWriter &response) = 0; - /// /// Logs user into the system /// @@ -113,7 +117,6 @@ class UserApi { /// The user name for login /// The password for login in clear text virtual void login_user(const Pistache::Optional &username, const Pistache::Optional &password, Pistache::Http::ResponseWriter &response) = 0; - /// /// Logs out current logged in user session /// @@ -121,7 +124,6 @@ class UserApi { /// /// virtual void logout_user(Pistache::Http::ResponseWriter &response) = 0; - /// /// Updated user /// @@ -130,14 +132,11 @@ class UserApi { /// /// name that need to be deleted /// Updated user object - virtual void update_user(const std::string &username, const User &body, Pistache::Http::ResponseWriter &response) = 0; + virtual void update_user(const std::string &username, const org::openapitools::server::model::User &body, Pistache::Http::ResponseWriter &response) = 0; }; -} -} -} -} +} // namespace org::openapitools::server::api #endif /* UserApi_H_ */ diff --git a/samples/server/petstore/cpp-pistache/impl/PetApiImpl.cpp b/samples/server/petstore/cpp-pistache/impl/PetApiImpl.cpp index 778117a18bbe..94b49b151e4e 100644 --- a/samples/server/petstore/cpp-pistache/impl/PetApiImpl.cpp +++ b/samples/server/petstore/cpp-pistache/impl/PetApiImpl.cpp @@ -19,9 +19,10 @@ namespace api { using namespace org::openapitools::server::model; -PetApiImpl::PetApiImpl(std::shared_ptr rtr) +PetApiImpl::PetApiImpl(const std::shared_ptr& rtr) : PetApi(rtr) - { } +{ +} void PetApiImpl::add_pet(const Pet &body, Pistache::Http::ResponseWriter &response) { response.send(Pistache::Http::Code::Ok, "Do some magic\n"); diff --git a/samples/server/petstore/cpp-pistache/impl/PetApiImpl.h b/samples/server/petstore/cpp-pistache/impl/PetApiImpl.h index 9e9f3d145baf..82c10b0a410c 100644 --- a/samples/server/petstore/cpp-pistache/impl/PetApiImpl.h +++ b/samples/server/petstore/cpp-pistache/impl/PetApiImpl.h @@ -33,17 +33,15 @@ #include "Pet.h" #include -namespace org { -namespace openapitools { -namespace server { -namespace api { +namespace org::openapitools::server::api +{ using namespace org::openapitools::server::model; class PetApiImpl : public org::openapitools::server::api::PetApi { public: - PetApiImpl(std::shared_ptr); - ~PetApiImpl() {} + explicit PetApiImpl(const std::shared_ptr& rtr); + ~PetApiImpl() override = default; void add_pet(const Pet &body, Pistache::Http::ResponseWriter &response); void delete_pet(const int64_t &petId, const Pistache::Optional &apiKey, Pistache::Http::ResponseWriter &response); @@ -56,11 +54,8 @@ class PetApiImpl : public org::openapitools::server::api::PetApi { }; -} -} -} -} +} // namespace org::openapitools::server::api -#endif \ No newline at end of file +#endif diff --git a/samples/server/petstore/cpp-pistache/impl/StoreApiImpl.cpp b/samples/server/petstore/cpp-pistache/impl/StoreApiImpl.cpp index ef164eb0543e..a746316b8039 100644 --- a/samples/server/petstore/cpp-pistache/impl/StoreApiImpl.cpp +++ b/samples/server/petstore/cpp-pistache/impl/StoreApiImpl.cpp @@ -19,9 +19,10 @@ namespace api { using namespace org::openapitools::server::model; -StoreApiImpl::StoreApiImpl(std::shared_ptr rtr) +StoreApiImpl::StoreApiImpl(const std::shared_ptr& rtr) : StoreApi(rtr) - { } +{ +} void StoreApiImpl::delete_order(const std::string &orderId, Pistache::Http::ResponseWriter &response) { response.send(Pistache::Http::Code::Ok, "Do some magic\n"); diff --git a/samples/server/petstore/cpp-pistache/impl/StoreApiImpl.h b/samples/server/petstore/cpp-pistache/impl/StoreApiImpl.h index c99372463184..c5dda64490f7 100644 --- a/samples/server/petstore/cpp-pistache/impl/StoreApiImpl.h +++ b/samples/server/petstore/cpp-pistache/impl/StoreApiImpl.h @@ -33,17 +33,15 @@ #include #include -namespace org { -namespace openapitools { -namespace server { -namespace api { +namespace org::openapitools::server::api +{ using namespace org::openapitools::server::model; class StoreApiImpl : public org::openapitools::server::api::StoreApi { public: - StoreApiImpl(std::shared_ptr); - ~StoreApiImpl() {} + explicit StoreApiImpl(const std::shared_ptr& rtr); + ~StoreApiImpl() override = default; void delete_order(const std::string &orderId, Pistache::Http::ResponseWriter &response); void get_inventory(Pistache::Http::ResponseWriter &response); @@ -52,11 +50,8 @@ class StoreApiImpl : public org::openapitools::server::api::StoreApi { }; -} -} -} -} +} // namespace org::openapitools::server::api -#endif \ No newline at end of file +#endif diff --git a/samples/server/petstore/cpp-pistache/impl/UserApiImpl.cpp b/samples/server/petstore/cpp-pistache/impl/UserApiImpl.cpp index 7163a560bd77..b477f053c5c8 100644 --- a/samples/server/petstore/cpp-pistache/impl/UserApiImpl.cpp +++ b/samples/server/petstore/cpp-pistache/impl/UserApiImpl.cpp @@ -19,9 +19,10 @@ namespace api { using namespace org::openapitools::server::model; -UserApiImpl::UserApiImpl(std::shared_ptr rtr) +UserApiImpl::UserApiImpl(const std::shared_ptr& rtr) : UserApi(rtr) - { } +{ +} void UserApiImpl::create_user(const User &body, Pistache::Http::ResponseWriter &response) { response.send(Pistache::Http::Code::Ok, "Do some magic\n"); diff --git a/samples/server/petstore/cpp-pistache/impl/UserApiImpl.h b/samples/server/petstore/cpp-pistache/impl/UserApiImpl.h index 8f22c4998894..856a30db5bb1 100644 --- a/samples/server/petstore/cpp-pistache/impl/UserApiImpl.h +++ b/samples/server/petstore/cpp-pistache/impl/UserApiImpl.h @@ -33,17 +33,15 @@ #include #include -namespace org { -namespace openapitools { -namespace server { -namespace api { +namespace org::openapitools::server::api +{ using namespace org::openapitools::server::model; class UserApiImpl : public org::openapitools::server::api::UserApi { public: - UserApiImpl(std::shared_ptr); - ~UserApiImpl() {} + explicit UserApiImpl(const std::shared_ptr& rtr); + ~UserApiImpl() override = default; void create_user(const User &body, Pistache::Http::ResponseWriter &response); void create_users_with_array_input(const std::vector &body, Pistache::Http::ResponseWriter &response); @@ -56,11 +54,8 @@ class UserApiImpl : public org::openapitools::server::api::UserApi { }; -} -} -} -} +} // namespace org::openapitools::server::api -#endif \ No newline at end of file +#endif diff --git a/samples/server/petstore/cpp-pistache/model/ApiResponse.cpp b/samples/server/petstore/cpp-pistache/model/ApiResponse.cpp index 4b9ca7419208..049f6c19d6d6 100644 --- a/samples/server/petstore/cpp-pistache/model/ApiResponse.cpp +++ b/samples/server/petstore/cpp-pistache/model/ApiResponse.cpp @@ -12,11 +12,12 @@ #include "ApiResponse.h" +#include "Helpers.h" -namespace org { -namespace openapitools { -namespace server { -namespace model { +#include + +namespace org::openapitools::server::model +{ ApiResponse::ApiResponse() { @@ -29,13 +30,52 @@ ApiResponse::ApiResponse() } -ApiResponse::~ApiResponse() +void ApiResponse::validate() const +{ + std::stringstream msg; + if (!validate(msg)) + { + throw org::openapitools::server::helpers::ValidationException(msg.str()); + } +} + +bool ApiResponse::validate(std::stringstream& msg) const +{ + return validate(msg, ""); +} + +bool ApiResponse::validate(std::stringstream& msg, const std::string& pathPrefix) const +{ + bool success = true; + const std::string _pathPrefix = pathPrefix.empty() ? "ApiResponse" : pathPrefix; + + + + + + return success; +} + +bool ApiResponse::operator==(const ApiResponse& rhs) const { + return + + + + ((!codeIsSet() && !rhs.codeIsSet()) || (codeIsSet() && rhs.codeIsSet() && getCode() == rhs.getCode())) && + + + ((!typeIsSet() && !rhs.typeIsSet()) || (typeIsSet() && rhs.typeIsSet() && getType() == rhs.getType())) && + + + ((!messageIsSet() && !rhs.messageIsSet()) || (messageIsSet() && rhs.messageIsSet() && getMessage() == rhs.getMessage())) + + ; } -void ApiResponse::validate() +bool ApiResponse::operator!=(const ApiResponse& rhs) const { - // TODO: implement validation + return !(*this == rhs); } void to_json(nlohmann::json& j, const ApiResponse& o) @@ -123,8 +163,5 @@ void ApiResponse::unsetMessage() } -} -} -} -} +} // namespace org::openapitools::server::model diff --git a/samples/server/petstore/cpp-pistache/model/ApiResponse.h b/samples/server/petstore/cpp-pistache/model/ApiResponse.h index 7ecb6c9a82ec..d963b76650bd 100644 --- a/samples/server/petstore/cpp-pistache/model/ApiResponse.h +++ b/samples/server/petstore/cpp-pistache/model/ApiResponse.h @@ -22,10 +22,8 @@ #include #include -namespace org { -namespace openapitools { -namespace server { -namespace model { +namespace org::openapitools::server::model +{ /// /// Describes the result of uploading an image resource @@ -34,9 +32,22 @@ class ApiResponse { public: ApiResponse(); - virtual ~ApiResponse(); + virtual ~ApiResponse() = default; - void validate(); + + /// + /// Validate the current data in the model. Throws a ValidationException on failure. + /// + void validate() const; + + /// + /// Validate the current data in the model. Returns false on error and writes an error + /// message into the given stringstream. + /// + bool validate(std::stringstream& msg) const; + + bool operator==(const ApiResponse& rhs) const; + bool operator!=(const ApiResponse& rhs) const; ///////////////////////////////////////////// /// ApiResponse members @@ -72,11 +83,11 @@ class ApiResponse bool m_TypeIsSet; std::string m_Message; bool m_MessageIsSet; + + // Helper overload for validate. Used when one model stores another model and calls it's validate. + bool validate(std::stringstream& msg, const std::string& pathPrefix) const; }; -} -} -} -} +} // namespace org::openapitools::server::model #endif /* ApiResponse_H_ */ diff --git a/samples/server/petstore/cpp-pistache/model/Category.cpp b/samples/server/petstore/cpp-pistache/model/Category.cpp index 3b08114f61de..deb18ff9bb7e 100644 --- a/samples/server/petstore/cpp-pistache/model/Category.cpp +++ b/samples/server/petstore/cpp-pistache/model/Category.cpp @@ -12,11 +12,12 @@ #include "Category.h" +#include "Helpers.h" -namespace org { -namespace openapitools { -namespace server { -namespace model { +#include + +namespace org::openapitools::server::model +{ Category::Category() { @@ -27,13 +28,48 @@ Category::Category() } -Category::~Category() +void Category::validate() const { + std::stringstream msg; + if (!validate(msg)) + { + throw org::openapitools::server::helpers::ValidationException(msg.str()); + } } -void Category::validate() +bool Category::validate(std::stringstream& msg) const { - // TODO: implement validation + return validate(msg, ""); +} + +bool Category::validate(std::stringstream& msg, const std::string& pathPrefix) const +{ + bool success = true; + const std::string _pathPrefix = pathPrefix.empty() ? "Category" : pathPrefix; + + + + + return success; +} + +bool Category::operator==(const Category& rhs) const +{ + return + + + + ((!idIsSet() && !rhs.idIsSet()) || (idIsSet() && rhs.idIsSet() && getId() == rhs.getId())) && + + + ((!nameIsSet() && !rhs.nameIsSet()) || (nameIsSet() && rhs.nameIsSet() && getName() == rhs.getName())) + + ; +} + +bool Category::operator!=(const Category& rhs) const +{ + return !(*this == rhs); } void to_json(nlohmann::json& j, const Category& o) @@ -97,8 +133,5 @@ void Category::unsetName() } -} -} -} -} +} // namespace org::openapitools::server::model diff --git a/samples/server/petstore/cpp-pistache/model/Category.h b/samples/server/petstore/cpp-pistache/model/Category.h index fa12fdc0de8d..1929ce33e925 100644 --- a/samples/server/petstore/cpp-pistache/model/Category.h +++ b/samples/server/petstore/cpp-pistache/model/Category.h @@ -22,10 +22,8 @@ #include #include -namespace org { -namespace openapitools { -namespace server { -namespace model { +namespace org::openapitools::server::model +{ /// /// A category for a pet @@ -34,9 +32,22 @@ class Category { public: Category(); - virtual ~Category(); + virtual ~Category() = default; - void validate(); + + /// + /// Validate the current data in the model. Throws a ValidationException on failure. + /// + void validate() const; + + /// + /// Validate the current data in the model. Returns false on error and writes an error + /// message into the given stringstream. + /// + bool validate(std::stringstream& msg) const; + + bool operator==(const Category& rhs) const; + bool operator!=(const Category& rhs) const; ///////////////////////////////////////////// /// Category members @@ -63,11 +74,11 @@ class Category bool m_IdIsSet; std::string m_Name; bool m_NameIsSet; + + // Helper overload for validate. Used when one model stores another model and calls it's validate. + bool validate(std::stringstream& msg, const std::string& pathPrefix) const; }; -} -} -} -} +} // namespace org::openapitools::server::model #endif /* Category_H_ */ diff --git a/samples/server/petstore/cpp-pistache/model/Helpers.cpp b/samples/server/petstore/cpp-pistache/model/Helpers.cpp index a7774194c82c..cfac2d78986a 100644 --- a/samples/server/petstore/cpp-pistache/model/Helpers.cpp +++ b/samples/server/petstore/cpp-pistache/model/Helpers.cpp @@ -10,34 +10,75 @@ * Do not edit the class manually. */ #include "Helpers.h" +#include -namespace org { -namespace openapitools { -namespace server { -namespace helpers { +namespace org::openapitools::server::helpers +{ +const std::regex regexRfc3339_date(R"(^(\d{4})\-(\d{2})\-(\d{2})$)"); +const std::regex regexRfc3339_date_time( + R"(^(\d{4})\-(\d{2})\-(\d{2})[Tt](\d{2}):(\d{2}):(\d{2})(\.\d+)?([Zz]|([\+\-])(\d{2}):(\d{2}))$)" +); + + +namespace +{ + // Determine if given year is a leap year + // See RFC 3339, Appendix C https://tools.ietf.org/html/rfc3339#appendix-C + bool isLeapYear(const uint16_t year) { + return (year % 4 == 0) && ((year % 100 != 0) || (year % 400 == 0)); + } + + bool validateDateValues(const uint16_t year, const uint16_t month, const uint16_t day) { + return !( + (month == 0 || month > 12) + || (day == 0) + || (month == 2 && day > (28 + (isLeapYear(year) ? 1 : 0))) + || (month <= 7 && day > (30 + month % 2)) + || (month >= 8 && day > (31 - month % 2)) + ); + } + + bool validateTimeValues(const uint16_t hours, const uint16_t minutes, const uint16_t seconds) { + return (hours <= 23) && (minutes <= 59) && (seconds <= 60); + } +} + +bool validateRfc3339_date(const std::string& str) { + std::smatch match; + const bool found = std::regex_search(str, match, regexRfc3339_date); + return found && validateDateValues(std::stoi(match[1]), std::stoi(match[2]), std::stoi(match[3])); +} + +bool validateRfc3339_date_time(const std::string& str) { + std::smatch match; + const bool found = std::regex_search(str, match, regexRfc3339_date_time); + return found + && validateDateValues(std::stoi(match[1]), std::stoi(match[2]), std::stoi(match[3])) + && validateTimeValues(std::stoi(match[4]), std::stoi(match[5]), std::stoi(match[6])); +} std::string toStringValue(const std::string &value){ return std::string(value); } -std::string toStringValue(const int32_t &value){ +std::string toStringValue(const int32_t value){ return std::to_string(value); } -std::string toStringValue(const int64_t &value){ +std::string toStringValue(const int64_t value){ return std::to_string(value); } -std::string toStringValue(const bool &value){ - return value?std::string("true"):std::string("false"); +std::string toStringValue(const bool value){ + return value ? std::string("true") : std::string("false"); } -std::string toStringValue(const float &value){ +std::string toStringValue(const float value){ return std::to_string(value); } -std::string toStringValue(const double &value){ +std::string toStringValue(const double value){ return std::to_string(value); } @@ -67,9 +108,15 @@ bool fromStringValue(const std::string &inStr, int64_t &value){ } bool fromStringValue(const std::string &inStr, bool &value){ - bool result = true; - inStr == "true"?value = true: inStr == "false"?value = false: result = false; - return result; + if (inStr == "true") { + value = true; + return true; + } + if (inStr == "false") { + value = false; + return true; + } + return false; } bool fromStringValue(const std::string &inStr, float &value){ @@ -92,7 +139,4 @@ bool fromStringValue(const std::string &inStr, double &value){ return true; } -} -} -} -} +} // namespace org::openapitools::server::helpers diff --git a/samples/server/petstore/cpp-pistache/model/Helpers.h b/samples/server/petstore/cpp-pistache/model/Helpers.h index 9c8c02c4ae61..176b817de1eb 100644 --- a/samples/server/petstore/cpp-pistache/model/Helpers.h +++ b/samples/server/petstore/cpp-pistache/model/Helpers.h @@ -24,17 +24,80 @@ #include #include -namespace org { -namespace openapitools { -namespace server { -namespace helpers { +namespace org::openapitools::server::helpers +{ + + class ValidationException : public std::runtime_error + { + public: + explicit ValidationException(const std::string& what) + : std::runtime_error(what) + { } + ~ValidationException() override = default; + }; + + /// + /// Validate a string against the full-date definition of RFC 3339, section 5.6. + /// + bool validateRfc3339_date(const std::string& str); + + /// + /// Validate a string against the date-time definition of RFC 3339, section 5.6. + /// + bool validateRfc3339_date_time(const std::string& str); + + namespace sfinae_helpers + { + struct NoType {}; + template NoType operator==(const T1&, const T2&); + + template class EqualsOperatorAvailable + { + public: + enum + { + value = !std::is_same< decltype(std::declval() == std::declval()), NoType >::value + }; + }; + } // namespace sfinae_helpers + + + /// + /// Determine if the given vector only has unique elements. T must provide the == operator. + /// + template + bool hasOnlyUniqueItems(const std::vector& vec) + { + static_assert(sfinae_helpers::EqualsOperatorAvailable::value, + "hasOnlyUniqueItems cannot be called, passed template type does not provide == operator."); + if (vec.size() <= 1) + { + return true; + } + // Compare every element of vec to every other element of vec. + // This isn't an elegant way to do this, since it's O(n^2), + // but it's the best solution working only with the == operator. + // This could be greatly improved if our models provided a valid hash + // and/or the < operator + for (size_t i = 0; i < vec.size() - 1; i++) + { + for (size_t j = i + 1; j < vec.size(); j++) + { + if (vec[i] == vec[j]) + { + return false; + } + } + } + return true; + } std::string toStringValue(const std::string &value); - std::string toStringValue(const int32_t &value); - std::string toStringValue(const int64_t &value); - std::string toStringValue(const bool &value); - std::string toStringValue(const float &value); - std::string toStringValue(const double &value); + std::string toStringValue(const int32_t value); + std::string toStringValue(const int64_t value); + std::string toStringValue(const bool value); + std::string toStringValue(const float value); + std::string toStringValue(const double value); bool fromStringValue(const std::string &inStr, std::string &value); bool fromStringValue(const std::string &inStr, int32_t &value); @@ -68,9 +131,6 @@ namespace helpers { return fromStringValue(inStrings, value); } -} -} -} -} +} // namespace org::openapitools::server::helpers -#endif // Helpers_H_ \ No newline at end of file +#endif // Helpers_H_ diff --git a/samples/server/petstore/cpp-pistache/model/Order.cpp b/samples/server/petstore/cpp-pistache/model/Order.cpp index 986cf6b24fa9..2d04f0ac637b 100644 --- a/samples/server/petstore/cpp-pistache/model/Order.cpp +++ b/samples/server/petstore/cpp-pistache/model/Order.cpp @@ -12,11 +12,12 @@ #include "Order.h" +#include "Helpers.h" -namespace org { -namespace openapitools { -namespace server { -namespace model { +#include + +namespace org::openapitools::server::model +{ Order::Order() { @@ -35,13 +36,64 @@ Order::Order() } -Order::~Order() +void Order::validate() const { + std::stringstream msg; + if (!validate(msg)) + { + throw org::openapitools::server::helpers::ValidationException(msg.str()); + } } -void Order::validate() +bool Order::validate(std::stringstream& msg) const { - // TODO: implement validation + return validate(msg, ""); +} + +bool Order::validate(std::stringstream& msg, const std::string& pathPrefix) const +{ + bool success = true; + const std::string _pathPrefix = pathPrefix.empty() ? "Order" : pathPrefix; + + + + + + + + + return success; +} + +bool Order::operator==(const Order& rhs) const +{ + return + + + + ((!idIsSet() && !rhs.idIsSet()) || (idIsSet() && rhs.idIsSet() && getId() == rhs.getId())) && + + + ((!petIdIsSet() && !rhs.petIdIsSet()) || (petIdIsSet() && rhs.petIdIsSet() && getPetId() == rhs.getPetId())) && + + + ((!quantityIsSet() && !rhs.quantityIsSet()) || (quantityIsSet() && rhs.quantityIsSet() && getQuantity() == rhs.getQuantity())) && + + + ((!shipDateIsSet() && !rhs.shipDateIsSet()) || (shipDateIsSet() && rhs.shipDateIsSet() && getShipDate() == rhs.getShipDate())) && + + + ((!statusIsSet() && !rhs.statusIsSet()) || (statusIsSet() && rhs.statusIsSet() && getStatus() == rhs.getStatus())) && + + + ((!completeIsSet() && !rhs.completeIsSet()) || (completeIsSet() && rhs.completeIsSet() && isComplete() == rhs.isComplete())) + + ; +} + +bool Order::operator!=(const Order& rhs) const +{ + return !(*this == rhs); } void to_json(nlohmann::json& j, const Order& o) @@ -201,8 +253,5 @@ void Order::unsetComplete() } -} -} -} -} +} // namespace org::openapitools::server::model diff --git a/samples/server/petstore/cpp-pistache/model/Order.h b/samples/server/petstore/cpp-pistache/model/Order.h index d900b633f32c..3d28e1eef6ba 100644 --- a/samples/server/petstore/cpp-pistache/model/Order.h +++ b/samples/server/petstore/cpp-pistache/model/Order.h @@ -22,10 +22,8 @@ #include #include -namespace org { -namespace openapitools { -namespace server { -namespace model { +namespace org::openapitools::server::model +{ /// /// An order for a pets from the pet store @@ -34,9 +32,22 @@ class Order { public: Order(); - virtual ~Order(); + virtual ~Order() = default; - void validate(); + + /// + /// Validate the current data in the model. Throws a ValidationException on failure. + /// + void validate() const; + + /// + /// Validate the current data in the model. Returns false on error and writes an error + /// message into the given stringstream. + /// + bool validate(std::stringstream& msg) const; + + bool operator==(const Order& rhs) const; + bool operator!=(const Order& rhs) const; ///////////////////////////////////////////// /// Order members @@ -99,11 +110,11 @@ class Order bool m_StatusIsSet; bool m_Complete; bool m_CompleteIsSet; + + // Helper overload for validate. Used when one model stores another model and calls it's validate. + bool validate(std::stringstream& msg, const std::string& pathPrefix) const; }; -} -} -} -} +} // namespace org::openapitools::server::model #endif /* Order_H_ */ diff --git a/samples/server/petstore/cpp-pistache/model/Pet.cpp b/samples/server/petstore/cpp-pistache/model/Pet.cpp index 434b1339cd06..9c7ba886a44c 100644 --- a/samples/server/petstore/cpp-pistache/model/Pet.cpp +++ b/samples/server/petstore/cpp-pistache/model/Pet.cpp @@ -12,11 +12,12 @@ #include "Pet.h" +#include "Helpers.h" -namespace org { -namespace openapitools { -namespace server { -namespace model { +#include + +namespace org::openapitools::server::model +{ Pet::Pet() { @@ -30,13 +31,106 @@ Pet::Pet() } -Pet::~Pet() +void Pet::validate() const +{ + std::stringstream msg; + if (!validate(msg)) + { + throw org::openapitools::server::helpers::ValidationException(msg.str()); + } +} + +bool Pet::validate(std::stringstream& msg) const { + return validate(msg, ""); } -void Pet::validate() +bool Pet::validate(std::stringstream& msg, const std::string& pathPrefix) const { - // TODO: implement validation + bool success = true; + const std::string _pathPrefix = pathPrefix.empty() ? "Pet" : pathPrefix; + + + + + + + /* PhotoUrls */ { + const std::vector& value = m_PhotoUrls; + const std::string currentValuePath = _pathPrefix + ".photoUrls"; + + + { // Recursive validation of array elements + const std::string oldValuePath = currentValuePath; + int i = 0; + for (const std::string& value : value) + { + const std::string currentValuePath = oldValuePath + "[" + std::to_string(i) + "]"; + + + + i++; + } + } + + } + + + if (tagsIsSet()) + { + const std::vector& value = m_Tags; + const std::string currentValuePath = _pathPrefix + ".tags"; + + + { // Recursive validation of array elements + const std::string oldValuePath = currentValuePath; + int i = 0; + for (const Tag& value : value) + { + const std::string currentValuePath = oldValuePath + "[" + std::to_string(i) + "]"; + + success = value.validate(msg, currentValuePath + ".tags") && success; + + i++; + } + } + + } + + + + return success; +} + +bool Pet::operator==(const Pet& rhs) const +{ + return + + + + ((!idIsSet() && !rhs.idIsSet()) || (idIsSet() && rhs.idIsSet() && getId() == rhs.getId())) && + + + ((!categoryIsSet() && !rhs.categoryIsSet()) || (categoryIsSet() && rhs.categoryIsSet() && getCategory() == rhs.getCategory())) && + + (getName() == rhs.getName()) + && + + (getPhotoUrls() == rhs.getPhotoUrls()) + && + + + ((!tagsIsSet() && !rhs.tagsIsSet()) || (tagsIsSet() && rhs.tagsIsSet() && getTags() == rhs.getTags())) && + + + ((!statusIsSet() && !rhs.statusIsSet()) || (statusIsSet() && rhs.statusIsSet() && getStatus() == rhs.getStatus())) + + ; +} + +bool Pet::operator!=(const Pet& rhs) const +{ + return !(*this == rhs); } void to_json(nlohmann::json& j, const Pet& o) @@ -124,7 +218,7 @@ void Pet::setName(std::string const& value) { m_Name = value; } -std::vector& Pet::getPhotoUrls() +std::vector Pet::getPhotoUrls() const { return m_PhotoUrls; } @@ -132,7 +226,7 @@ void Pet::setPhotoUrls(std::vector const& value) { m_PhotoUrls = value; } -std::vector& Pet::getTags() +std::vector Pet::getTags() const { return m_Tags; } @@ -168,8 +262,5 @@ void Pet::unsetStatus() } -} -} -} -} +} // namespace org::openapitools::server::model diff --git a/samples/server/petstore/cpp-pistache/model/Pet.h b/samples/server/petstore/cpp-pistache/model/Pet.h index eddf475f6ee3..1cd841a08fa7 100644 --- a/samples/server/petstore/cpp-pistache/model/Pet.h +++ b/samples/server/petstore/cpp-pistache/model/Pet.h @@ -25,10 +25,8 @@ #include #include -namespace org { -namespace openapitools { -namespace server { -namespace model { +namespace org::openapitools::server::model +{ /// /// A pet for sale in the pet store @@ -37,9 +35,22 @@ class Pet { public: Pet(); - virtual ~Pet(); + virtual ~Pet() = default; - void validate(); + + /// + /// Validate the current data in the model. Throws a ValidationException on failure. + /// + void validate() const; + + /// + /// Validate the current data in the model. Returns false on error and writes an error + /// message into the given stringstream. + /// + bool validate(std::stringstream& msg) const; + + bool operator==(const Pet& rhs) const; + bool operator!=(const Pet& rhs) const; ///////////////////////////////////////////// /// Pet members @@ -66,12 +77,12 @@ class Pet /// /// /// - std::vector& getPhotoUrls(); + std::vector getPhotoUrls() const; void setPhotoUrls(std::vector const& value); /// /// /// - std::vector& getTags(); + std::vector getTags() const; void setTags(std::vector const& value); bool tagsIsSet() const; void unsetTags(); @@ -98,11 +109,11 @@ class Pet bool m_TagsIsSet; std::string m_Status; bool m_StatusIsSet; + + // Helper overload for validate. Used when one model stores another model and calls it's validate. + bool validate(std::stringstream& msg, const std::string& pathPrefix) const; }; -} -} -} -} +} // namespace org::openapitools::server::model #endif /* Pet_H_ */ diff --git a/samples/server/petstore/cpp-pistache/model/Tag.cpp b/samples/server/petstore/cpp-pistache/model/Tag.cpp index cba759bad1d0..659565e4034d 100644 --- a/samples/server/petstore/cpp-pistache/model/Tag.cpp +++ b/samples/server/petstore/cpp-pistache/model/Tag.cpp @@ -12,11 +12,12 @@ #include "Tag.h" +#include "Helpers.h" -namespace org { -namespace openapitools { -namespace server { -namespace model { +#include + +namespace org::openapitools::server::model +{ Tag::Tag() { @@ -27,13 +28,48 @@ Tag::Tag() } -Tag::~Tag() +void Tag::validate() const { + std::stringstream msg; + if (!validate(msg)) + { + throw org::openapitools::server::helpers::ValidationException(msg.str()); + } } -void Tag::validate() +bool Tag::validate(std::stringstream& msg) const { - // TODO: implement validation + return validate(msg, ""); +} + +bool Tag::validate(std::stringstream& msg, const std::string& pathPrefix) const +{ + bool success = true; + const std::string _pathPrefix = pathPrefix.empty() ? "Tag" : pathPrefix; + + + + + return success; +} + +bool Tag::operator==(const Tag& rhs) const +{ + return + + + + ((!idIsSet() && !rhs.idIsSet()) || (idIsSet() && rhs.idIsSet() && getId() == rhs.getId())) && + + + ((!nameIsSet() && !rhs.nameIsSet()) || (nameIsSet() && rhs.nameIsSet() && getName() == rhs.getName())) + + ; +} + +bool Tag::operator!=(const Tag& rhs) const +{ + return !(*this == rhs); } void to_json(nlohmann::json& j, const Tag& o) @@ -97,8 +133,5 @@ void Tag::unsetName() } -} -} -} -} +} // namespace org::openapitools::server::model diff --git a/samples/server/petstore/cpp-pistache/model/Tag.h b/samples/server/petstore/cpp-pistache/model/Tag.h index 4b422931d771..ddebeadae431 100644 --- a/samples/server/petstore/cpp-pistache/model/Tag.h +++ b/samples/server/petstore/cpp-pistache/model/Tag.h @@ -22,10 +22,8 @@ #include #include -namespace org { -namespace openapitools { -namespace server { -namespace model { +namespace org::openapitools::server::model +{ /// /// A tag for a pet @@ -34,9 +32,22 @@ class Tag { public: Tag(); - virtual ~Tag(); + virtual ~Tag() = default; - void validate(); + + /// + /// Validate the current data in the model. Throws a ValidationException on failure. + /// + void validate() const; + + /// + /// Validate the current data in the model. Returns false on error and writes an error + /// message into the given stringstream. + /// + bool validate(std::stringstream& msg) const; + + bool operator==(const Tag& rhs) const; + bool operator!=(const Tag& rhs) const; ///////////////////////////////////////////// /// Tag members @@ -63,11 +74,11 @@ class Tag bool m_IdIsSet; std::string m_Name; bool m_NameIsSet; + + // Helper overload for validate. Used when one model stores another model and calls it's validate. + bool validate(std::stringstream& msg, const std::string& pathPrefix) const; }; -} -} -} -} +} // namespace org::openapitools::server::model #endif /* Tag_H_ */ diff --git a/samples/server/petstore/cpp-pistache/model/User.cpp b/samples/server/petstore/cpp-pistache/model/User.cpp index 2db9316b75d9..c997bf9734db 100644 --- a/samples/server/petstore/cpp-pistache/model/User.cpp +++ b/samples/server/petstore/cpp-pistache/model/User.cpp @@ -12,11 +12,12 @@ #include "User.h" +#include "Helpers.h" -namespace org { -namespace openapitools { -namespace server { -namespace model { +#include + +namespace org::openapitools::server::model +{ User::User() { @@ -39,13 +40,72 @@ User::User() } -User::~User() +void User::validate() const +{ + std::stringstream msg; + if (!validate(msg)) + { + throw org::openapitools::server::helpers::ValidationException(msg.str()); + } +} + +bool User::validate(std::stringstream& msg) const { + return validate(msg, ""); } -void User::validate() +bool User::validate(std::stringstream& msg, const std::string& pathPrefix) const { - // TODO: implement validation + bool success = true; + const std::string _pathPrefix = pathPrefix.empty() ? "User" : pathPrefix; + + + + + + + + + + + return success; +} + +bool User::operator==(const User& rhs) const +{ + return + + + + ((!idIsSet() && !rhs.idIsSet()) || (idIsSet() && rhs.idIsSet() && getId() == rhs.getId())) && + + + ((!usernameIsSet() && !rhs.usernameIsSet()) || (usernameIsSet() && rhs.usernameIsSet() && getUsername() == rhs.getUsername())) && + + + ((!firstNameIsSet() && !rhs.firstNameIsSet()) || (firstNameIsSet() && rhs.firstNameIsSet() && getFirstName() == rhs.getFirstName())) && + + + ((!lastNameIsSet() && !rhs.lastNameIsSet()) || (lastNameIsSet() && rhs.lastNameIsSet() && getLastName() == rhs.getLastName())) && + + + ((!emailIsSet() && !rhs.emailIsSet()) || (emailIsSet() && rhs.emailIsSet() && getEmail() == rhs.getEmail())) && + + + ((!passwordIsSet() && !rhs.passwordIsSet()) || (passwordIsSet() && rhs.passwordIsSet() && getPassword() == rhs.getPassword())) && + + + ((!phoneIsSet() && !rhs.phoneIsSet()) || (phoneIsSet() && rhs.phoneIsSet() && getPhone() == rhs.getPhone())) && + + + ((!userStatusIsSet() && !rhs.userStatusIsSet()) || (userStatusIsSet() && rhs.userStatusIsSet() && getUserStatus() == rhs.getUserStatus())) + + ; +} + +bool User::operator!=(const User& rhs) const +{ + return !(*this == rhs); } void to_json(nlohmann::json& j, const User& o) @@ -253,8 +313,5 @@ void User::unsetUserStatus() } -} -} -} -} +} // namespace org::openapitools::server::model diff --git a/samples/server/petstore/cpp-pistache/model/User.h b/samples/server/petstore/cpp-pistache/model/User.h index 1f4c17ce6a81..02bd5f4230a8 100644 --- a/samples/server/petstore/cpp-pistache/model/User.h +++ b/samples/server/petstore/cpp-pistache/model/User.h @@ -22,10 +22,8 @@ #include #include -namespace org { -namespace openapitools { -namespace server { -namespace model { +namespace org::openapitools::server::model +{ /// /// A User who is purchasing from the pet store @@ -34,9 +32,22 @@ class User { public: User(); - virtual ~User(); + virtual ~User() = default; - void validate(); + + /// + /// Validate the current data in the model. Throws a ValidationException on failure. + /// + void validate() const; + + /// + /// Validate the current data in the model. Returns false on error and writes an error + /// message into the given stringstream. + /// + bool validate(std::stringstream& msg) const; + + bool operator==(const User& rhs) const; + bool operator!=(const User& rhs) const; ///////////////////////////////////////////// /// User members @@ -117,11 +128,11 @@ class User bool m_PhoneIsSet; int32_t m_UserStatus; bool m_UserStatusIsSet; + + // Helper overload for validate. Used when one model stores another model and calls it's validate. + bool validate(std::stringstream& msg, const std::string& pathPrefix) const; }; -} -} -} -} +} // namespace org::openapitools::server::model #endif /* User_H_ */ From ec085713cec7d51a5ee9e17e5fd4899740354efa Mon Sep 17 00:00:00 2001 From: William Cheng Date: Thu, 6 May 2021 10:42:46 +0800 Subject: [PATCH 11/18] [Erlang] migrate CI to drone.io (#9406) * test erlang client, server in drone.io * rearrange tests, add server folder * comment out erlang server tests --- CI/.drone.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CI/.drone.yml b/CI/.drone.yml index 037fb654724c..a4c8c9b0e95e 100644 --- a/CI/.drone.yml +++ b/CI/.drone.yml @@ -1,6 +1,5 @@ kind: pipeline name: default - steps: # test Java 11 HTTP client - name: java11-test @@ -54,3 +53,10 @@ steps: image: haskell:8.6.5 commands: - (cd samples/client/petstore/haskell-http-client/ && stack --install-ghc --no-haddock-deps haddock --fast && stack test --fast) +# test erlang client and server +- name: erlang + image: erlang:alpine + commands: + - (cd samples/client/petstore/erlang-client && rebar3 compile) + - (cd samples/client/petstore/erlang-proper && rebar3 compile) + #- (cd samples/server/petstore/erlang-server && rebar3 compile) From 45d55f6b73b166e55ed452cd384eb1a790082817 Mon Sep 17 00:00:00 2001 From: matt beary <1661988+hauntingEcho@users.noreply.github.com> Date: Wed, 5 May 2021 21:46:06 -0500 Subject: [PATCH 12/18] [aspnetcore] Fix incorrect logging messages (#9405) * fix incorrect aspnetcore logging messages * address comments from review cleans up log messages --- .../codegen/languages/AspNetCoreServerCodegen.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AspNetCoreServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AspNetCoreServerCodegen.java index a52fa88609a5..7786ba8b092d 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AspNetCoreServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AspNetCoreServerCodegen.java @@ -592,6 +592,7 @@ private void setModelClassModifier() { private void setBuildTarget() { setCliOption(buildTarget); if ("library".equals(buildTarget.getOptValue())) { + LOGGER.warn("buildTarget is {} so changing default isLibrary to true", buildTarget.getOptValue()); isLibrary = true; projectSdk = SDK_LIB; additionalProperties.put(CLASS_MODIFIER, "abstract"); @@ -636,7 +637,7 @@ private String determineTemplateVersion(String frameworkVersion) { private void setUseSwashbuckle() { if (isLibrary) { - LOGGER.warn("buildTarget is " + buildTarget.getOptValue() + " so changing default isLibrary to false "); + LOGGER.warn("isLibrary is true so changing default useSwashbuckle to false"); useSwashbuckle = false; } else { useSwashbuckle = true; From 32b2ea3291dc7cf209449155bcf5bd049f488723 Mon Sep 17 00:00:00 2001 From: matt beary <1661988+hauntingEcho@users.noreply.github.com> Date: Wed, 5 May 2021 22:23:32 -0500 Subject: [PATCH 13/18] Fixes #9398: fix aspnet enum documentation (#9404) --- docs/generators/aspnetcore.md | 12 ++++++------ .../codegen/languages/AspNetCoreServerCodegen.java | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/generators/aspnetcore.md b/docs/generators/aspnetcore.md index 0a30830099f5..99f0b789bdc3 100644 --- a/docs/generators/aspnetcore.md +++ b/docs/generators/aspnetcore.md @@ -7,9 +7,9 @@ These options may be applied as additional-properties (cli) or configOptions (pl | Option | Description | Values | Default | | ------ | ----------- | ------ | ------- | -|aspnetCoreVersion|ASP.NET Core version: 5.0, 3.1, 3.0, 2.2, 2.1, 2.0 (deprecated)| |3.1| -|buildTarget|Target to build an application or library| |program| -|classModifier|Class Modifier for controller classes: Empty string or abstract.| || +|aspnetCoreVersion|ASP.NET Core version: 5.0, 3.1, 3.0, 2.2, 2.1, 2.0 (deprecated)|
**2.0**
ASP.NET Core 2.0
**2.1**
ASP.NET Core 2.1
**2.2**
ASP.NET Core 2.2
**3.0**
ASP.NET Core 3.0
**3.1**
ASP.NET Core 3.1
**5.0**
ASP.NET Core 5.0
|3.1| +|buildTarget|Target to build an application or library|
**program**
Generate code for a standalone server
**library**
Generate code for a server abstract class library
|program| +|classModifier|Class Modifier for controller classes: Empty string or abstract.|
****
Keep class default with no modifier
**abstract**
Make class abstract
|| |compatibilityVersion|ASP.Net Core CompatibilityVersion| |Version_2_2| |enumNameSuffix|Suffix that will be appended to all enum names.| |Enum| |enumValueSuffix|Suffix that will be appended to all enum values.| |Enum| @@ -17,10 +17,10 @@ These options may be applied as additional-properties (cli) or configOptions (pl |isLibrary|Is the build a library| |false| |licenseName|The name of the license| |NoLicense| |licenseUrl|The URL of the license| |http://localhost| -|modelClassModifier|Model Class Modifier can be nothing or partial| |partial| +|modelClassModifier|Model Class Modifier can be nothing or partial|
****
Keep model class default with no modifier
**partial**
Make model class partial
|partial| |newtonsoftVersion|Version for Microsoft.AspNetCore.Mvc.NewtonsoftJson for ASP.NET Core 3.0+| |3.0.0| |operationIsAsync|Set methods to async or sync (default).| |false| -|operationModifier|Operation Modifier can be virtual or abstract| |virtual| +|operationModifier|Operation Modifier can be virtual or abstract|
**virtual**
Keep method virtual
**abstract**
Make method abstract
|virtual| |operationResultTask|Set methods result to Task<>.| |false| |packageAuthors|Specifies Authors property in the .NET Core project file.| |OpenAPI| |packageCopyright|Specifies an AssemblyCopyright for the .NET Framework global assembly attributes stored in the AssemblyInfo file.| |No Copyright| @@ -32,7 +32,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |returnICollection|Return ICollection<T> instead of the concrete type.| |false| |sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true| |sourceFolder|source folder for generated code| |src| -|swashbuckleVersion|Swashbuckle version: 3.0.0, 4.0.0, 5.0.0| |3.0.0| +|swashbuckleVersion|Swashbuckle version: 3.0.0, 4.0.0, 5.0.0|
**3.0.0**
Swashbuckle 3.0.0
**4.0.0**
Swashbuckle 4.0.0
**5.0.0**
Swashbuckle 5.0.0
|3.0.0| |useCollection|Deserialize array types to Collection<T> instead of List<T>.| |false| |useDateTimeOffset|Use DateTimeOffset to model date-time properties| |false| |useDefaultRouting|Use default routing for the ASP.NET Core version.| |true| diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AspNetCoreServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AspNetCoreServerCodegen.java index 7786ba8b092d..f7c24196331e 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AspNetCoreServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AspNetCoreServerCodegen.java @@ -199,14 +199,14 @@ public AspNetCoreServerCodegen() { aspnetCoreVersion.addEnum("5.0", "ASP.NET Core 5.0"); aspnetCoreVersion.setDefault("3.1"); aspnetCoreVersion.setOptValue(aspnetCoreVersion.getDefault()); - addOption(aspnetCoreVersion.getOpt(), aspnetCoreVersion.getDescription(), aspnetCoreVersion.getOptValue()); + cliOptions.add(aspnetCoreVersion); swashbuckleVersion.addEnum("3.0.0", "Swashbuckle 3.0.0"); swashbuckleVersion.addEnum("4.0.0", "Swashbuckle 4.0.0"); swashbuckleVersion.addEnum("5.0.0", "Swashbuckle 5.0.0"); swashbuckleVersion.setDefault("3.0.0"); swashbuckleVersion.setOptValue(swashbuckleVersion.getDefault()); - addOption(swashbuckleVersion.getOpt(), swashbuckleVersion.getDescription(), swashbuckleVersion.getOptValue()); + cliOptions.add(swashbuckleVersion); // CLI Switches addSwitch(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, @@ -261,19 +261,19 @@ public AspNetCoreServerCodegen() { classModifier.addEnum("abstract", "Make class abstract"); classModifier.setDefault(""); classModifier.setOptValue(classModifier.getDefault()); - addOption(classModifier.getOpt(), classModifier.getDescription(), classModifier.getOptValue()); + cliOptions.add(classModifier); operationModifier.addEnum("virtual", "Keep method virtual"); operationModifier.addEnum("abstract", "Make method abstract"); operationModifier.setDefault("virtual"); operationModifier.setOptValue(operationModifier.getDefault()); - addOption(operationModifier.getOpt(), operationModifier.getDescription(), operationModifier.getOptValue()); + cliOptions.add(operationModifier); buildTarget.addEnum("program", "Generate code for a standalone server"); buildTarget.addEnum("library", "Generate code for a server abstract class library"); buildTarget.setDefault("program"); buildTarget.setOptValue(buildTarget.getDefault()); - addOption(buildTarget.getOpt(), buildTarget.getDescription(), buildTarget.getOptValue()); + cliOptions.add(buildTarget); addSwitch(GENERATE_BODY, "Generates method body.", @@ -292,7 +292,7 @@ public AspNetCoreServerCodegen() { modelClassModifier.addEnum("partial", "Make model class partial"); modelClassModifier.setDefault("partial"); modelClassModifier.setOptValue(modelClassModifier.getDefault()); - addOption(modelClassModifier.getOpt(), modelClassModifier.getDescription(), modelClassModifier.getOptValue()); + cliOptions.add(modelClassModifier); } @Override From 343d7eb712159d6dc00a62f8158167398a835f13 Mon Sep 17 00:00:00 2001 From: Samuel Kahn <48932506+Kahncode@users.noreply.github.com> Date: Thu, 6 May 2021 05:26:07 +0200 Subject: [PATCH 14/18] [cpp-ue4] Improved retry system to use Unreal's FHttpRetrySystem (#9382) * Revert "[cpp-ue4] Added the possibility to retry requests easily with AsyncRetry method on the response and SetAutoRetryCount on the request" * [cpp-ue4] Improved retry system to use Unreal's FHttpRetrySystem * [cpp-ue4] Updated style guide link * update samples Co-authored-by: William Cheng --- CONTRIBUTING.md | 1 + .../resources/cpp-ue4/api-header.mustache | 16 +- .../resources/cpp-ue4/api-source.mustache | 53 +++-- .../cpp-ue4/model-base-header.mustache | 40 +++- .../cpp-ue4/model-base-source.mustache | 30 +-- .../cpp-ue4/Private/OpenAPIBaseModel.cpp | 30 +-- .../cpp-ue4/Private/OpenAPIPetApi.cpp | 186 +++++++----------- .../cpp-ue4/Private/OpenAPIStoreApi.cpp | 110 +++++------ .../cpp-ue4/Private/OpenAPIUserApi.cpp | 186 +++++++----------- .../cpp-ue4/Public/OpenAPIBaseModel.h | 40 +++- .../petstore/cpp-ue4/Public/OpenAPIPetApi.h | 30 ++- .../petstore/cpp-ue4/Public/OpenAPIStoreApi.h | 22 ++- .../petstore/cpp-ue4/Public/OpenAPIUserApi.h | 30 ++- 13 files changed, 394 insertions(+), 380 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 30258ec9fd6c..0fe833163afa 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -48,6 +48,7 @@ Code change should conform to the programming style guide of the respective lang - C#: https://msdn.microsoft.com/en-us/library/vstudio/ff926074.aspx - C++: https://google.github.io/styleguide/cppguide.html - C++ (Tizen): https://wiki.tizen.org/Native_Platform_Coding_Idiom_and_Style_Guide#C.2B.2B_Coding_Style +- C++ (Unreal Engine 4): https://docs.unrealengine.com/en-US/ProductionPipelines/DevelopmentSetup/CodingStandard/index.html - Clojure: https://github.com/bbatsov/clojure-style-guide - Crystal: https://crystal-lang.org/reference/conventions/coding_style.html - Dart: https://www.dartlang.org/guides/language/effective-dart/style diff --git a/modules/openapi-generator/src/main/resources/cpp-ue4/api-header.mustache b/modules/openapi-generator/src/main/resources/cpp-ue4/api-header.mustache index c6ee2f08eb44..17b42e942ea7 100644 --- a/modules/openapi-generator/src/main/resources/cpp-ue4/api-header.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-ue4/api-header.mustache @@ -15,9 +15,19 @@ public: {{classname}}(); ~{{classname}}(); + /* Sets the URL Endpoint. + * Note: several fallback endpoints can be configured in request retry policies, see Request::SetShouldRetry */ void SetURL(const FString& Url); + + /* Adds global header params to all requests */ void AddHeaderParam(const FString& Key, const FString& Value); void ClearHeaderParams(); + + /* Sets the retry manager to the user-defined retry manager. User must manage the lifetime of the retry manager. + * If no retry manager is specified and a request needs retries, a default retry manager will be used. + * See also: Request::SetShouldRetry */ + void SetHttpRetryManager(FHttpRetrySystem::FManager& RetryManager); + FHttpRetrySystem::FManager& GetHttpRetryManager(); {{#operations}}{{#operation}}class {{operationIdCamelCase}}Request; class {{operationIdCamelCase}}Response; @@ -27,15 +37,17 @@ public: {{#operations}}{{#operation}}{{#description}}/* {{{description}}} */ {{/description}}bool {{operationIdCamelCase}}(const {{operationIdCamelCase}}Request& Request, const F{{operationIdCamelCase}}Delegate& Delegate = F{{operationIdCamelCase}}Delegate()) const; {{/operation}}{{/operations}} - private: - {{#operations}}{{#operation}}void On{{operationIdCamelCase}}Response(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, F{{operationIdCamelCase}}Delegate Delegate, int AutoRetryCount) const; + {{#operations}}{{#operation}}void On{{operationIdCamelCase}}Response(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, F{{operationIdCamelCase}}Delegate Delegate) const; {{/operation}}{{/operations}} + FHttpRequestRef CreateHttpRequest(const Request& Request) const; bool IsValid() const; void HandleResponse(FHttpResponsePtr HttpResponse, bool bSucceeded, Response& InOutResponse) const; FString Url; TMap AdditionalHeaderParams; + mutable FHttpRetrySystem::FManager* RetryManager = nullptr; + mutable TUniquePtr DefaultRetryManager; }; {{#cppNamespaceDeclarations}} diff --git a/modules/openapi-generator/src/main/resources/cpp-ue4/api-source.mustache b/modules/openapi-generator/src/main/resources/cpp-ue4/api-source.mustache index 8a9b38545444..9bd9f3b87bde 100644 --- a/modules/openapi-generator/src/main/resources/cpp-ue4/api-source.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-ue4/api-source.mustache @@ -45,6 +45,40 @@ bool {{classname}}::IsValid() const return true; } +void {{classname}}::SetHttpRetryManager(FHttpRetrySystem::FManager& InRetryManager) +{ + if(RetryManager != &GetHttpRetryManager()) + { + DefaultRetryManager.Reset(); + RetryManager = &InRetryManager; + } +} + +FHttpRetrySystem::FManager& {{classname}}::GetHttpRetryManager() +{ + return *RetryManager; +} + +FHttpRequestRef {{classname}}::CreateHttpRequest(const Request& Request) const +{ + if (!Request.GetRetryParams().IsSet()) + { + return FHttpModule::Get().CreateRequest(); + } + else + { + if (!RetryManager) + { + // Create default retry manager if none was specified + DefaultRetryManager = MakeUnique(6, 60); + RetryManager = DefaultRetryManager.Get(); + } + + const HttpRetryParams& Params = Request.GetRetryParams().GetValue(); + return RetryManager->CreateRequest(Params.RetryLimitCountOverride, Params.RetryTimeoutRelativeSecondsOverride, Params.RetryResponseCodes, Params.RetryVerbs, Params.RetryDomains); + } +} + void {{classname}}::HandleResponse(FHttpResponsePtr HttpResponse, bool bSucceeded, Response& InOutResponse) const { InOutResponse.SetHttpResponse(HttpResponse); @@ -96,7 +130,7 @@ bool {{classname}}::{{operationIdCamelCase}}(const {{operationIdCamelCase}}Reque if (!IsValid()) return false; - FHttpRequestRef HttpRequest = FHttpModule::Get().CreateRequest(); + FHttpRequestRef HttpRequest = CreateHttpRequest(Request); HttpRequest->SetURL(*(Url + Request.ComputePath())); for(const auto& It : AdditionalHeaderParams) @@ -106,26 +140,15 @@ bool {{classname}}::{{operationIdCamelCase}}(const {{operationIdCamelCase}}Reque Request.SetupHttpRequest(HttpRequest); - HttpRequest->OnProcessRequestComplete().BindRaw(this, &{{classname}}::On{{operationIdCamelCase}}Response, Delegate, Request.GetAutoRetryCount()); + HttpRequest->OnProcessRequestComplete().BindRaw(this, &{{classname}}::On{{operationIdCamelCase}}Response, Delegate); return HttpRequest->ProcessRequest(); } -void {{classname}}::On{{operationIdCamelCase}}Response(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, F{{operationIdCamelCase}}Delegate Delegate, int AutoRetryCount) const +void {{classname}}::On{{operationIdCamelCase}}Response(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, F{{operationIdCamelCase}}Delegate Delegate) const { {{operationIdCamelCase}}Response Response; - Response.SetHttpRequest(HttpRequest); - HandleResponse(HttpResponse, bSucceeded, Response); - - if(!Response.IsSuccessful() && AutoRetryCount > 0) - { - HttpRequest->OnProcessRequestComplete().BindRaw(this, &{{classname}}::On{{operationIdCamelCase}}Response, Delegate, AutoRetryCount - 1); - Response.AsyncRetry(); - } - else - { - Delegate.ExecuteIfBound(Response); - } + Delegate.ExecuteIfBound(Response); } {{/operation}} diff --git a/modules/openapi-generator/src/main/resources/cpp-ue4/model-base-header.mustache b/modules/openapi-generator/src/main/resources/cpp-ue4/model-base-header.mustache index 31b0bdabd260..2f5b6255f54a 100644 --- a/modules/openapi-generator/src/main/resources/cpp-ue4/model-base-header.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-ue4/model-base-header.mustache @@ -5,6 +5,8 @@ #include "Interfaces/IHttpResponse.h" #include "Serialization/JsonWriter.h" #include "Dom/JsonObject.h" +#include "HttpRetrySystem.h" +#include "Containers/Ticker.h" {{#cppNamespaceDeclarations}} namespace {{this}} @@ -12,6 +14,31 @@ namespace {{this}} {{/cppNamespaceDeclarations}} typedef TSharedRef> JsonWriter; +using namespace FHttpRetrySystem; + +struct {{dllapi}} HttpRetryManager : public FManager, public FTickerObjectBase +{ + using FManager::FManager; + + bool Tick(float DeltaTime) final; +}; + +struct {{dllapi}} HttpRetryParams +{ + HttpRetryParams( + const FRetryLimitCountSetting& InRetryLimitCountOverride = FRetryLimitCountSetting(), + const FRetryTimeoutRelativeSecondsSetting& InRetryTimeoutRelativeSecondsOverride = FRetryTimeoutRelativeSecondsSetting(), + const FRetryResponseCodes& InRetryResponseCodes = FRetryResponseCodes(), + const FRetryVerbs& InRetryVerbs = FRetryVerbs(), + const FRetryDomainsPtr& InRetryDomains = FRetryDomainsPtr() + ); + + FRetryLimitCountSetting RetryLimitCountOverride; + FRetryTimeoutRelativeSecondsSetting RetryTimeoutRelativeSecondsOverride; + FRetryResponseCodes RetryResponseCodes; + FRetryVerbs RetryVerbs; + FRetryDomainsPtr RetryDomains; +}; class {{dllapi}} Model { @@ -28,11 +55,12 @@ public: virtual void SetupHttpRequest(const FHttpRequestRef& HttpRequest) const = 0; virtual FString ComputePath() const = 0; - void SetAutoRetryCount(int InCount) { AutoRetryCount = InCount; } - int GetAutoRetryCount() const { return AutoRetryCount; } + /* Enables retry and optionally sets a retry policy for this request */ + void SetShouldRetry(const HttpRetryParams& Params = HttpRetryParams()) { RetryParams = Params; } + const TOptional& GetRetryParams() const { return RetryParams; } private: - int AutoRetryCount = 0; + TOptional RetryParams; }; class {{dllapi}} Response @@ -44,8 +72,6 @@ public: void SetSuccessful(bool InSuccessful) { Successful = InSuccessful; } bool IsSuccessful() const { return Successful; } - void AsyncRetry() const; - virtual void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode); EHttpResponseCodes::Type GetHttpResponseCode() const { return ResponseCode; } @@ -55,15 +81,11 @@ public: void SetHttpResponse(const FHttpResponsePtr& InHttpResponse) { HttpResponse = InHttpResponse; } const FHttpResponsePtr& GetHttpResponse() const { return HttpResponse; } - void SetHttpRequest(const FHttpRequestPtr& InHttpRequest) { HttpRequest = InHttpRequest; } - const FHttpRequestPtr& GetHttpRequest() const { return HttpRequest; } - private: bool Successful; EHttpResponseCodes::Type ResponseCode; FString ResponseString; FHttpResponsePtr HttpResponse; - FHttpRequestPtr HttpRequest; }; {{#cppNamespaceDeclarations}} diff --git a/modules/openapi-generator/src/main/resources/cpp-ue4/model-base-source.mustache b/modules/openapi-generator/src/main/resources/cpp-ue4/model-base-source.mustache index a5ab70a432f7..57dc4fb4151c 100644 --- a/modules/openapi-generator/src/main/resources/cpp-ue4/model-base-source.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-ue4/model-base-source.mustache @@ -1,13 +1,30 @@ {{>licenseInfo}} #include "{{modelNamePrefix}}BaseModel.h" -#include "Async/Async.h" - {{#cppNamespaceDeclarations}} namespace {{this}} { {{/cppNamespaceDeclarations}} +bool HttpRetryManager::Tick(float DeltaTime) +{ + FManager::Update(); + return true; +} + +HttpRetryParams::HttpRetryParams(const FRetryLimitCountSetting& InRetryLimitCountOverride /*= FRetryLimitCountSetting()*/, + const FRetryTimeoutRelativeSecondsSetting& InRetryTimeoutRelativeSecondsOverride /*= FRetryTimeoutRelativeSecondsSetting()*/, + const FRetryResponseCodes& InRetryResponseCodes /*= FRetryResponseCodes()*/, + const FRetryVerbs& InRetryVerbs /*= FRetryVerbs()*/, + const FRetryDomainsPtr& InRetryDomains /*= FRetryDomainsPtr() */) + : RetryLimitCountOverride(InRetryLimitCountOverride) + , RetryTimeoutRelativeSecondsOverride(InRetryTimeoutRelativeSecondsOverride) + , RetryResponseCodes(InRetryResponseCodes) + , RetryVerbs(InRetryVerbs) + , RetryDomains(InRetryDomains) +{ +} + void Response::SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) { ResponseCode = InHttpResponseCode; @@ -18,15 +35,6 @@ void Response::SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) } } -void Response::AsyncRetry() const -{ - // Unfortunately, it is currently usafe to call ProcessRequest() directly here. - // This is because the HttpManager will remove all references to this HttpRequest in FHttpManager::Tick including the new request we just added, instead of removing just one. - // This will lead to the request's destruction and eventually a crash. - // The only solution is therefore to ensure we are taking an extra reference to the request, and that the request is added after the queue is flushed. - Async(EAsyncExecution::TaskGraph, [AddRef = FHttpRequestPtr(GetHttpRequest())](){ AddRef->ProcessRequest(); }); -} - {{#cppNamespaceDeclarations}} } {{/cppNamespaceDeclarations}} \ No newline at end of file diff --git a/samples/client/petstore/cpp-ue4/Private/OpenAPIBaseModel.cpp b/samples/client/petstore/cpp-ue4/Private/OpenAPIBaseModel.cpp index b277e2570285..f8552ac0b7d9 100644 --- a/samples/client/petstore/cpp-ue4/Private/OpenAPIBaseModel.cpp +++ b/samples/client/petstore/cpp-ue4/Private/OpenAPIBaseModel.cpp @@ -12,11 +12,28 @@ #include "OpenAPIBaseModel.h" -#include "Async/Async.h" - namespace OpenAPI { +bool HttpRetryManager::Tick(float DeltaTime) +{ + FManager::Update(); + return true; +} + +HttpRetryParams::HttpRetryParams(const FRetryLimitCountSetting& InRetryLimitCountOverride /*= FRetryLimitCountSetting()*/, + const FRetryTimeoutRelativeSecondsSetting& InRetryTimeoutRelativeSecondsOverride /*= FRetryTimeoutRelativeSecondsSetting()*/, + const FRetryResponseCodes& InRetryResponseCodes /*= FRetryResponseCodes()*/, + const FRetryVerbs& InRetryVerbs /*= FRetryVerbs()*/, + const FRetryDomainsPtr& InRetryDomains /*= FRetryDomainsPtr() */) + : RetryLimitCountOverride(InRetryLimitCountOverride) + , RetryTimeoutRelativeSecondsOverride(InRetryTimeoutRelativeSecondsOverride) + , RetryResponseCodes(InRetryResponseCodes) + , RetryVerbs(InRetryVerbs) + , RetryDomains(InRetryDomains) +{ +} + void Response::SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) { ResponseCode = InHttpResponseCode; @@ -27,13 +44,4 @@ void Response::SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) } } -void Response::AsyncRetry() const -{ - // Unfortunately, it is currently usafe to call ProcessRequest() directly here. - // This is because the HttpManager will remove all references to this HttpRequest in FHttpManager::Tick including the new request we just added, instead of removing just one. - // This will lead to the request's destruction and eventually a crash. - // The only solution is therefore to ensure we are taking an extra reference to the request, and that the request is added after the queue is flushed. - Async(EAsyncExecution::TaskGraph, [AddRef = FHttpRequestPtr(GetHttpRequest())](){ AddRef->ProcessRequest(); }); -} - } diff --git a/samples/client/petstore/cpp-ue4/Private/OpenAPIPetApi.cpp b/samples/client/petstore/cpp-ue4/Private/OpenAPIPetApi.cpp index 68a0d933aca7..72d2c58ea6e1 100644 --- a/samples/client/petstore/cpp-ue4/Private/OpenAPIPetApi.cpp +++ b/samples/client/petstore/cpp-ue4/Private/OpenAPIPetApi.cpp @@ -54,6 +54,40 @@ bool OpenAPIPetApi::IsValid() const return true; } +void OpenAPIPetApi::SetHttpRetryManager(FHttpRetrySystem::FManager& InRetryManager) +{ + if(RetryManager != &GetHttpRetryManager()) + { + DefaultRetryManager.Reset(); + RetryManager = &InRetryManager; + } +} + +FHttpRetrySystem::FManager& OpenAPIPetApi::GetHttpRetryManager() +{ + return *RetryManager; +} + +FHttpRequestRef OpenAPIPetApi::CreateHttpRequest(const Request& Request) const +{ + if (!Request.GetRetryParams().IsSet()) + { + return FHttpModule::Get().CreateRequest(); + } + else + { + if (!RetryManager) + { + // Create default retry manager if none was specified + DefaultRetryManager = MakeUnique(6, 60); + RetryManager = DefaultRetryManager.Get(); + } + + const HttpRetryParams& Params = Request.GetRetryParams().GetValue(); + return RetryManager->CreateRequest(Params.RetryLimitCountOverride, Params.RetryTimeoutRelativeSecondsOverride, Params.RetryResponseCodes, Params.RetryVerbs, Params.RetryDomains); + } +} + void OpenAPIPetApi::HandleResponse(FHttpResponsePtr HttpResponse, bool bSucceeded, Response& InOutResponse) const { InOutResponse.SetHttpResponse(HttpResponse); @@ -103,7 +137,7 @@ bool OpenAPIPetApi::AddPet(const AddPetRequest& Request, const FAddPetDelegate& if (!IsValid()) return false; - FHttpRequestRef HttpRequest = FHttpModule::Get().CreateRequest(); + FHttpRequestRef HttpRequest = CreateHttpRequest(Request); HttpRequest->SetURL(*(Url + Request.ComputePath())); for(const auto& It : AdditionalHeaderParams) @@ -113,26 +147,15 @@ bool OpenAPIPetApi::AddPet(const AddPetRequest& Request, const FAddPetDelegate& Request.SetupHttpRequest(HttpRequest); - HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnAddPetResponse, Delegate, Request.GetAutoRetryCount()); + HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnAddPetResponse, Delegate); return HttpRequest->ProcessRequest(); } -void OpenAPIPetApi::OnAddPetResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FAddPetDelegate Delegate, int AutoRetryCount) const +void OpenAPIPetApi::OnAddPetResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FAddPetDelegate Delegate) const { AddPetResponse Response; - Response.SetHttpRequest(HttpRequest); - HandleResponse(HttpResponse, bSucceeded, Response); - - if(!Response.IsSuccessful() && AutoRetryCount > 0) - { - HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnAddPetResponse, Delegate, AutoRetryCount - 1); - Response.AsyncRetry(); - } - else - { - Delegate.ExecuteIfBound(Response); - } + Delegate.ExecuteIfBound(Response); } bool OpenAPIPetApi::DeletePet(const DeletePetRequest& Request, const FDeletePetDelegate& Delegate /*= FDeletePetDelegate()*/) const @@ -140,7 +163,7 @@ bool OpenAPIPetApi::DeletePet(const DeletePetRequest& Request, const FDeletePetD if (!IsValid()) return false; - FHttpRequestRef HttpRequest = FHttpModule::Get().CreateRequest(); + FHttpRequestRef HttpRequest = CreateHttpRequest(Request); HttpRequest->SetURL(*(Url + Request.ComputePath())); for(const auto& It : AdditionalHeaderParams) @@ -150,26 +173,15 @@ bool OpenAPIPetApi::DeletePet(const DeletePetRequest& Request, const FDeletePetD Request.SetupHttpRequest(HttpRequest); - HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnDeletePetResponse, Delegate, Request.GetAutoRetryCount()); + HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnDeletePetResponse, Delegate); return HttpRequest->ProcessRequest(); } -void OpenAPIPetApi::OnDeletePetResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FDeletePetDelegate Delegate, int AutoRetryCount) const +void OpenAPIPetApi::OnDeletePetResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FDeletePetDelegate Delegate) const { DeletePetResponse Response; - Response.SetHttpRequest(HttpRequest); - HandleResponse(HttpResponse, bSucceeded, Response); - - if(!Response.IsSuccessful() && AutoRetryCount > 0) - { - HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnDeletePetResponse, Delegate, AutoRetryCount - 1); - Response.AsyncRetry(); - } - else - { - Delegate.ExecuteIfBound(Response); - } + Delegate.ExecuteIfBound(Response); } bool OpenAPIPetApi::FindPetsByStatus(const FindPetsByStatusRequest& Request, const FFindPetsByStatusDelegate& Delegate /*= FFindPetsByStatusDelegate()*/) const @@ -177,7 +189,7 @@ bool OpenAPIPetApi::FindPetsByStatus(const FindPetsByStatusRequest& Request, con if (!IsValid()) return false; - FHttpRequestRef HttpRequest = FHttpModule::Get().CreateRequest(); + FHttpRequestRef HttpRequest = CreateHttpRequest(Request); HttpRequest->SetURL(*(Url + Request.ComputePath())); for(const auto& It : AdditionalHeaderParams) @@ -187,26 +199,15 @@ bool OpenAPIPetApi::FindPetsByStatus(const FindPetsByStatusRequest& Request, con Request.SetupHttpRequest(HttpRequest); - HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnFindPetsByStatusResponse, Delegate, Request.GetAutoRetryCount()); + HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnFindPetsByStatusResponse, Delegate); return HttpRequest->ProcessRequest(); } -void OpenAPIPetApi::OnFindPetsByStatusResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FFindPetsByStatusDelegate Delegate, int AutoRetryCount) const +void OpenAPIPetApi::OnFindPetsByStatusResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FFindPetsByStatusDelegate Delegate) const { FindPetsByStatusResponse Response; - Response.SetHttpRequest(HttpRequest); - HandleResponse(HttpResponse, bSucceeded, Response); - - if(!Response.IsSuccessful() && AutoRetryCount > 0) - { - HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnFindPetsByStatusResponse, Delegate, AutoRetryCount - 1); - Response.AsyncRetry(); - } - else - { - Delegate.ExecuteIfBound(Response); - } + Delegate.ExecuteIfBound(Response); } bool OpenAPIPetApi::FindPetsByTags(const FindPetsByTagsRequest& Request, const FFindPetsByTagsDelegate& Delegate /*= FFindPetsByTagsDelegate()*/) const @@ -214,7 +215,7 @@ bool OpenAPIPetApi::FindPetsByTags(const FindPetsByTagsRequest& Request, const F if (!IsValid()) return false; - FHttpRequestRef HttpRequest = FHttpModule::Get().CreateRequest(); + FHttpRequestRef HttpRequest = CreateHttpRequest(Request); HttpRequest->SetURL(*(Url + Request.ComputePath())); for(const auto& It : AdditionalHeaderParams) @@ -224,26 +225,15 @@ bool OpenAPIPetApi::FindPetsByTags(const FindPetsByTagsRequest& Request, const F Request.SetupHttpRequest(HttpRequest); - HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnFindPetsByTagsResponse, Delegate, Request.GetAutoRetryCount()); + HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnFindPetsByTagsResponse, Delegate); return HttpRequest->ProcessRequest(); } -void OpenAPIPetApi::OnFindPetsByTagsResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FFindPetsByTagsDelegate Delegate, int AutoRetryCount) const +void OpenAPIPetApi::OnFindPetsByTagsResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FFindPetsByTagsDelegate Delegate) const { FindPetsByTagsResponse Response; - Response.SetHttpRequest(HttpRequest); - HandleResponse(HttpResponse, bSucceeded, Response); - - if(!Response.IsSuccessful() && AutoRetryCount > 0) - { - HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnFindPetsByTagsResponse, Delegate, AutoRetryCount - 1); - Response.AsyncRetry(); - } - else - { - Delegate.ExecuteIfBound(Response); - } + Delegate.ExecuteIfBound(Response); } bool OpenAPIPetApi::GetPetById(const GetPetByIdRequest& Request, const FGetPetByIdDelegate& Delegate /*= FGetPetByIdDelegate()*/) const @@ -251,7 +241,7 @@ bool OpenAPIPetApi::GetPetById(const GetPetByIdRequest& Request, const FGetPetBy if (!IsValid()) return false; - FHttpRequestRef HttpRequest = FHttpModule::Get().CreateRequest(); + FHttpRequestRef HttpRequest = CreateHttpRequest(Request); HttpRequest->SetURL(*(Url + Request.ComputePath())); for(const auto& It : AdditionalHeaderParams) @@ -261,26 +251,15 @@ bool OpenAPIPetApi::GetPetById(const GetPetByIdRequest& Request, const FGetPetBy Request.SetupHttpRequest(HttpRequest); - HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnGetPetByIdResponse, Delegate, Request.GetAutoRetryCount()); + HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnGetPetByIdResponse, Delegate); return HttpRequest->ProcessRequest(); } -void OpenAPIPetApi::OnGetPetByIdResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FGetPetByIdDelegate Delegate, int AutoRetryCount) const +void OpenAPIPetApi::OnGetPetByIdResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FGetPetByIdDelegate Delegate) const { GetPetByIdResponse Response; - Response.SetHttpRequest(HttpRequest); - HandleResponse(HttpResponse, bSucceeded, Response); - - if(!Response.IsSuccessful() && AutoRetryCount > 0) - { - HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnGetPetByIdResponse, Delegate, AutoRetryCount - 1); - Response.AsyncRetry(); - } - else - { - Delegate.ExecuteIfBound(Response); - } + Delegate.ExecuteIfBound(Response); } bool OpenAPIPetApi::UpdatePet(const UpdatePetRequest& Request, const FUpdatePetDelegate& Delegate /*= FUpdatePetDelegate()*/) const @@ -288,7 +267,7 @@ bool OpenAPIPetApi::UpdatePet(const UpdatePetRequest& Request, const FUpdatePetD if (!IsValid()) return false; - FHttpRequestRef HttpRequest = FHttpModule::Get().CreateRequest(); + FHttpRequestRef HttpRequest = CreateHttpRequest(Request); HttpRequest->SetURL(*(Url + Request.ComputePath())); for(const auto& It : AdditionalHeaderParams) @@ -298,26 +277,15 @@ bool OpenAPIPetApi::UpdatePet(const UpdatePetRequest& Request, const FUpdatePetD Request.SetupHttpRequest(HttpRequest); - HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnUpdatePetResponse, Delegate, Request.GetAutoRetryCount()); + HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnUpdatePetResponse, Delegate); return HttpRequest->ProcessRequest(); } -void OpenAPIPetApi::OnUpdatePetResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FUpdatePetDelegate Delegate, int AutoRetryCount) const +void OpenAPIPetApi::OnUpdatePetResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FUpdatePetDelegate Delegate) const { UpdatePetResponse Response; - Response.SetHttpRequest(HttpRequest); - HandleResponse(HttpResponse, bSucceeded, Response); - - if(!Response.IsSuccessful() && AutoRetryCount > 0) - { - HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnUpdatePetResponse, Delegate, AutoRetryCount - 1); - Response.AsyncRetry(); - } - else - { - Delegate.ExecuteIfBound(Response); - } + Delegate.ExecuteIfBound(Response); } bool OpenAPIPetApi::UpdatePetWithForm(const UpdatePetWithFormRequest& Request, const FUpdatePetWithFormDelegate& Delegate /*= FUpdatePetWithFormDelegate()*/) const @@ -325,7 +293,7 @@ bool OpenAPIPetApi::UpdatePetWithForm(const UpdatePetWithFormRequest& Request, c if (!IsValid()) return false; - FHttpRequestRef HttpRequest = FHttpModule::Get().CreateRequest(); + FHttpRequestRef HttpRequest = CreateHttpRequest(Request); HttpRequest->SetURL(*(Url + Request.ComputePath())); for(const auto& It : AdditionalHeaderParams) @@ -335,26 +303,15 @@ bool OpenAPIPetApi::UpdatePetWithForm(const UpdatePetWithFormRequest& Request, c Request.SetupHttpRequest(HttpRequest); - HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnUpdatePetWithFormResponse, Delegate, Request.GetAutoRetryCount()); + HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnUpdatePetWithFormResponse, Delegate); return HttpRequest->ProcessRequest(); } -void OpenAPIPetApi::OnUpdatePetWithFormResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FUpdatePetWithFormDelegate Delegate, int AutoRetryCount) const +void OpenAPIPetApi::OnUpdatePetWithFormResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FUpdatePetWithFormDelegate Delegate) const { UpdatePetWithFormResponse Response; - Response.SetHttpRequest(HttpRequest); - HandleResponse(HttpResponse, bSucceeded, Response); - - if(!Response.IsSuccessful() && AutoRetryCount > 0) - { - HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnUpdatePetWithFormResponse, Delegate, AutoRetryCount - 1); - Response.AsyncRetry(); - } - else - { - Delegate.ExecuteIfBound(Response); - } + Delegate.ExecuteIfBound(Response); } bool OpenAPIPetApi::UploadFile(const UploadFileRequest& Request, const FUploadFileDelegate& Delegate /*= FUploadFileDelegate()*/) const @@ -362,7 +319,7 @@ bool OpenAPIPetApi::UploadFile(const UploadFileRequest& Request, const FUploadFi if (!IsValid()) return false; - FHttpRequestRef HttpRequest = FHttpModule::Get().CreateRequest(); + FHttpRequestRef HttpRequest = CreateHttpRequest(Request); HttpRequest->SetURL(*(Url + Request.ComputePath())); for(const auto& It : AdditionalHeaderParams) @@ -372,26 +329,15 @@ bool OpenAPIPetApi::UploadFile(const UploadFileRequest& Request, const FUploadFi Request.SetupHttpRequest(HttpRequest); - HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnUploadFileResponse, Delegate, Request.GetAutoRetryCount()); + HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnUploadFileResponse, Delegate); return HttpRequest->ProcessRequest(); } -void OpenAPIPetApi::OnUploadFileResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FUploadFileDelegate Delegate, int AutoRetryCount) const +void OpenAPIPetApi::OnUploadFileResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FUploadFileDelegate Delegate) const { UploadFileResponse Response; - Response.SetHttpRequest(HttpRequest); - HandleResponse(HttpResponse, bSucceeded, Response); - - if(!Response.IsSuccessful() && AutoRetryCount > 0) - { - HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIPetApi::OnUploadFileResponse, Delegate, AutoRetryCount - 1); - Response.AsyncRetry(); - } - else - { - Delegate.ExecuteIfBound(Response); - } + Delegate.ExecuteIfBound(Response); } } diff --git a/samples/client/petstore/cpp-ue4/Private/OpenAPIStoreApi.cpp b/samples/client/petstore/cpp-ue4/Private/OpenAPIStoreApi.cpp index 32000a959073..ed25814006e0 100644 --- a/samples/client/petstore/cpp-ue4/Private/OpenAPIStoreApi.cpp +++ b/samples/client/petstore/cpp-ue4/Private/OpenAPIStoreApi.cpp @@ -54,6 +54,40 @@ bool OpenAPIStoreApi::IsValid() const return true; } +void OpenAPIStoreApi::SetHttpRetryManager(FHttpRetrySystem::FManager& InRetryManager) +{ + if(RetryManager != &GetHttpRetryManager()) + { + DefaultRetryManager.Reset(); + RetryManager = &InRetryManager; + } +} + +FHttpRetrySystem::FManager& OpenAPIStoreApi::GetHttpRetryManager() +{ + return *RetryManager; +} + +FHttpRequestRef OpenAPIStoreApi::CreateHttpRequest(const Request& Request) const +{ + if (!Request.GetRetryParams().IsSet()) + { + return FHttpModule::Get().CreateRequest(); + } + else + { + if (!RetryManager) + { + // Create default retry manager if none was specified + DefaultRetryManager = MakeUnique(6, 60); + RetryManager = DefaultRetryManager.Get(); + } + + const HttpRetryParams& Params = Request.GetRetryParams().GetValue(); + return RetryManager->CreateRequest(Params.RetryLimitCountOverride, Params.RetryTimeoutRelativeSecondsOverride, Params.RetryResponseCodes, Params.RetryVerbs, Params.RetryDomains); + } +} + void OpenAPIStoreApi::HandleResponse(FHttpResponsePtr HttpResponse, bool bSucceeded, Response& InOutResponse) const { InOutResponse.SetHttpResponse(HttpResponse); @@ -103,7 +137,7 @@ bool OpenAPIStoreApi::DeleteOrder(const DeleteOrderRequest& Request, const FDele if (!IsValid()) return false; - FHttpRequestRef HttpRequest = FHttpModule::Get().CreateRequest(); + FHttpRequestRef HttpRequest = CreateHttpRequest(Request); HttpRequest->SetURL(*(Url + Request.ComputePath())); for(const auto& It : AdditionalHeaderParams) @@ -113,26 +147,15 @@ bool OpenAPIStoreApi::DeleteOrder(const DeleteOrderRequest& Request, const FDele Request.SetupHttpRequest(HttpRequest); - HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIStoreApi::OnDeleteOrderResponse, Delegate, Request.GetAutoRetryCount()); + HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIStoreApi::OnDeleteOrderResponse, Delegate); return HttpRequest->ProcessRequest(); } -void OpenAPIStoreApi::OnDeleteOrderResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FDeleteOrderDelegate Delegate, int AutoRetryCount) const +void OpenAPIStoreApi::OnDeleteOrderResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FDeleteOrderDelegate Delegate) const { DeleteOrderResponse Response; - Response.SetHttpRequest(HttpRequest); - HandleResponse(HttpResponse, bSucceeded, Response); - - if(!Response.IsSuccessful() && AutoRetryCount > 0) - { - HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIStoreApi::OnDeleteOrderResponse, Delegate, AutoRetryCount - 1); - Response.AsyncRetry(); - } - else - { - Delegate.ExecuteIfBound(Response); - } + Delegate.ExecuteIfBound(Response); } bool OpenAPIStoreApi::GetInventory(const GetInventoryRequest& Request, const FGetInventoryDelegate& Delegate /*= FGetInventoryDelegate()*/) const @@ -140,7 +163,7 @@ bool OpenAPIStoreApi::GetInventory(const GetInventoryRequest& Request, const FGe if (!IsValid()) return false; - FHttpRequestRef HttpRequest = FHttpModule::Get().CreateRequest(); + FHttpRequestRef HttpRequest = CreateHttpRequest(Request); HttpRequest->SetURL(*(Url + Request.ComputePath())); for(const auto& It : AdditionalHeaderParams) @@ -150,26 +173,15 @@ bool OpenAPIStoreApi::GetInventory(const GetInventoryRequest& Request, const FGe Request.SetupHttpRequest(HttpRequest); - HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIStoreApi::OnGetInventoryResponse, Delegate, Request.GetAutoRetryCount()); + HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIStoreApi::OnGetInventoryResponse, Delegate); return HttpRequest->ProcessRequest(); } -void OpenAPIStoreApi::OnGetInventoryResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FGetInventoryDelegate Delegate, int AutoRetryCount) const +void OpenAPIStoreApi::OnGetInventoryResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FGetInventoryDelegate Delegate) const { GetInventoryResponse Response; - Response.SetHttpRequest(HttpRequest); - HandleResponse(HttpResponse, bSucceeded, Response); - - if(!Response.IsSuccessful() && AutoRetryCount > 0) - { - HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIStoreApi::OnGetInventoryResponse, Delegate, AutoRetryCount - 1); - Response.AsyncRetry(); - } - else - { - Delegate.ExecuteIfBound(Response); - } + Delegate.ExecuteIfBound(Response); } bool OpenAPIStoreApi::GetOrderById(const GetOrderByIdRequest& Request, const FGetOrderByIdDelegate& Delegate /*= FGetOrderByIdDelegate()*/) const @@ -177,7 +189,7 @@ bool OpenAPIStoreApi::GetOrderById(const GetOrderByIdRequest& Request, const FGe if (!IsValid()) return false; - FHttpRequestRef HttpRequest = FHttpModule::Get().CreateRequest(); + FHttpRequestRef HttpRequest = CreateHttpRequest(Request); HttpRequest->SetURL(*(Url + Request.ComputePath())); for(const auto& It : AdditionalHeaderParams) @@ -187,26 +199,15 @@ bool OpenAPIStoreApi::GetOrderById(const GetOrderByIdRequest& Request, const FGe Request.SetupHttpRequest(HttpRequest); - HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIStoreApi::OnGetOrderByIdResponse, Delegate, Request.GetAutoRetryCount()); + HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIStoreApi::OnGetOrderByIdResponse, Delegate); return HttpRequest->ProcessRequest(); } -void OpenAPIStoreApi::OnGetOrderByIdResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FGetOrderByIdDelegate Delegate, int AutoRetryCount) const +void OpenAPIStoreApi::OnGetOrderByIdResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FGetOrderByIdDelegate Delegate) const { GetOrderByIdResponse Response; - Response.SetHttpRequest(HttpRequest); - HandleResponse(HttpResponse, bSucceeded, Response); - - if(!Response.IsSuccessful() && AutoRetryCount > 0) - { - HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIStoreApi::OnGetOrderByIdResponse, Delegate, AutoRetryCount - 1); - Response.AsyncRetry(); - } - else - { - Delegate.ExecuteIfBound(Response); - } + Delegate.ExecuteIfBound(Response); } bool OpenAPIStoreApi::PlaceOrder(const PlaceOrderRequest& Request, const FPlaceOrderDelegate& Delegate /*= FPlaceOrderDelegate()*/) const @@ -214,7 +215,7 @@ bool OpenAPIStoreApi::PlaceOrder(const PlaceOrderRequest& Request, const FPlaceO if (!IsValid()) return false; - FHttpRequestRef HttpRequest = FHttpModule::Get().CreateRequest(); + FHttpRequestRef HttpRequest = CreateHttpRequest(Request); HttpRequest->SetURL(*(Url + Request.ComputePath())); for(const auto& It : AdditionalHeaderParams) @@ -224,26 +225,15 @@ bool OpenAPIStoreApi::PlaceOrder(const PlaceOrderRequest& Request, const FPlaceO Request.SetupHttpRequest(HttpRequest); - HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIStoreApi::OnPlaceOrderResponse, Delegate, Request.GetAutoRetryCount()); + HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIStoreApi::OnPlaceOrderResponse, Delegate); return HttpRequest->ProcessRequest(); } -void OpenAPIStoreApi::OnPlaceOrderResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FPlaceOrderDelegate Delegate, int AutoRetryCount) const +void OpenAPIStoreApi::OnPlaceOrderResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FPlaceOrderDelegate Delegate) const { PlaceOrderResponse Response; - Response.SetHttpRequest(HttpRequest); - HandleResponse(HttpResponse, bSucceeded, Response); - - if(!Response.IsSuccessful() && AutoRetryCount > 0) - { - HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIStoreApi::OnPlaceOrderResponse, Delegate, AutoRetryCount - 1); - Response.AsyncRetry(); - } - else - { - Delegate.ExecuteIfBound(Response); - } + Delegate.ExecuteIfBound(Response); } } diff --git a/samples/client/petstore/cpp-ue4/Private/OpenAPIUserApi.cpp b/samples/client/petstore/cpp-ue4/Private/OpenAPIUserApi.cpp index 9fdd937b3b9e..8f38a6358f46 100644 --- a/samples/client/petstore/cpp-ue4/Private/OpenAPIUserApi.cpp +++ b/samples/client/petstore/cpp-ue4/Private/OpenAPIUserApi.cpp @@ -54,6 +54,40 @@ bool OpenAPIUserApi::IsValid() const return true; } +void OpenAPIUserApi::SetHttpRetryManager(FHttpRetrySystem::FManager& InRetryManager) +{ + if(RetryManager != &GetHttpRetryManager()) + { + DefaultRetryManager.Reset(); + RetryManager = &InRetryManager; + } +} + +FHttpRetrySystem::FManager& OpenAPIUserApi::GetHttpRetryManager() +{ + return *RetryManager; +} + +FHttpRequestRef OpenAPIUserApi::CreateHttpRequest(const Request& Request) const +{ + if (!Request.GetRetryParams().IsSet()) + { + return FHttpModule::Get().CreateRequest(); + } + else + { + if (!RetryManager) + { + // Create default retry manager if none was specified + DefaultRetryManager = MakeUnique(6, 60); + RetryManager = DefaultRetryManager.Get(); + } + + const HttpRetryParams& Params = Request.GetRetryParams().GetValue(); + return RetryManager->CreateRequest(Params.RetryLimitCountOverride, Params.RetryTimeoutRelativeSecondsOverride, Params.RetryResponseCodes, Params.RetryVerbs, Params.RetryDomains); + } +} + void OpenAPIUserApi::HandleResponse(FHttpResponsePtr HttpResponse, bool bSucceeded, Response& InOutResponse) const { InOutResponse.SetHttpResponse(HttpResponse); @@ -103,7 +137,7 @@ bool OpenAPIUserApi::CreateUser(const CreateUserRequest& Request, const FCreateU if (!IsValid()) return false; - FHttpRequestRef HttpRequest = FHttpModule::Get().CreateRequest(); + FHttpRequestRef HttpRequest = CreateHttpRequest(Request); HttpRequest->SetURL(*(Url + Request.ComputePath())); for(const auto& It : AdditionalHeaderParams) @@ -113,26 +147,15 @@ bool OpenAPIUserApi::CreateUser(const CreateUserRequest& Request, const FCreateU Request.SetupHttpRequest(HttpRequest); - HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnCreateUserResponse, Delegate, Request.GetAutoRetryCount()); + HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnCreateUserResponse, Delegate); return HttpRequest->ProcessRequest(); } -void OpenAPIUserApi::OnCreateUserResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FCreateUserDelegate Delegate, int AutoRetryCount) const +void OpenAPIUserApi::OnCreateUserResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FCreateUserDelegate Delegate) const { CreateUserResponse Response; - Response.SetHttpRequest(HttpRequest); - HandleResponse(HttpResponse, bSucceeded, Response); - - if(!Response.IsSuccessful() && AutoRetryCount > 0) - { - HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnCreateUserResponse, Delegate, AutoRetryCount - 1); - Response.AsyncRetry(); - } - else - { - Delegate.ExecuteIfBound(Response); - } + Delegate.ExecuteIfBound(Response); } bool OpenAPIUserApi::CreateUsersWithArrayInput(const CreateUsersWithArrayInputRequest& Request, const FCreateUsersWithArrayInputDelegate& Delegate /*= FCreateUsersWithArrayInputDelegate()*/) const @@ -140,7 +163,7 @@ bool OpenAPIUserApi::CreateUsersWithArrayInput(const CreateUsersWithArrayInputRe if (!IsValid()) return false; - FHttpRequestRef HttpRequest = FHttpModule::Get().CreateRequest(); + FHttpRequestRef HttpRequest = CreateHttpRequest(Request); HttpRequest->SetURL(*(Url + Request.ComputePath())); for(const auto& It : AdditionalHeaderParams) @@ -150,26 +173,15 @@ bool OpenAPIUserApi::CreateUsersWithArrayInput(const CreateUsersWithArrayInputRe Request.SetupHttpRequest(HttpRequest); - HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnCreateUsersWithArrayInputResponse, Delegate, Request.GetAutoRetryCount()); + HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnCreateUsersWithArrayInputResponse, Delegate); return HttpRequest->ProcessRequest(); } -void OpenAPIUserApi::OnCreateUsersWithArrayInputResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FCreateUsersWithArrayInputDelegate Delegate, int AutoRetryCount) const +void OpenAPIUserApi::OnCreateUsersWithArrayInputResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FCreateUsersWithArrayInputDelegate Delegate) const { CreateUsersWithArrayInputResponse Response; - Response.SetHttpRequest(HttpRequest); - HandleResponse(HttpResponse, bSucceeded, Response); - - if(!Response.IsSuccessful() && AutoRetryCount > 0) - { - HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnCreateUsersWithArrayInputResponse, Delegate, AutoRetryCount - 1); - Response.AsyncRetry(); - } - else - { - Delegate.ExecuteIfBound(Response); - } + Delegate.ExecuteIfBound(Response); } bool OpenAPIUserApi::CreateUsersWithListInput(const CreateUsersWithListInputRequest& Request, const FCreateUsersWithListInputDelegate& Delegate /*= FCreateUsersWithListInputDelegate()*/) const @@ -177,7 +189,7 @@ bool OpenAPIUserApi::CreateUsersWithListInput(const CreateUsersWithListInputRequ if (!IsValid()) return false; - FHttpRequestRef HttpRequest = FHttpModule::Get().CreateRequest(); + FHttpRequestRef HttpRequest = CreateHttpRequest(Request); HttpRequest->SetURL(*(Url + Request.ComputePath())); for(const auto& It : AdditionalHeaderParams) @@ -187,26 +199,15 @@ bool OpenAPIUserApi::CreateUsersWithListInput(const CreateUsersWithListInputRequ Request.SetupHttpRequest(HttpRequest); - HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnCreateUsersWithListInputResponse, Delegate, Request.GetAutoRetryCount()); + HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnCreateUsersWithListInputResponse, Delegate); return HttpRequest->ProcessRequest(); } -void OpenAPIUserApi::OnCreateUsersWithListInputResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FCreateUsersWithListInputDelegate Delegate, int AutoRetryCount) const +void OpenAPIUserApi::OnCreateUsersWithListInputResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FCreateUsersWithListInputDelegate Delegate) const { CreateUsersWithListInputResponse Response; - Response.SetHttpRequest(HttpRequest); - HandleResponse(HttpResponse, bSucceeded, Response); - - if(!Response.IsSuccessful() && AutoRetryCount > 0) - { - HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnCreateUsersWithListInputResponse, Delegate, AutoRetryCount - 1); - Response.AsyncRetry(); - } - else - { - Delegate.ExecuteIfBound(Response); - } + Delegate.ExecuteIfBound(Response); } bool OpenAPIUserApi::DeleteUser(const DeleteUserRequest& Request, const FDeleteUserDelegate& Delegate /*= FDeleteUserDelegate()*/) const @@ -214,7 +215,7 @@ bool OpenAPIUserApi::DeleteUser(const DeleteUserRequest& Request, const FDeleteU if (!IsValid()) return false; - FHttpRequestRef HttpRequest = FHttpModule::Get().CreateRequest(); + FHttpRequestRef HttpRequest = CreateHttpRequest(Request); HttpRequest->SetURL(*(Url + Request.ComputePath())); for(const auto& It : AdditionalHeaderParams) @@ -224,26 +225,15 @@ bool OpenAPIUserApi::DeleteUser(const DeleteUserRequest& Request, const FDeleteU Request.SetupHttpRequest(HttpRequest); - HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnDeleteUserResponse, Delegate, Request.GetAutoRetryCount()); + HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnDeleteUserResponse, Delegate); return HttpRequest->ProcessRequest(); } -void OpenAPIUserApi::OnDeleteUserResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FDeleteUserDelegate Delegate, int AutoRetryCount) const +void OpenAPIUserApi::OnDeleteUserResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FDeleteUserDelegate Delegate) const { DeleteUserResponse Response; - Response.SetHttpRequest(HttpRequest); - HandleResponse(HttpResponse, bSucceeded, Response); - - if(!Response.IsSuccessful() && AutoRetryCount > 0) - { - HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnDeleteUserResponse, Delegate, AutoRetryCount - 1); - Response.AsyncRetry(); - } - else - { - Delegate.ExecuteIfBound(Response); - } + Delegate.ExecuteIfBound(Response); } bool OpenAPIUserApi::GetUserByName(const GetUserByNameRequest& Request, const FGetUserByNameDelegate& Delegate /*= FGetUserByNameDelegate()*/) const @@ -251,7 +241,7 @@ bool OpenAPIUserApi::GetUserByName(const GetUserByNameRequest& Request, const FG if (!IsValid()) return false; - FHttpRequestRef HttpRequest = FHttpModule::Get().CreateRequest(); + FHttpRequestRef HttpRequest = CreateHttpRequest(Request); HttpRequest->SetURL(*(Url + Request.ComputePath())); for(const auto& It : AdditionalHeaderParams) @@ -261,26 +251,15 @@ bool OpenAPIUserApi::GetUserByName(const GetUserByNameRequest& Request, const FG Request.SetupHttpRequest(HttpRequest); - HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnGetUserByNameResponse, Delegate, Request.GetAutoRetryCount()); + HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnGetUserByNameResponse, Delegate); return HttpRequest->ProcessRequest(); } -void OpenAPIUserApi::OnGetUserByNameResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FGetUserByNameDelegate Delegate, int AutoRetryCount) const +void OpenAPIUserApi::OnGetUserByNameResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FGetUserByNameDelegate Delegate) const { GetUserByNameResponse Response; - Response.SetHttpRequest(HttpRequest); - HandleResponse(HttpResponse, bSucceeded, Response); - - if(!Response.IsSuccessful() && AutoRetryCount > 0) - { - HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnGetUserByNameResponse, Delegate, AutoRetryCount - 1); - Response.AsyncRetry(); - } - else - { - Delegate.ExecuteIfBound(Response); - } + Delegate.ExecuteIfBound(Response); } bool OpenAPIUserApi::LoginUser(const LoginUserRequest& Request, const FLoginUserDelegate& Delegate /*= FLoginUserDelegate()*/) const @@ -288,7 +267,7 @@ bool OpenAPIUserApi::LoginUser(const LoginUserRequest& Request, const FLoginUser if (!IsValid()) return false; - FHttpRequestRef HttpRequest = FHttpModule::Get().CreateRequest(); + FHttpRequestRef HttpRequest = CreateHttpRequest(Request); HttpRequest->SetURL(*(Url + Request.ComputePath())); for(const auto& It : AdditionalHeaderParams) @@ -298,26 +277,15 @@ bool OpenAPIUserApi::LoginUser(const LoginUserRequest& Request, const FLoginUser Request.SetupHttpRequest(HttpRequest); - HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnLoginUserResponse, Delegate, Request.GetAutoRetryCount()); + HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnLoginUserResponse, Delegate); return HttpRequest->ProcessRequest(); } -void OpenAPIUserApi::OnLoginUserResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FLoginUserDelegate Delegate, int AutoRetryCount) const +void OpenAPIUserApi::OnLoginUserResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FLoginUserDelegate Delegate) const { LoginUserResponse Response; - Response.SetHttpRequest(HttpRequest); - HandleResponse(HttpResponse, bSucceeded, Response); - - if(!Response.IsSuccessful() && AutoRetryCount > 0) - { - HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnLoginUserResponse, Delegate, AutoRetryCount - 1); - Response.AsyncRetry(); - } - else - { - Delegate.ExecuteIfBound(Response); - } + Delegate.ExecuteIfBound(Response); } bool OpenAPIUserApi::LogoutUser(const LogoutUserRequest& Request, const FLogoutUserDelegate& Delegate /*= FLogoutUserDelegate()*/) const @@ -325,7 +293,7 @@ bool OpenAPIUserApi::LogoutUser(const LogoutUserRequest& Request, const FLogoutU if (!IsValid()) return false; - FHttpRequestRef HttpRequest = FHttpModule::Get().CreateRequest(); + FHttpRequestRef HttpRequest = CreateHttpRequest(Request); HttpRequest->SetURL(*(Url + Request.ComputePath())); for(const auto& It : AdditionalHeaderParams) @@ -335,26 +303,15 @@ bool OpenAPIUserApi::LogoutUser(const LogoutUserRequest& Request, const FLogoutU Request.SetupHttpRequest(HttpRequest); - HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnLogoutUserResponse, Delegate, Request.GetAutoRetryCount()); + HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnLogoutUserResponse, Delegate); return HttpRequest->ProcessRequest(); } -void OpenAPIUserApi::OnLogoutUserResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FLogoutUserDelegate Delegate, int AutoRetryCount) const +void OpenAPIUserApi::OnLogoutUserResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FLogoutUserDelegate Delegate) const { LogoutUserResponse Response; - Response.SetHttpRequest(HttpRequest); - HandleResponse(HttpResponse, bSucceeded, Response); - - if(!Response.IsSuccessful() && AutoRetryCount > 0) - { - HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnLogoutUserResponse, Delegate, AutoRetryCount - 1); - Response.AsyncRetry(); - } - else - { - Delegate.ExecuteIfBound(Response); - } + Delegate.ExecuteIfBound(Response); } bool OpenAPIUserApi::UpdateUser(const UpdateUserRequest& Request, const FUpdateUserDelegate& Delegate /*= FUpdateUserDelegate()*/) const @@ -362,7 +319,7 @@ bool OpenAPIUserApi::UpdateUser(const UpdateUserRequest& Request, const FUpdateU if (!IsValid()) return false; - FHttpRequestRef HttpRequest = FHttpModule::Get().CreateRequest(); + FHttpRequestRef HttpRequest = CreateHttpRequest(Request); HttpRequest->SetURL(*(Url + Request.ComputePath())); for(const auto& It : AdditionalHeaderParams) @@ -372,26 +329,15 @@ bool OpenAPIUserApi::UpdateUser(const UpdateUserRequest& Request, const FUpdateU Request.SetupHttpRequest(HttpRequest); - HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnUpdateUserResponse, Delegate, Request.GetAutoRetryCount()); + HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnUpdateUserResponse, Delegate); return HttpRequest->ProcessRequest(); } -void OpenAPIUserApi::OnUpdateUserResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FUpdateUserDelegate Delegate, int AutoRetryCount) const +void OpenAPIUserApi::OnUpdateUserResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FUpdateUserDelegate Delegate) const { UpdateUserResponse Response; - Response.SetHttpRequest(HttpRequest); - HandleResponse(HttpResponse, bSucceeded, Response); - - if(!Response.IsSuccessful() && AutoRetryCount > 0) - { - HttpRequest->OnProcessRequestComplete().BindRaw(this, &OpenAPIUserApi::OnUpdateUserResponse, Delegate, AutoRetryCount - 1); - Response.AsyncRetry(); - } - else - { - Delegate.ExecuteIfBound(Response); - } + Delegate.ExecuteIfBound(Response); } } diff --git a/samples/client/petstore/cpp-ue4/Public/OpenAPIBaseModel.h b/samples/client/petstore/cpp-ue4/Public/OpenAPIBaseModel.h index d73441e1326c..538589752458 100644 --- a/samples/client/petstore/cpp-ue4/Public/OpenAPIBaseModel.h +++ b/samples/client/petstore/cpp-ue4/Public/OpenAPIBaseModel.h @@ -16,11 +16,38 @@ #include "Interfaces/IHttpResponse.h" #include "Serialization/JsonWriter.h" #include "Dom/JsonObject.h" +#include "HttpRetrySystem.h" +#include "Containers/Ticker.h" namespace OpenAPI { typedef TSharedRef> JsonWriter; +using namespace FHttpRetrySystem; + +struct OPENAPI_API HttpRetryManager : public FManager, public FTickerObjectBase +{ + using FManager::FManager; + + bool Tick(float DeltaTime) final; +}; + +struct OPENAPI_API HttpRetryParams +{ + HttpRetryParams( + const FRetryLimitCountSetting& InRetryLimitCountOverride = FRetryLimitCountSetting(), + const FRetryTimeoutRelativeSecondsSetting& InRetryTimeoutRelativeSecondsOverride = FRetryTimeoutRelativeSecondsSetting(), + const FRetryResponseCodes& InRetryResponseCodes = FRetryResponseCodes(), + const FRetryVerbs& InRetryVerbs = FRetryVerbs(), + const FRetryDomainsPtr& InRetryDomains = FRetryDomainsPtr() + ); + + FRetryLimitCountSetting RetryLimitCountOverride; + FRetryTimeoutRelativeSecondsSetting RetryTimeoutRelativeSecondsOverride; + FRetryResponseCodes RetryResponseCodes; + FRetryVerbs RetryVerbs; + FRetryDomainsPtr RetryDomains; +}; class OPENAPI_API Model { @@ -37,11 +64,12 @@ class OPENAPI_API Request virtual void SetupHttpRequest(const FHttpRequestRef& HttpRequest) const = 0; virtual FString ComputePath() const = 0; - void SetAutoRetryCount(int InCount) { AutoRetryCount = InCount; } - int GetAutoRetryCount() const { return AutoRetryCount; } + /* Enables retry and optionally sets a retry policy for this request */ + void SetShouldRetry(const HttpRetryParams& Params = HttpRetryParams()) { RetryParams = Params; } + const TOptional& GetRetryParams() const { return RetryParams; } private: - int AutoRetryCount = 0; + TOptional RetryParams; }; class OPENAPI_API Response @@ -53,8 +81,6 @@ class OPENAPI_API Response void SetSuccessful(bool InSuccessful) { Successful = InSuccessful; } bool IsSuccessful() const { return Successful; } - void AsyncRetry() const; - virtual void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode); EHttpResponseCodes::Type GetHttpResponseCode() const { return ResponseCode; } @@ -64,15 +90,11 @@ class OPENAPI_API Response void SetHttpResponse(const FHttpResponsePtr& InHttpResponse) { HttpResponse = InHttpResponse; } const FHttpResponsePtr& GetHttpResponse() const { return HttpResponse; } - void SetHttpRequest(const FHttpRequestPtr& InHttpRequest) { HttpRequest = InHttpRequest; } - const FHttpRequestPtr& GetHttpRequest() const { return HttpRequest; } - private: bool Successful; EHttpResponseCodes::Type ResponseCode; FString ResponseString; FHttpResponsePtr HttpResponse; - FHttpRequestPtr HttpRequest; }; } diff --git a/samples/client/petstore/cpp-ue4/Public/OpenAPIPetApi.h b/samples/client/petstore/cpp-ue4/Public/OpenAPIPetApi.h index bde6403c4913..db422a0eccc6 100644 --- a/samples/client/petstore/cpp-ue4/Public/OpenAPIPetApi.h +++ b/samples/client/petstore/cpp-ue4/Public/OpenAPIPetApi.h @@ -24,9 +24,19 @@ class OPENAPI_API OpenAPIPetApi OpenAPIPetApi(); ~OpenAPIPetApi(); + /* Sets the URL Endpoint. + * Note: several fallback endpoints can be configured in request retry policies, see Request::SetShouldRetry */ void SetURL(const FString& Url); + + /* Adds global header params to all requests */ void AddHeaderParam(const FString& Key, const FString& Value); void ClearHeaderParams(); + + /* Sets the retry manager to the user-defined retry manager. User must manage the lifetime of the retry manager. + * If no retry manager is specified and a request needs retries, a default retry manager will be used. + * See also: Request::SetShouldRetry */ + void SetHttpRetryManager(FHttpRetrySystem::FManager& RetryManager); + FHttpRetrySystem::FManager& GetHttpRetryManager(); class AddPetRequest; class AddPetResponse; @@ -63,22 +73,24 @@ class OPENAPI_API OpenAPIPetApi bool UpdatePetWithForm(const UpdatePetWithFormRequest& Request, const FUpdatePetWithFormDelegate& Delegate = FUpdatePetWithFormDelegate()) const; bool UploadFile(const UploadFileRequest& Request, const FUploadFileDelegate& Delegate = FUploadFileDelegate()) const; - private: - void OnAddPetResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FAddPetDelegate Delegate, int AutoRetryCount) const; - void OnDeletePetResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FDeletePetDelegate Delegate, int AutoRetryCount) const; - void OnFindPetsByStatusResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FFindPetsByStatusDelegate Delegate, int AutoRetryCount) const; - void OnFindPetsByTagsResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FFindPetsByTagsDelegate Delegate, int AutoRetryCount) const; - void OnGetPetByIdResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FGetPetByIdDelegate Delegate, int AutoRetryCount) const; - void OnUpdatePetResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FUpdatePetDelegate Delegate, int AutoRetryCount) const; - void OnUpdatePetWithFormResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FUpdatePetWithFormDelegate Delegate, int AutoRetryCount) const; - void OnUploadFileResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FUploadFileDelegate Delegate, int AutoRetryCount) const; + void OnAddPetResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FAddPetDelegate Delegate) const; + void OnDeletePetResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FDeletePetDelegate Delegate) const; + void OnFindPetsByStatusResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FFindPetsByStatusDelegate Delegate) const; + void OnFindPetsByTagsResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FFindPetsByTagsDelegate Delegate) const; + void OnGetPetByIdResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FGetPetByIdDelegate Delegate) const; + void OnUpdatePetResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FUpdatePetDelegate Delegate) const; + void OnUpdatePetWithFormResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FUpdatePetWithFormDelegate Delegate) const; + void OnUploadFileResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FUploadFileDelegate Delegate) const; + FHttpRequestRef CreateHttpRequest(const Request& Request) const; bool IsValid() const; void HandleResponse(FHttpResponsePtr HttpResponse, bool bSucceeded, Response& InOutResponse) const; FString Url; TMap AdditionalHeaderParams; + mutable FHttpRetrySystem::FManager* RetryManager = nullptr; + mutable TUniquePtr DefaultRetryManager; }; } diff --git a/samples/client/petstore/cpp-ue4/Public/OpenAPIStoreApi.h b/samples/client/petstore/cpp-ue4/Public/OpenAPIStoreApi.h index 5f5377327328..934a1b277c74 100644 --- a/samples/client/petstore/cpp-ue4/Public/OpenAPIStoreApi.h +++ b/samples/client/petstore/cpp-ue4/Public/OpenAPIStoreApi.h @@ -24,9 +24,19 @@ class OPENAPI_API OpenAPIStoreApi OpenAPIStoreApi(); ~OpenAPIStoreApi(); + /* Sets the URL Endpoint. + * Note: several fallback endpoints can be configured in request retry policies, see Request::SetShouldRetry */ void SetURL(const FString& Url); + + /* Adds global header params to all requests */ void AddHeaderParam(const FString& Key, const FString& Value); void ClearHeaderParams(); + + /* Sets the retry manager to the user-defined retry manager. User must manage the lifetime of the retry manager. + * If no retry manager is specified and a request needs retries, a default retry manager will be used. + * See also: Request::SetShouldRetry */ + void SetHttpRetryManager(FHttpRetrySystem::FManager& RetryManager); + FHttpRetrySystem::FManager& GetHttpRetryManager(); class DeleteOrderRequest; class DeleteOrderResponse; @@ -47,18 +57,20 @@ class OPENAPI_API OpenAPIStoreApi bool GetOrderById(const GetOrderByIdRequest& Request, const FGetOrderByIdDelegate& Delegate = FGetOrderByIdDelegate()) const; bool PlaceOrder(const PlaceOrderRequest& Request, const FPlaceOrderDelegate& Delegate = FPlaceOrderDelegate()) const; - private: - void OnDeleteOrderResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FDeleteOrderDelegate Delegate, int AutoRetryCount) const; - void OnGetInventoryResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FGetInventoryDelegate Delegate, int AutoRetryCount) const; - void OnGetOrderByIdResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FGetOrderByIdDelegate Delegate, int AutoRetryCount) const; - void OnPlaceOrderResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FPlaceOrderDelegate Delegate, int AutoRetryCount) const; + void OnDeleteOrderResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FDeleteOrderDelegate Delegate) const; + void OnGetInventoryResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FGetInventoryDelegate Delegate) const; + void OnGetOrderByIdResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FGetOrderByIdDelegate Delegate) const; + void OnPlaceOrderResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FPlaceOrderDelegate Delegate) const; + FHttpRequestRef CreateHttpRequest(const Request& Request) const; bool IsValid() const; void HandleResponse(FHttpResponsePtr HttpResponse, bool bSucceeded, Response& InOutResponse) const; FString Url; TMap AdditionalHeaderParams; + mutable FHttpRetrySystem::FManager* RetryManager = nullptr; + mutable TUniquePtr DefaultRetryManager; }; } diff --git a/samples/client/petstore/cpp-ue4/Public/OpenAPIUserApi.h b/samples/client/petstore/cpp-ue4/Public/OpenAPIUserApi.h index e60ce6754039..809c4950125b 100644 --- a/samples/client/petstore/cpp-ue4/Public/OpenAPIUserApi.h +++ b/samples/client/petstore/cpp-ue4/Public/OpenAPIUserApi.h @@ -24,9 +24,19 @@ class OPENAPI_API OpenAPIUserApi OpenAPIUserApi(); ~OpenAPIUserApi(); + /* Sets the URL Endpoint. + * Note: several fallback endpoints can be configured in request retry policies, see Request::SetShouldRetry */ void SetURL(const FString& Url); + + /* Adds global header params to all requests */ void AddHeaderParam(const FString& Key, const FString& Value); void ClearHeaderParams(); + + /* Sets the retry manager to the user-defined retry manager. User must manage the lifetime of the retry manager. + * If no retry manager is specified and a request needs retries, a default retry manager will be used. + * See also: Request::SetShouldRetry */ + void SetHttpRetryManager(FHttpRetrySystem::FManager& RetryManager); + FHttpRetrySystem::FManager& GetHttpRetryManager(); class CreateUserRequest; class CreateUserResponse; @@ -63,22 +73,24 @@ class OPENAPI_API OpenAPIUserApi bool LogoutUser(const LogoutUserRequest& Request, const FLogoutUserDelegate& Delegate = FLogoutUserDelegate()) const; bool UpdateUser(const UpdateUserRequest& Request, const FUpdateUserDelegate& Delegate = FUpdateUserDelegate()) const; - private: - void OnCreateUserResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FCreateUserDelegate Delegate, int AutoRetryCount) const; - void OnCreateUsersWithArrayInputResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FCreateUsersWithArrayInputDelegate Delegate, int AutoRetryCount) const; - void OnCreateUsersWithListInputResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FCreateUsersWithListInputDelegate Delegate, int AutoRetryCount) const; - void OnDeleteUserResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FDeleteUserDelegate Delegate, int AutoRetryCount) const; - void OnGetUserByNameResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FGetUserByNameDelegate Delegate, int AutoRetryCount) const; - void OnLoginUserResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FLoginUserDelegate Delegate, int AutoRetryCount) const; - void OnLogoutUserResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FLogoutUserDelegate Delegate, int AutoRetryCount) const; - void OnUpdateUserResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FUpdateUserDelegate Delegate, int AutoRetryCount) const; + void OnCreateUserResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FCreateUserDelegate Delegate) const; + void OnCreateUsersWithArrayInputResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FCreateUsersWithArrayInputDelegate Delegate) const; + void OnCreateUsersWithListInputResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FCreateUsersWithListInputDelegate Delegate) const; + void OnDeleteUserResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FDeleteUserDelegate Delegate) const; + void OnGetUserByNameResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FGetUserByNameDelegate Delegate) const; + void OnLoginUserResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FLoginUserDelegate Delegate) const; + void OnLogoutUserResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FLogoutUserDelegate Delegate) const; + void OnUpdateUserResponse(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FUpdateUserDelegate Delegate) const; + FHttpRequestRef CreateHttpRequest(const Request& Request) const; bool IsValid() const; void HandleResponse(FHttpResponsePtr HttpResponse, bool bSucceeded, Response& InOutResponse) const; FString Url; TMap AdditionalHeaderParams; + mutable FHttpRetrySystem::FManager* RetryManager = nullptr; + mutable TUniquePtr DefaultRetryManager; }; } From 7703c923f9f93c39a977243a9f3ce36677c0c5ff Mon Sep 17 00:00:00 2001 From: William Cheng Date: Thu, 6 May 2021 12:14:45 +0800 Subject: [PATCH 15/18] update doc --- docs/contributing.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/contributing.md b/docs/contributing.md index a791b0d6f1ba..fe325ae17e16 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -52,6 +52,7 @@ Code change should conform to the programming style guide of the respective lang - C#: https://msdn.microsoft.com/en-us/library/vstudio/ff926074.aspx - C++: https://google.github.io/styleguide/cppguide.html - C++ (Tizen): https://wiki.tizen.org/Native_Platform_Coding_Idiom_and_Style_Guide#C.2B.2B_Coding_Style +- C++ (Unreal Engine 4): https://docs.unrealengine.com/en-US/ProductionPipelines/DevelopmentSetup/CodingStandard/index.html - Clojure: https://github.com/bbatsov/clojure-style-guide - Crystal: https://crystal-lang.org/reference/conventions/coding_style.html - Dart: https://www.dartlang.org/guides/language/effective-dart/style From f4f4d5de0e5dec0e8d23e9faca197180e1f3fb3d Mon Sep 17 00:00:00 2001 From: Bruno Coelho <4brunu@users.noreply.github.com> Date: Thu, 6 May 2021 17:26:22 +0100 Subject: [PATCH 16/18] [kotlin][client] fix warning for non optional header parameter (#9415) --- .../resources/kotlin-client/libraries/jvm-okhttp/api.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-okhttp/api.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-okhttp/api.mustache index 8adf1980e420..7745b52249ab 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-okhttp/api.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-okhttp/api.mustache @@ -97,7 +97,7 @@ import {{packageName}}.infrastructure.toMultiValue {{/hasQueryParams}} val localVariableHeaders: MutableMap = mutableMapOf({{#hasFormParams}}"Content-Type" to {{^consumes}}"multipart/form-data"{{/consumes}}{{#consumes.0}}"{{{mediaType}}}"{{/consumes.0}}{{/hasFormParams}}) {{#headerParams}} - {{{paramName}}}?.apply { localVariableHeaders["{{baseName}}"] = {{#isContainer}}this.joinToString(separator = collectionDelimiter("{{collectionFormat}}")){{/isContainer}}{{^isContainer}}this.toString(){{/isContainer}} } + {{{paramName}}}{{^required}}?{{/required}}.apply { localVariableHeaders["{{baseName}}"] = {{#isContainer}}this.joinToString(separator = collectionDelimiter("{{collectionFormat}}")){{/isContainer}}{{^isContainer}}this.toString(){{/isContainer}} } {{/headerParams}} val localVariableConfig = RequestConfig( From 1dad148b698d142245efbcafe18fd317b7114970 Mon Sep 17 00:00:00 2001 From: Kyle Kelly Date: Wed, 5 May 2021 14:08:02 -0700 Subject: [PATCH 17/18] Add handling for casting uniqueItems from Set to Arrays so they can be properly joined --- .../src/main/resources/Javascript-Flowtyped/api.mustache | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/Javascript-Flowtyped/api.mustache b/modules/openapi-generator/src/main/resources/Javascript-Flowtyped/api.mustache index 35bff5b9687e..d7565ea7ceb6 100644 --- a/modules/openapi-generator/src/main/resources/Javascript-Flowtyped/api.mustache +++ b/modules/openapi-generator/src/main/resources/Javascript-Flowtyped/api.mustache @@ -142,7 +142,7 @@ export const {{classname}}FetchParamCreator = function (configuration?: Configur localVarQueryParameter['{{baseName}}'] = {{paramName}}; {{/isCollectionFormatMulti}} {{^isCollectionFormatMulti}} - localVarQueryParameter['{{baseName}}'] = {{paramName}}.join(COLLECTION_FORMATS["{{collectionFormat}}"]); + localVarQueryParameter['{{baseName}}'] = {{#uniqueItems}}Array.from({{/uniqueItems}}{{paramName}}{{#uniqueItems}}){{/uniqueItems}}.join(COLLECTION_FORMATS["{{collectionFormat}}"]); {{/isCollectionFormatMulti}} } {{/isArray}} @@ -166,7 +166,7 @@ export const {{classname}}FetchParamCreator = function (configuration?: Configur {{#headerParams}} {{#isArray}} if ({{paramName}}) { - localVarHeaderParameter['{{baseName}}'] = {{paramName}}.join(COLLECTION_FORMATS["{{collectionFormat}}"]); + localVarHeaderParameter['{{baseName}}'] = {{#uniqueItems}}Array.from({{/uniqueItems}}{{paramName}}{{#uniqueItems}}){{/uniqueItems}}.join(COLLECTION_FORMATS["{{collectionFormat}}"]); } {{/isArray}} {{^isArray}} @@ -185,7 +185,7 @@ export const {{classname}}FetchParamCreator = function (configuration?: Configur }) {{/isCollectionFormatMulti}} {{^isCollectionFormatMulti}} - localVarFormParams.set('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS["{{collectionFormat}}"])); + localVarFormParams.set('{{baseName}}', {{#uniqueItems}}Array.from({{/uniqueItems}}{{paramName}}{{#uniqueItems}}){{/uniqueItems}}.join(COLLECTION_FORMATS["{{collectionFormat}}"])); {{/isCollectionFormatMulti}} } {{/isArray}} From cde69768c4071e825535acbad1592a116ebf3ffe Mon Sep 17 00:00:00 2001 From: Kyle Kelly Date: Wed, 5 May 2021 14:08:19 -0700 Subject: [PATCH 18/18] Fix mixed-indent lines --- .../resources/Javascript-Flowtyped/api.mustache | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/Javascript-Flowtyped/api.mustache b/modules/openapi-generator/src/main/resources/Javascript-Flowtyped/api.mustache index d7565ea7ceb6..1afc22037510 100644 --- a/modules/openapi-generator/src/main/resources/Javascript-Flowtyped/api.mustache +++ b/modules/openapi-generator/src/main/resources/Javascript-Flowtyped/api.mustache @@ -104,16 +104,16 @@ export const {{classname}}FetchParamCreator = function (configuration?: Configur {{#isKeyInHeader}} if (configuration && configuration.apiKey) { const localVarApiKeyValue = typeof configuration.apiKey === 'function' - ? configuration.apiKey("{{keyParamName}}") - : configuration.apiKey; + ? configuration.apiKey("{{keyParamName}}") + : configuration.apiKey; localVarHeaderParameter["{{keyParamName}}"] = localVarApiKeyValue; } {{/isKeyInHeader}} {{#isKeyInQuery}} if (configuration && configuration.apiKey) { const localVarApiKeyValue = typeof configuration.apiKey === 'function' - ? configuration.apiKey("{{keyParamName}}") - : configuration.apiKey; + ? configuration.apiKey("{{keyParamName}}") + : configuration.apiKey; localVarQueryParameter["{{keyParamName}}"] = localVarApiKeyValue; } {{/isKeyInQuery}} @@ -127,9 +127,9 @@ export const {{classname}}FetchParamCreator = function (configuration?: Configur {{#isOAuth}} // oauth required if (configuration && configuration.accessToken) { - const localVarAccessTokenValue = typeof configuration.accessToken === 'function' - ? configuration.accessToken("{{name}}", [{{#scopes}}"{{{scope}}}"{{^-last}}, {{/-last}}{{/scopes}}]) - : configuration.accessToken; + const localVarAccessTokenValue = typeof configuration.accessToken === 'function' + ? configuration.accessToken("{{name}}", [{{#scopes}}"{{{scope}}}"{{^-last}}, {{/-last}}{{/scopes}}]) + : configuration.accessToken; localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; } {{/isOAuth}}