From 594f055ff9191dbb375f846d341218c1b96b66a7 Mon Sep 17 00:00:00 2001
From: Jiri Kuncar <jiri.kuncar@gmail.com>
Date: Tue, 14 Jan 2020 16:46:43 +0100
Subject: [PATCH 01/10] [java] Support templated servers

---
 .../codegen/languages/JavaClientCodegen.java  |   2 +
 .../main/resources/Java/ApiClient.mustache    |  69 +++++++++-
 .../Java/ServerConfiguration.mustache         |  60 +++++++++
 .../resources/Java/ServerVariable.mustache    |  23 ++++
 .../Java/libraries/jersey2/ApiClient.mustache | 119 +++++++++++++++++-
 .../Java/libraries/jersey2/api.mustache       |   4 +-
 .../codegen/java/JavaClientCodegenTest.java   |   8 +-
 .../client/ServerConfiguration.java           |  60 +++++++++
 .../openapitools/client/ServerVariable.java   |  23 ++++
 .../client/ServerConfiguration.java           |  60 +++++++++
 .../openapitools/client/ServerVariable.java   |  23 ++++
 .../client/ServerConfiguration.java           |  60 +++++++++
 .../openapitools/client/ServerVariable.java   |  23 ++++
 .../org/openapitools/client/ApiClient.java    |  51 +++++++-
 .../client/ServerConfiguration.java           |  60 +++++++++
 .../openapitools/client/ServerVariable.java   |  23 ++++
 .../org/openapitools/client/ApiClient.java    |  64 +++++++++-
 .../client/ServerConfiguration.java           |  60 +++++++++
 .../openapitools/client/ServerVariable.java   |  23 ++++
 .../client/api/AnotherFakeApi.java            |   2 +-
 .../org/openapitools/client/api/FakeApi.java  |  28 ++---
 .../client/api/FakeClassnameTags123Api.java   |   2 +-
 .../org/openapitools/client/api/PetApi.java   |  18 +--
 .../org/openapitools/client/api/StoreApi.java |   8 +-
 .../org/openapitools/client/api/UserApi.java  |  16 +--
 .../org/openapitools/client/ApiClient.java    |  64 +++++++++-
 .../client/ServerConfiguration.java           |  60 +++++++++
 .../openapitools/client/ServerVariable.java   |  23 ++++
 .../client/api/AnotherFakeApi.java            |   2 +-
 .../org/openapitools/client/api/FakeApi.java  |  28 ++---
 .../client/api/FakeClassnameTags123Api.java   |   2 +-
 .../org/openapitools/client/api/PetApi.java   |  18 +--
 .../org/openapitools/client/api/StoreApi.java |   8 +-
 .../org/openapitools/client/api/UserApi.java  |  16 +--
 .../org/openapitools/client/ApiClient.java    |  64 +++++++++-
 .../client/ServerConfiguration.java           |  60 +++++++++
 .../openapitools/client/ServerVariable.java   |  23 ++++
 .../client/api/AnotherFakeApi.java            |   2 +-
 .../org/openapitools/client/api/FakeApi.java  |  28 ++---
 .../client/api/FakeClassnameTags123Api.java   |   2 +-
 .../org/openapitools/client/api/PetApi.java   |  18 +--
 .../org/openapitools/client/api/StoreApi.java |   8 +-
 .../org/openapitools/client/api/UserApi.java  |  16 +--
 .../client/ServerConfiguration.java           |  60 +++++++++
 .../openapitools/client/ServerVariable.java   |  23 ++++
 .../client/ServerConfiguration.java           |  60 +++++++++
 .../openapitools/client/ServerVariable.java   |  23 ++++
 .../client/ServerConfiguration.java           |  60 +++++++++
 .../openapitools/client/ServerVariable.java   |  23 ++++
 .../client/ServerConfiguration.java           |  60 +++++++++
 .../openapitools/client/ServerVariable.java   |  23 ++++
 .../client/ServerConfiguration.java           |  60 +++++++++
 .../openapitools/client/ServerVariable.java   |  23 ++++
 .../client/ServerConfiguration.java           |  60 +++++++++
 .../openapitools/client/ServerVariable.java   |  23 ++++
 .../client/ServerConfiguration.java           |  60 +++++++++
 .../openapitools/client/ServerVariable.java   |  23 ++++
 .../client/ServerConfiguration.java           |  60 +++++++++
 .../openapitools/client/ServerVariable.java   |  23 ++++
 .../client/ServerConfiguration.java           |  60 +++++++++
 .../openapitools/client/ServerVariable.java   |  23 ++++
 .../client/ServerConfiguration.java           |  60 +++++++++
 .../openapitools/client/ServerVariable.java   |  23 ++++
 .../client/ServerConfiguration.java           |  60 +++++++++
 .../openapitools/client/ServerVariable.java   |  23 ++++
 .../client/ServerConfiguration.java           |  60 +++++++++
 .../openapitools/client/ServerVariable.java   |  23 ++++
 .../client/ServerConfiguration.java           |  60 +++++++++
 .../openapitools/client/ServerVariable.java   |  23 ++++
 .../client/ServerConfiguration.java           |  60 +++++++++
 .../openapitools/client/ServerVariable.java   |  23 ++++
 .../client/ServerConfiguration.java           |  60 +++++++++
 .../openapitools/client/ServerVariable.java   |  23 ++++
 .../client/ServerConfiguration.java           |  60 +++++++++
 .../openapitools/client/ServerVariable.java   |  23 ++++
 75 files changed, 2526 insertions(+), 133 deletions(-)
 create mode 100644 modules/openapi-generator/src/main/resources/Java/ServerConfiguration.mustache
 create mode 100644 modules/openapi-generator/src/main/resources/Java/ServerVariable.mustache
 create mode 100644 samples/client/petstore/java/feign/src/main/java/org/openapitools/client/ServerConfiguration.java
 create mode 100644 samples/client/petstore/java/feign/src/main/java/org/openapitools/client/ServerVariable.java
 create mode 100644 samples/client/petstore/java/feign10x/src/main/java/org/openapitools/client/ServerConfiguration.java
 create mode 100644 samples/client/petstore/java/feign10x/src/main/java/org/openapitools/client/ServerVariable.java
 create mode 100644 samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/ServerConfiguration.java
 create mode 100644 samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/ServerVariable.java
 create mode 100644 samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/ServerConfiguration.java
 create mode 100644 samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/ServerVariable.java
 create mode 100644 samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/ServerConfiguration.java
 create mode 100644 samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/ServerVariable.java
 create mode 100644 samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/ServerConfiguration.java
 create mode 100644 samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/ServerVariable.java
 create mode 100644 samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/ServerConfiguration.java
 create mode 100644 samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/ServerVariable.java
 create mode 100644 samples/client/petstore/java/native/src/main/java/org/openapitools/client/ServerConfiguration.java
 create mode 100644 samples/client/petstore/java/native/src/main/java/org/openapitools/client/ServerVariable.java
 create mode 100644 samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/ServerConfiguration.java
 create mode 100644 samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/ServerVariable.java
 create mode 100644 samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ServerConfiguration.java
 create mode 100644 samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ServerVariable.java
 create mode 100644 samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/ServerConfiguration.java
 create mode 100644 samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/ServerVariable.java
 create mode 100644 samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/ServerConfiguration.java
 create mode 100644 samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/ServerVariable.java
 create mode 100644 samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/ServerConfiguration.java
 create mode 100644 samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/ServerVariable.java
 create mode 100644 samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/ServerConfiguration.java
 create mode 100644 samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/ServerVariable.java
 create mode 100644 samples/client/petstore/java/retrofit/src/main/java/org/openapitools/client/ServerConfiguration.java
 create mode 100644 samples/client/petstore/java/retrofit/src/main/java/org/openapitools/client/ServerVariable.java
 create mode 100644 samples/client/petstore/java/retrofit2-play24/src/main/java/org/openapitools/client/ServerConfiguration.java
 create mode 100644 samples/client/petstore/java/retrofit2-play24/src/main/java/org/openapitools/client/ServerVariable.java
 create mode 100644 samples/client/petstore/java/retrofit2-play25/src/main/java/org/openapitools/client/ServerConfiguration.java
 create mode 100644 samples/client/petstore/java/retrofit2-play25/src/main/java/org/openapitools/client/ServerVariable.java
 create mode 100644 samples/client/petstore/java/retrofit2-play26/src/main/java/org/openapitools/client/ServerConfiguration.java
 create mode 100644 samples/client/petstore/java/retrofit2-play26/src/main/java/org/openapitools/client/ServerVariable.java
 create mode 100644 samples/client/petstore/java/retrofit2/src/main/java/org/openapitools/client/ServerConfiguration.java
 create mode 100644 samples/client/petstore/java/retrofit2/src/main/java/org/openapitools/client/ServerVariable.java
 create mode 100644 samples/client/petstore/java/retrofit2rx/src/main/java/org/openapitools/client/ServerConfiguration.java
 create mode 100644 samples/client/petstore/java/retrofit2rx/src/main/java/org/openapitools/client/ServerVariable.java
 create mode 100644 samples/client/petstore/java/retrofit2rx2/src/main/java/org/openapitools/client/ServerConfiguration.java
 create mode 100644 samples/client/petstore/java/retrofit2rx2/src/main/java/org/openapitools/client/ServerVariable.java
 create mode 100644 samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/ServerConfiguration.java
 create mode 100644 samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/ServerVariable.java
 create mode 100644 samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/ServerConfiguration.java
 create mode 100644 samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/ServerVariable.java

diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java
index ef591c7b30e..5e018543af7 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java
@@ -285,6 +285,8 @@ public class JavaClientCodegen extends AbstractJavaCodegen
         writeOptional(outputFolder, new SupportingFile("manifest.mustache", projectFolder, "AndroidManifest.xml"));
         supportingFiles.add(new SupportingFile("travis.mustache", "", ".travis.yml"));
         supportingFiles.add(new SupportingFile("ApiClient.mustache", invokerFolder, "ApiClient.java"));
+        supportingFiles.add(new SupportingFile("ServerConfiguration.mustache", invokerFolder, "ServerConfiguration.java"));
+        supportingFiles.add(new SupportingFile("ServerVariable.mustache", invokerFolder, "ServerVariable.java"));
         if (!(RESTTEMPLATE.equals(getLibrary()) || REST_ASSURED.equals(getLibrary()) || NATIVE.equals(getLibrary()) || MICROPROFILE.equals(getLibrary()))) {
             supportingFiles.add(new SupportingFile("StringUtil.mustache", invokerFolder, "StringUtil.java"));
         }
diff --git a/modules/openapi-generator/src/main/resources/Java/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Java/ApiClient.mustache
index 1ae6c36f68a..fe333042737 100644
--- a/modules/openapi-generator/src/main/resources/Java/ApiClient.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/ApiClient.mustache
@@ -38,7 +38,9 @@ import java.util.Collections;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Arrays;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.TimeZone;
@@ -54,6 +56,8 @@ import {{invokerPackage}}.auth.Authentication;
 import {{invokerPackage}}.auth.HttpBasicAuth;
 import {{invokerPackage}}.auth.HttpBearerAuth;
 import {{invokerPackage}}.auth.ApiKeyAuth;
+import {{invokerPackage}}.ServerConfiguration;
+import {{invokerPackage}}.ServerVariable;
 {{#hasOAuthMethods}}
 import {{invokerPackage}}.auth.OAuth;
 {{/hasOAuthMethods}}
@@ -63,6 +67,33 @@ public class ApiClient {
   private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
   private Map<String, String> defaultCookieMap = new HashMap<String, String>();
   private String basePath = "{{{basePath}}}";
+  protected ServerConfiguration[] servers{{#servers}}{{#-first}} = {
+{{/-first}}    new ServerConfiguration(
+      "{{{url}}}",
+      "{{{description}}}{{^description}}No description provided{{/description}}",
+      new HashMap<String, ServerVariable>(){{#variables}}{{#-first}} {{
+{{/-first}}        put("{{{name}}}", new ServerVariable(
+          "{{{description}}}{{^description}}No description provided{{/description}}",
+          "{{{defaultValue}}}",
+          new HashSet<String>(
+          {{#enumValues}}
+          {{#-first}}
+            Arrays.asList(
+          {{/-first}}
+              "{{{.}}}"{{^-last}},{{/-last}}
+          {{#-last}}
+            )
+          {{/-last}}
+          {{/enumValues}}
+          )
+        ));
+      {{#-last}}
+      }}{{/-last}}{{/variables}}
+    ){{^-last}},{{/-last}}
+  {{#-last}}
+  }{{/-last}}{{/servers}};
+  protected Integer serverIndex = 0;
+  protected Map<String, String> serverVariables = null;
   private boolean debugging = false;
   private int connectionTimeout = 0;
 
@@ -177,6 +208,33 @@ public class ApiClient {
     return this;
   }
 
+  public ServerConfiguration[] getServers() {
+    return servers;
+  }
+
+  public ApiClient setServers(ServerConfiguration[] servers) {
+    this.servers = servers;
+    return this;
+  }
+
+  public Integer getServerIndex() {
+    return serverIndex;
+  }
+
+  public ApiClient setServerIndex(Integer serverIndex) {
+    this.serverIndex = serverIndex;
+    return this;
+  }
+
+  public Map<String, String> getServerVariables() {
+    return serverVariables;
+  }
+
+  public ApiClient setServerVariables(Map<String, String> serverVariables) {
+    this.serverVariables = serverVariables;
+    return this;
+  }
+
   /**
    * Gets the status code of the previous request
    * @return Status code
@@ -252,7 +310,7 @@ public class ApiClient {
     }
     throw new RuntimeException("No API key authentication configured!");
   }
-  
+
   /**
    * Helper method to set API key prefix for the first API key authentication.
    * @param apiKeyPrefix API key prefix
@@ -626,8 +684,15 @@ public class ApiClient {
    * @return The full URL
    */
   private String buildUrl(String path, List<Pair> queryParams, List<Pair> collectionQueryParams) {
+    String baseURL;
+    if (serverIndex != null) {
+      baseURL = servers[serverIndex].URL(serverVariables);
+    } else {
+      baseURL = basePath;
+    }
+
     final StringBuilder url = new StringBuilder();
-    url.append(basePath).append(path);
+    url.append(baseURL).append(path);
 
     if (queryParams != null && !queryParams.isEmpty()) {
       // support (constant) query string in `path`, e.g. "/posts?draft=1"
diff --git a/modules/openapi-generator/src/main/resources/Java/ServerConfiguration.mustache b/modules/openapi-generator/src/main/resources/Java/ServerConfiguration.mustache
new file mode 100644
index 00000000000..c76a097d24c
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/Java/ServerConfiguration.mustache
@@ -0,0 +1,60 @@
+package {{invokerPackage}};
+
+import java.util.Map;
+
+import com.datadog.api.v1.client.ServerVariable;
+
+/**
+ * Representing a Server configuration.
+ */
+public class ServerConfiguration {
+    public String URL;
+    public String description;
+    public Map<String, ServerVariable> variables;
+
+    /**
+     * @param A URL to the target host.
+     * @param description A describtion of the host designated by the URL.
+     * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
+     */
+    public ServerConfiguration(String URL, String description, Map<String, ServerVariable> variables) {
+        this.URL = URL;
+        this.description = description;
+        this.variables = variables;
+    }
+
+    /**
+     * Format URL template using given variables.
+     *
+     * @param variables A map between a variable name and its value.
+     * @return Formatted URL.
+     */
+    public String URL(Map<String, String> variables) {
+        String url = this.URL;
+
+        // go through variables and replace placeholders
+        for (Map.Entry<String, ServerVariable> variable: this.variables.entrySet()) {
+            String name = variable.getKey();
+            ServerVariable serverVariable = variable.getValue();
+            String value = serverVariable.defaultValue;
+
+            if (variables != null && variables.containsKey(name)) {
+                value = variables.get(name);
+                if (serverVariable.enumValues.size() > 0 && !serverVariable.enumValues.contains(value)) {
+                    throw new RuntimeException("The variable " + name + " in the server URL has invalid value " + value + ".");
+                }
+            }
+            url = url.replaceAll("\\{" + name + "\\}", value);
+        }
+        return url;
+    }
+
+    /**
+     * Format URL template using default server variables.
+     *
+     * @return Formatted URL.
+     */
+    public String URL() {
+        return URL(null);
+    }
+}
diff --git a/modules/openapi-generator/src/main/resources/Java/ServerVariable.mustache b/modules/openapi-generator/src/main/resources/Java/ServerVariable.mustache
new file mode 100644
index 00000000000..1978b1eb95e
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/Java/ServerVariable.mustache
@@ -0,0 +1,23 @@
+package {{invokerPackage}};
+
+import java.util.HashSet;
+
+/**
+ * Representing a Server Variable for server URL template substitution.
+ */
+public class ServerVariable {
+    public String description;
+    public String defaultValue;
+    public HashSet<String> enumValues = null;
+
+    /**
+     * @param description A description for the server variable.
+     * @param defaultValue The default value to use for substitution.
+     * @param enumValues An enumeration of string values to be used if the substitution options are from a limited set.
+     */
+    public ServerVariable(String description, String defaultValue, HashSet<String> enumValues) {
+        this.description = description;
+        this.defaultValue = defaultValue;
+        this.enumValues = enumValues;
+    }
+}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/ApiClient.mustache
index b12740b0f64..ee4d7a6d10c 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/ApiClient.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/ApiClient.mustache
@@ -37,7 +37,9 @@ import java.util.Collections;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Arrays;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.TimeZone;
@@ -55,6 +57,9 @@ import {{invokerPackage}}.auth.Authentication;
 import {{invokerPackage}}.auth.HttpBasicAuth;
 import {{invokerPackage}}.auth.HttpBearerAuth;
 import {{invokerPackage}}.auth.ApiKeyAuth;
+import {{invokerPackage}}.ServerConfiguration;
+import {{invokerPackage}}.ServerVariable;
+
 {{#hasOAuthMethods}}
 import {{invokerPackage}}.auth.OAuth;
 {{/hasOAuthMethods}}
@@ -64,6 +69,74 @@ public class ApiClient {
   protected Map<String, String> defaultHeaderMap = new HashMap<String, String>();
   protected Map<String, String> defaultCookieMap = new HashMap<String, String>();
   protected String basePath = "{{{basePath}}}";
+  protected ServerConfiguration[] servers{{#servers}}{{#-first}} = {
+{{/-first}}    new ServerConfiguration(
+      "{{{url}}}",
+      "{{{description}}}{{^description}}No description provided{{/description}}",
+      new HashMap<String, ServerVariable>(){{#variables}}{{#-first}} {{
+{{/-first}}        put("{{{name}}}", new ServerVariable(
+          "{{{description}}}{{^description}}No description provided{{/description}}",
+          "{{{defaultValue}}}",
+          new HashSet<String>(
+          {{#enumValues}}
+          {{#-first}}
+            Arrays.asList(
+          {{/-first}}
+              "{{{.}}}"{{^-last}},{{/-last}}
+          {{#-last}}
+            )
+          {{/-last}}
+          {{/enumValues}}
+          )
+        ));
+      {{#-last}}
+      }}{{/-last}}{{/variables}}
+    ){{^-last}},{{/-last}}
+  {{#-last}}
+  }{{/-last}}{{/servers}};
+  protected Integer serverIndex = 0;
+  protected Map<String, String> serverVariables = null;
+  protected Map<String, List<ServerConfiguration>> operationServers = new HashMap<String, List<ServerConfiguration>>() {{
+    {{#apiInfo}}
+    {{#apis}}
+    {{#operations}}
+    {{#operation}}
+    {{#servers}}
+    {{#-first}}
+    put("{{{classname}}}.{{{operationId}}}", new ArrayList<ServerConfiguration>(Arrays.asList(
+    {{/-first}}
+      new ServerConfiguration(
+        "{{{url}}}",
+        "{{{description}}}{{^description}}No description provided{{/description}}",
+        new HashMap<String, ServerVariable>(){{#variables}}{{#-first}} {{
+{{/-first}}          put("{{{name}}}", new ServerVariable(
+            "{{{description}}}{{^description}}No description provided{{/description}}",
+            "{{{defaultValue}}}",
+            new HashSet<String>(
+            {{#enumValues}}
+            {{#-first}}
+              Arrays.asList(
+            {{/-first}}
+                "{{{.}}}"{{^-last}},{{/-last}}
+            {{#-last}}
+              )
+            {{/-last}}
+            {{/enumValues}}
+            )
+          ));
+        {{#-last}}
+        }}{{/-last}}{{/variables}}
+      ){{^-last}},{{/-last}}
+    {{#-last}}
+    )));{{/-last}}
+    {{/servers}}
+    {{/operation}}
+    {{/operations}}
+    {{/apis}}
+    {{/apiInfo}}
+  }};
+  protected Map<String, Integer> operationServerIndex = new HashMap<String, Integer>();
+  protected Map<String, Map<String, String>> operationServerVariables = new HashMap<String, Map<String, String>>();
   protected boolean debugging = false;
   protected int connectionTimeout = 0;
   private int readTimeout = 0;
@@ -121,6 +194,33 @@ public class ApiClient {
     return this;
   }
 
+  public ServerConfiguration[] getServers() {
+    return servers;
+  }
+
+  public ApiClient setServers(ServerConfiguration[] servers) {
+    this.servers = servers;
+    return this;
+  }
+
+  public Integer getServerIndex() {
+    return serverIndex;
+  }
+
+  public ApiClient setServerIndex(Integer serverIndex) {
+    this.serverIndex = serverIndex;
+    return this;
+  }
+
+  public Map<String, String> getServerVariables() {
+    return serverVariables;
+  }
+
+  public ApiClient setServerVariables(Map<String, String> serverVariables) {
+    this.serverVariables = serverVariables;
+    return this;
+  }
+
   /**
    * Get authentications (key: authentication name, value: authentication).
    * @return Map of authentication object
@@ -670,6 +770,7 @@ public class ApiClient {
    * Invoke API by sending HTTP request with the given options.
    *
    * @param <T> Type
+   * @param operation The qualified name of the operation
    * @param path The sub-path of the HTTP URL
    * @param method The request method, one of "GET", "POST", "PUT", "HEAD" and "DELETE"
    * @param queryParams The query parameters
@@ -684,12 +785,24 @@ public class ApiClient {
    * @return The response body in type of string
    * @throws ApiException API exception
    */
-  public <T> ApiResponse<T> invokeAPI(String path, String method, List<Pair> queryParams, Object body, Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String accept, String contentType, String[] authNames, GenericType<T> returnType) throws ApiException {
+  public <T> ApiResponse<T> invokeAPI(String operation, String path, String method, List<Pair> queryParams, Object body, Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String accept, String contentType, String[] authNames, GenericType<T> returnType) throws ApiException {
     updateParamsForAuth(authNames, queryParams, headerParams, cookieParams);
 
-    // Not using `.target(this.basePath).path(path)` below,
+    // Not using `.target(targetURL).path(path)` below,
     // to support (constant) query string in `path`, e.g. "/posts?draft=1"
-    WebTarget target = httpClient.target(this.basePath + path);
+    String targetURL;
+    if (serverIndex != null) {
+      if (operationServers.containsKey(operation)) {
+        Integer index = operationServerIndex.getOrDefault(operation, serverIndex);
+        Map<String, String> variables = operationServerVariables.getOrDefault(operation, serverVariables);
+        targetURL = operationServers.get(operation).get(index).URL(variables);
+      } else {
+        targetURL = servers[serverIndex].URL(serverVariables) + path;
+      }
+    } else {
+      targetURL = this.basePath + path;
+    }
+    WebTarget target = httpClient.target(targetURL);
 
     if (queryParams != null) {
       for (Pair queryParam : queryParams) {
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/api.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/api.mustache
index f3e27a079c2..43cbb72325b 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/api.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/api.mustache
@@ -154,9 +154,9 @@ public class {{classname}} {
 
     {{#returnType}}
     GenericType<{{{returnType}}}> localVarReturnType = new GenericType<{{{returnType}}}>() {};
-    return apiClient.invokeAPI(localVarPath, "{{httpMethod}}", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("{{classname}}.{{operationId}}", localVarPath, "{{httpMethod}}", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
     {{/returnType}}{{^returnType}}
-    return apiClient.invokeAPI(localVarPath, "{{httpMethod}}", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("{{classname}}.{{operationId}}", localVarPath, "{{httpMethod}}", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
     {{/returnType}}
   }
   {{/operation}}
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java
index aa11a462ca0..36572fb0209 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java
@@ -288,7 +288,7 @@ public class JavaClientCodegenTest {
         generator.opts(clientOptInput).generate();
 
         Map<String, String> generatedFiles = generator.getFiles();
-        Assert.assertEquals(generatedFiles.size(), 34);
+        Assert.assertEquals(generatedFiles.size(), 36);
         TestUtils.ensureContainsFile(generatedFiles, output, ".gitignore");
         TestUtils.ensureContainsFile(generatedFiles, output, ".openapi-generator-ignore");
         TestUtils.ensureContainsFile(generatedFiles, output, ".openapi-generator/VERSION");
@@ -361,7 +361,7 @@ public class JavaClientCodegenTest {
         generator.opts(clientOptInput).generate();
 
         Map<String, String> generatedFiles = generator.getFiles();
-        Assert.assertEquals(generatedFiles.size(), 37);
+        Assert.assertEquals(generatedFiles.size(), 39);
         TestUtils.ensureContainsFile(generatedFiles, output, ".gitignore");
         TestUtils.ensureContainsFile(generatedFiles, output, ".openapi-generator-ignore");
         TestUtils.ensureContainsFile(generatedFiles, output, ".openapi-generator/VERSION");
@@ -431,7 +431,7 @@ public class JavaClientCodegenTest {
         generator.opts(clientOptInput).generate();
 
         Map<String, String> generatedFiles = generator.getFiles();
-        Assert.assertEquals(generatedFiles.size(), 23);
+        Assert.assertEquals(generatedFiles.size(), 25);
         validateJavaSourceFiles(generatedFiles);
 
         String defaultApiFilename = new File(output, "src/main/java/xyz/abcdef/api/DefaultApi.java").getAbsolutePath().replace("\\", "/");
@@ -548,7 +548,7 @@ public class JavaClientCodegenTest {
     public void testBearerAuth() {
         final OpenAPI openAPI = TestUtils.parseSpec("src/test/resources/3_0/pingBearerAuth.yaml");
         JavaClientCodegen codegen = new JavaClientCodegen();
-        
+
         List<CodegenSecurity> security = codegen.fromSecurity(openAPI.getComponents().getSecuritySchemes());
         Assert.assertEquals(security.size(), 1);
         Assert.assertEquals(security.get(0).isBasic, Boolean.TRUE);
diff --git a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/ServerConfiguration.java
new file mode 100644
index 00000000000..43b5a16b308
--- /dev/null
+++ b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -0,0 +1,60 @@
+package org.openapitools.client;
+
+import java.util.Map;
+
+import com.datadog.api.v1.client.ServerVariable;
+
+/**
+ * Representing a Server configuration.
+ */
+public class ServerConfiguration {
+    public String URL;
+    public String description;
+    public Map<String, ServerVariable> variables;
+
+    /**
+     * @param A URL to the target host.
+     * @param description A describtion of the host designated by the URL.
+     * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
+     */
+    public ServerConfiguration(String URL, String description, Map<String, ServerVariable> variables) {
+        this.URL = URL;
+        this.description = description;
+        this.variables = variables;
+    }
+
+    /**
+     * Format URL template using given variables.
+     *
+     * @param variables A map between a variable name and its value.
+     * @return Formatted URL.
+     */
+    public String URL(Map<String, String> variables) {
+        String url = this.URL;
+
+        // go through variables and replace placeholders
+        for (Map.Entry<String, ServerVariable> variable: this.variables.entrySet()) {
+            String name = variable.getKey();
+            ServerVariable serverVariable = variable.getValue();
+            String value = serverVariable.defaultValue;
+
+            if (variables != null && variables.containsKey(name)) {
+                value = variables.get(name);
+                if (serverVariable.enumValues.size() > 0 && !serverVariable.enumValues.contains(value)) {
+                    throw new RuntimeException("The variable " + name + " in the server URL has invalid value " + value + ".");
+                }
+            }
+            url = url.replaceAll("\\{" + name + "\\}", value);
+        }
+        return url;
+    }
+
+    /**
+     * Format URL template using default server variables.
+     *
+     * @return Formatted URL.
+     */
+    public String URL() {
+        return URL(null);
+    }
+}
diff --git a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/ServerVariable.java b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/ServerVariable.java
new file mode 100644
index 00000000000..c2f13e21666
--- /dev/null
+++ b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/ServerVariable.java
@@ -0,0 +1,23 @@
+package org.openapitools.client;
+
+import java.util.HashSet;
+
+/**
+ * Representing a Server Variable for server URL template substitution.
+ */
+public class ServerVariable {
+    public String description;
+    public String defaultValue;
+    public HashSet<String> enumValues = null;
+
+    /**
+     * @param description A description for the server variable.
+     * @param defaultValue The default value to use for substitution.
+     * @param enumValues An enumeration of string values to be used if the substitution options are from a limited set.
+     */
+    public ServerVariable(String description, String defaultValue, HashSet<String> enumValues) {
+        this.description = description;
+        this.defaultValue = defaultValue;
+        this.enumValues = enumValues;
+    }
+}
diff --git a/samples/client/petstore/java/feign10x/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/feign10x/src/main/java/org/openapitools/client/ServerConfiguration.java
new file mode 100644
index 00000000000..43b5a16b308
--- /dev/null
+++ b/samples/client/petstore/java/feign10x/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -0,0 +1,60 @@
+package org.openapitools.client;
+
+import java.util.Map;
+
+import com.datadog.api.v1.client.ServerVariable;
+
+/**
+ * Representing a Server configuration.
+ */
+public class ServerConfiguration {
+    public String URL;
+    public String description;
+    public Map<String, ServerVariable> variables;
+
+    /**
+     * @param A URL to the target host.
+     * @param description A describtion of the host designated by the URL.
+     * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
+     */
+    public ServerConfiguration(String URL, String description, Map<String, ServerVariable> variables) {
+        this.URL = URL;
+        this.description = description;
+        this.variables = variables;
+    }
+
+    /**
+     * Format URL template using given variables.
+     *
+     * @param variables A map between a variable name and its value.
+     * @return Formatted URL.
+     */
+    public String URL(Map<String, String> variables) {
+        String url = this.URL;
+
+        // go through variables and replace placeholders
+        for (Map.Entry<String, ServerVariable> variable: this.variables.entrySet()) {
+            String name = variable.getKey();
+            ServerVariable serverVariable = variable.getValue();
+            String value = serverVariable.defaultValue;
+
+            if (variables != null && variables.containsKey(name)) {
+                value = variables.get(name);
+                if (serverVariable.enumValues.size() > 0 && !serverVariable.enumValues.contains(value)) {
+                    throw new RuntimeException("The variable " + name + " in the server URL has invalid value " + value + ".");
+                }
+            }
+            url = url.replaceAll("\\{" + name + "\\}", value);
+        }
+        return url;
+    }
+
+    /**
+     * Format URL template using default server variables.
+     *
+     * @return Formatted URL.
+     */
+    public String URL() {
+        return URL(null);
+    }
+}
diff --git a/samples/client/petstore/java/feign10x/src/main/java/org/openapitools/client/ServerVariable.java b/samples/client/petstore/java/feign10x/src/main/java/org/openapitools/client/ServerVariable.java
new file mode 100644
index 00000000000..c2f13e21666
--- /dev/null
+++ b/samples/client/petstore/java/feign10x/src/main/java/org/openapitools/client/ServerVariable.java
@@ -0,0 +1,23 @@
+package org.openapitools.client;
+
+import java.util.HashSet;
+
+/**
+ * Representing a Server Variable for server URL template substitution.
+ */
+public class ServerVariable {
+    public String description;
+    public String defaultValue;
+    public HashSet<String> enumValues = null;
+
+    /**
+     * @param description A description for the server variable.
+     * @param defaultValue The default value to use for substitution.
+     * @param enumValues An enumeration of string values to be used if the substitution options are from a limited set.
+     */
+    public ServerVariable(String description, String defaultValue, HashSet<String> enumValues) {
+        this.description = description;
+        this.defaultValue = defaultValue;
+        this.enumValues = enumValues;
+    }
+}
diff --git a/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/ServerConfiguration.java
new file mode 100644
index 00000000000..43b5a16b308
--- /dev/null
+++ b/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -0,0 +1,60 @@
+package org.openapitools.client;
+
+import java.util.Map;
+
+import com.datadog.api.v1.client.ServerVariable;
+
+/**
+ * Representing a Server configuration.
+ */
+public class ServerConfiguration {
+    public String URL;
+    public String description;
+    public Map<String, ServerVariable> variables;
+
+    /**
+     * @param A URL to the target host.
+     * @param description A describtion of the host designated by the URL.
+     * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
+     */
+    public ServerConfiguration(String URL, String description, Map<String, ServerVariable> variables) {
+        this.URL = URL;
+        this.description = description;
+        this.variables = variables;
+    }
+
+    /**
+     * Format URL template using given variables.
+     *
+     * @param variables A map between a variable name and its value.
+     * @return Formatted URL.
+     */
+    public String URL(Map<String, String> variables) {
+        String url = this.URL;
+
+        // go through variables and replace placeholders
+        for (Map.Entry<String, ServerVariable> variable: this.variables.entrySet()) {
+            String name = variable.getKey();
+            ServerVariable serverVariable = variable.getValue();
+            String value = serverVariable.defaultValue;
+
+            if (variables != null && variables.containsKey(name)) {
+                value = variables.get(name);
+                if (serverVariable.enumValues.size() > 0 && !serverVariable.enumValues.contains(value)) {
+                    throw new RuntimeException("The variable " + name + " in the server URL has invalid value " + value + ".");
+                }
+            }
+            url = url.replaceAll("\\{" + name + "\\}", value);
+        }
+        return url;
+    }
+
+    /**
+     * Format URL template using default server variables.
+     *
+     * @return Formatted URL.
+     */
+    public String URL() {
+        return URL(null);
+    }
+}
diff --git a/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/ServerVariable.java b/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/ServerVariable.java
new file mode 100644
index 00000000000..c2f13e21666
--- /dev/null
+++ b/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/ServerVariable.java
@@ -0,0 +1,23 @@
+package org.openapitools.client;
+
+import java.util.HashSet;
+
+/**
+ * Representing a Server Variable for server URL template substitution.
+ */
+public class ServerVariable {
+    public String description;
+    public String defaultValue;
+    public HashSet<String> enumValues = null;
+
+    /**
+     * @param description A description for the server variable.
+     * @param defaultValue The default value to use for substitution.
+     * @param enumValues An enumeration of string values to be used if the substitution options are from a limited set.
+     */
+    public ServerVariable(String description, String defaultValue, HashSet<String> enumValues) {
+        this.description = description;
+        this.defaultValue = defaultValue;
+        this.enumValues = enumValues;
+    }
+}
diff --git a/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/ApiClient.java
index c07b4ad77e2..ce9605199da 100644
--- a/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/ApiClient.java
+++ b/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/ApiClient.java
@@ -39,7 +39,9 @@ import java.util.Collections;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Arrays;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.TimeZone;
@@ -55,6 +57,8 @@ import org.openapitools.client.auth.Authentication;
 import org.openapitools.client.auth.HttpBasicAuth;
 import org.openapitools.client.auth.HttpBearerAuth;
 import org.openapitools.client.auth.ApiKeyAuth;
+import org.openapitools.client.ServerConfiguration;
+import org.openapitools.client.ServerVariable;
 import org.openapitools.client.auth.OAuth;
 
 
@@ -62,6 +66,15 @@ public class ApiClient {
   private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
   private Map<String, String> defaultCookieMap = new HashMap<String, String>();
   private String basePath = "http://petstore.swagger.io:80/v2";
+  protected ServerConfiguration[] servers = {
+    new ServerConfiguration(
+      "http://petstore.swagger.io:80/v2",
+      "No description provided",
+      new HashMap<String, ServerVariable>()
+    )
+  };
+  protected Integer serverIndex = 0;
+  protected Map<String, String> serverVariables = null;
   private boolean debugging = false;
   private int connectionTimeout = 0;
 
@@ -168,6 +181,33 @@ public class ApiClient {
     return this;
   }
 
+  public ServerConfiguration[] getServers() {
+    return servers;
+  }
+
+  public ApiClient setServers(ServerConfiguration[] servers) {
+    this.servers = servers;
+    return this;
+  }
+
+  public Integer getServerIndex() {
+    return serverIndex;
+  }
+
+  public ApiClient setServerIndex(Integer serverIndex) {
+    this.serverIndex = serverIndex;
+    return this;
+  }
+
+  public Map<String, String> getServerVariables() {
+    return serverVariables;
+  }
+
+  public ApiClient setServerVariables(Map<String, String> serverVariables) {
+    this.serverVariables = serverVariables;
+    return this;
+  }
+
   /**
    * Gets the status code of the previous request
    * @return Status code
@@ -243,7 +283,7 @@ public class ApiClient {
     }
     throw new RuntimeException("No API key authentication configured!");
   }
-  
+
   /**
    * Helper method to set API key prefix for the first API key authentication.
    * @param apiKeyPrefix API key prefix
@@ -615,8 +655,15 @@ public class ApiClient {
    * @return The full URL
    */
   private String buildUrl(String path, List<Pair> queryParams, List<Pair> collectionQueryParams) {
+    String baseURL;
+    if (serverIndex != null) {
+      baseURL = servers[serverIndex].URL(serverVariables);
+    } else {
+      baseURL = basePath;
+    }
+
     final StringBuilder url = new StringBuilder();
-    url.append(basePath).append(path);
+    url.append(baseURL).append(path);
 
     if (queryParams != null && !queryParams.isEmpty()) {
       // support (constant) query string in `path`, e.g. "/posts?draft=1"
diff --git a/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/ServerConfiguration.java
new file mode 100644
index 00000000000..43b5a16b308
--- /dev/null
+++ b/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -0,0 +1,60 @@
+package org.openapitools.client;
+
+import java.util.Map;
+
+import com.datadog.api.v1.client.ServerVariable;
+
+/**
+ * Representing a Server configuration.
+ */
+public class ServerConfiguration {
+    public String URL;
+    public String description;
+    public Map<String, ServerVariable> variables;
+
+    /**
+     * @param A URL to the target host.
+     * @param description A describtion of the host designated by the URL.
+     * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
+     */
+    public ServerConfiguration(String URL, String description, Map<String, ServerVariable> variables) {
+        this.URL = URL;
+        this.description = description;
+        this.variables = variables;
+    }
+
+    /**
+     * Format URL template using given variables.
+     *
+     * @param variables A map between a variable name and its value.
+     * @return Formatted URL.
+     */
+    public String URL(Map<String, String> variables) {
+        String url = this.URL;
+
+        // go through variables and replace placeholders
+        for (Map.Entry<String, ServerVariable> variable: this.variables.entrySet()) {
+            String name = variable.getKey();
+            ServerVariable serverVariable = variable.getValue();
+            String value = serverVariable.defaultValue;
+
+            if (variables != null && variables.containsKey(name)) {
+                value = variables.get(name);
+                if (serverVariable.enumValues.size() > 0 && !serverVariable.enumValues.contains(value)) {
+                    throw new RuntimeException("The variable " + name + " in the server URL has invalid value " + value + ".");
+                }
+            }
+            url = url.replaceAll("\\{" + name + "\\}", value);
+        }
+        return url;
+    }
+
+    /**
+     * Format URL template using default server variables.
+     *
+     * @return Formatted URL.
+     */
+    public String URL() {
+        return URL(null);
+    }
+}
diff --git a/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/ServerVariable.java b/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/ServerVariable.java
new file mode 100644
index 00000000000..c2f13e21666
--- /dev/null
+++ b/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/ServerVariable.java
@@ -0,0 +1,23 @@
+package org.openapitools.client;
+
+import java.util.HashSet;
+
+/**
+ * Representing a Server Variable for server URL template substitution.
+ */
+public class ServerVariable {
+    public String description;
+    public String defaultValue;
+    public HashSet<String> enumValues = null;
+
+    /**
+     * @param description A description for the server variable.
+     * @param defaultValue The default value to use for substitution.
+     * @param enumValues An enumeration of string values to be used if the substitution options are from a limited set.
+     */
+    public ServerVariable(String description, String defaultValue, HashSet<String> enumValues) {
+        this.description = description;
+        this.defaultValue = defaultValue;
+        this.enumValues = enumValues;
+    }
+}
diff --git a/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/ApiClient.java
index c92e4584cb2..89095f0680d 100644
--- a/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/ApiClient.java
+++ b/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/ApiClient.java
@@ -30,7 +30,9 @@ import java.util.Collections;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Arrays;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.TimeZone;
@@ -48,6 +50,9 @@ import org.openapitools.client.auth.Authentication;
 import org.openapitools.client.auth.HttpBasicAuth;
 import org.openapitools.client.auth.HttpBearerAuth;
 import org.openapitools.client.auth.ApiKeyAuth;
+import org.openapitools.client.ServerConfiguration;
+import org.openapitools.client.ServerVariable;
+
 import org.openapitools.client.auth.OAuth;
 
 
@@ -55,6 +60,19 @@ public class ApiClient {
   protected Map<String, String> defaultHeaderMap = new HashMap<String, String>();
   protected Map<String, String> defaultCookieMap = new HashMap<String, String>();
   protected String basePath = "http://petstore.swagger.io:80/v2";
+  protected ServerConfiguration[] servers = {
+    new ServerConfiguration(
+      "http://petstore.swagger.io:80/v2",
+      "No description provided",
+      new HashMap<String, ServerVariable>()
+    )
+  };
+  protected Integer serverIndex = 0;
+  protected Map<String, String> serverVariables = null;
+  protected Map<String, List<ServerConfiguration>> operationServers = new HashMap<String, List<ServerConfiguration>>() {{
+  }};
+  protected Map<String, Integer> operationServerIndex = new HashMap<String, Integer>();
+  protected Map<String, Map<String, String>> operationServerVariables = new HashMap<String, Map<String, String>>();
   protected boolean debugging = false;
   protected int connectionTimeout = 0;
   private int readTimeout = 0;
@@ -112,6 +130,33 @@ public class ApiClient {
     return this;
   }
 
+  public ServerConfiguration[] getServers() {
+    return servers;
+  }
+
+  public ApiClient setServers(ServerConfiguration[] servers) {
+    this.servers = servers;
+    return this;
+  }
+
+  public Integer getServerIndex() {
+    return serverIndex;
+  }
+
+  public ApiClient setServerIndex(Integer serverIndex) {
+    this.serverIndex = serverIndex;
+    return this;
+  }
+
+  public Map<String, String> getServerVariables() {
+    return serverVariables;
+  }
+
+  public ApiClient setServerVariables(Map<String, String> serverVariables) {
+    this.serverVariables = serverVariables;
+    return this;
+  }
+
   /**
    * Get authentications (key: authentication name, value: authentication).
    * @return Map of authentication object
@@ -654,6 +699,7 @@ public class ApiClient {
    * Invoke API by sending HTTP request with the given options.
    *
    * @param <T> Type
+   * @param operation The qualified name of the operation
    * @param path The sub-path of the HTTP URL
    * @param method The request method, one of "GET", "POST", "PUT", "HEAD" and "DELETE"
    * @param queryParams The query parameters
@@ -668,12 +714,24 @@ public class ApiClient {
    * @return The response body in type of string
    * @throws ApiException API exception
    */
-  public <T> ApiResponse<T> invokeAPI(String path, String method, List<Pair> queryParams, Object body, Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String accept, String contentType, String[] authNames, GenericType<T> returnType) throws ApiException {
+  public <T> ApiResponse<T> invokeAPI(String operation, String path, String method, List<Pair> queryParams, Object body, Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String accept, String contentType, String[] authNames, GenericType<T> returnType) throws ApiException {
     updateParamsForAuth(authNames, queryParams, headerParams, cookieParams);
 
-    // Not using `.target(this.basePath).path(path)` below,
+    // Not using `.target(targetURL).path(path)` below,
     // to support (constant) query string in `path`, e.g. "/posts?draft=1"
-    WebTarget target = httpClient.target(this.basePath + path);
+    String targetURL;
+    if (serverIndex != null) {
+      if (operationServers.containsKey(operation)) {
+        Integer index = operationServerIndex.getOrDefault(operation, serverIndex);
+        Map<String, String> variables = operationServerVariables.getOrDefault(operation, serverVariables);
+        targetURL = operationServers.get(operation)[index].URL(variables);
+      } else {
+        targetURL = servers[serverIndex].URL(serverVariables) + path;
+      }
+    } else {
+      targetURL = this.basePath + path;
+    }
+    WebTarget target = httpClient.target(targetURL);
 
     if (queryParams != null) {
       for (Pair queryParam : queryParams) {
diff --git a/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/ServerConfiguration.java
new file mode 100644
index 00000000000..43b5a16b308
--- /dev/null
+++ b/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -0,0 +1,60 @@
+package org.openapitools.client;
+
+import java.util.Map;
+
+import com.datadog.api.v1.client.ServerVariable;
+
+/**
+ * Representing a Server configuration.
+ */
+public class ServerConfiguration {
+    public String URL;
+    public String description;
+    public Map<String, ServerVariable> variables;
+
+    /**
+     * @param A URL to the target host.
+     * @param description A describtion of the host designated by the URL.
+     * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
+     */
+    public ServerConfiguration(String URL, String description, Map<String, ServerVariable> variables) {
+        this.URL = URL;
+        this.description = description;
+        this.variables = variables;
+    }
+
+    /**
+     * Format URL template using given variables.
+     *
+     * @param variables A map between a variable name and its value.
+     * @return Formatted URL.
+     */
+    public String URL(Map<String, String> variables) {
+        String url = this.URL;
+
+        // go through variables and replace placeholders
+        for (Map.Entry<String, ServerVariable> variable: this.variables.entrySet()) {
+            String name = variable.getKey();
+            ServerVariable serverVariable = variable.getValue();
+            String value = serverVariable.defaultValue;
+
+            if (variables != null && variables.containsKey(name)) {
+                value = variables.get(name);
+                if (serverVariable.enumValues.size() > 0 && !serverVariable.enumValues.contains(value)) {
+                    throw new RuntimeException("The variable " + name + " in the server URL has invalid value " + value + ".");
+                }
+            }
+            url = url.replaceAll("\\{" + name + "\\}", value);
+        }
+        return url;
+    }
+
+    /**
+     * Format URL template using default server variables.
+     *
+     * @return Formatted URL.
+     */
+    public String URL() {
+        return URL(null);
+    }
+}
diff --git a/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/ServerVariable.java b/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/ServerVariable.java
new file mode 100644
index 00000000000..c2f13e21666
--- /dev/null
+++ b/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/ServerVariable.java
@@ -0,0 +1,23 @@
+package org.openapitools.client;
+
+import java.util.HashSet;
+
+/**
+ * Representing a Server Variable for server URL template substitution.
+ */
+public class ServerVariable {
+    public String description;
+    public String defaultValue;
+    public HashSet<String> enumValues = null;
+
+    /**
+     * @param description A description for the server variable.
+     * @param defaultValue The default value to use for substitution.
+     * @param enumValues An enumeration of string values to be used if the substitution options are from a limited set.
+     */
+    public ServerVariable(String description, String defaultValue, HashSet<String> enumValues) {
+        this.description = description;
+        this.defaultValue = defaultValue;
+        this.enumValues = enumValues;
+    }
+}
diff --git a/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/api/AnotherFakeApi.java b/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/api/AnotherFakeApi.java
index 9d0776bb227..006ee5a2290 100644
--- a/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/api/AnotherFakeApi.java
+++ b/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/api/AnotherFakeApi.java
@@ -97,6 +97,6 @@ public class AnotherFakeApi {
     String[] localVarAuthNames = new String[] {  };
 
     GenericType<Client> localVarReturnType = new GenericType<Client>() {};
-    return apiClient.invokeAPI(localVarPath, "PATCH", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("AnotherFakeApi.call123testSpecialTags", localVarPath, "PATCH", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
 }
diff --git a/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/api/FakeApi.java
index 28099fcab83..1ca3732a4c0 100644
--- a/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/api/FakeApi.java
+++ b/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/api/FakeApi.java
@@ -105,7 +105,7 @@ public class FakeApi {
     String[] localVarAuthNames = new String[] {  };
 
 
-    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("FakeApi.createXmlItem", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * 
@@ -164,7 +164,7 @@ public class FakeApi {
     String[] localVarAuthNames = new String[] {  };
 
     GenericType<Boolean> localVarReturnType = new GenericType<Boolean>() {};
-    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("FakeApi.fakeOuterBooleanSerialize", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
   /**
    * 
@@ -223,7 +223,7 @@ public class FakeApi {
     String[] localVarAuthNames = new String[] {  };
 
     GenericType<OuterComposite> localVarReturnType = new GenericType<OuterComposite>() {};
-    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("FakeApi.fakeOuterCompositeSerialize", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
   /**
    * 
@@ -282,7 +282,7 @@ public class FakeApi {
     String[] localVarAuthNames = new String[] {  };
 
     GenericType<BigDecimal> localVarReturnType = new GenericType<BigDecimal>() {};
-    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("FakeApi.fakeOuterNumberSerialize", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
   /**
    * 
@@ -341,7 +341,7 @@ public class FakeApi {
     String[] localVarAuthNames = new String[] {  };
 
     GenericType<String> localVarReturnType = new GenericType<String>() {};
-    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("FakeApi.fakeOuterStringSerialize", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
   /**
    * 
@@ -405,7 +405,7 @@ public class FakeApi {
     String[] localVarAuthNames = new String[] {  };
 
 
-    return apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("FakeApi.testBodyWithFileSchema", localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * 
@@ -477,7 +477,7 @@ public class FakeApi {
     String[] localVarAuthNames = new String[] {  };
 
 
-    return apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("FakeApi.testBodyWithQueryParams", localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * To test \&quot;client\&quot; model
@@ -541,7 +541,7 @@ public class FakeApi {
     String[] localVarAuthNames = new String[] {  };
 
     GenericType<Client> localVarReturnType = new GenericType<Client>() {};
-    return apiClient.invokeAPI(localVarPath, "PATCH", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("FakeApi.testClientModel", localVarPath, "PATCH", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
   /**
    * Fake endpoint for testing various parameters  假端點  偽のエンドポイント  가짜 엔드 포인트
@@ -676,7 +676,7 @@ if (paramCallback != null)
     String[] localVarAuthNames = new String[] { "http_basic_test" };
 
 
-    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("FakeApi.testEndpointParameters", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * To test enum parameters
@@ -763,7 +763,7 @@ if (enumFormString != null)
     String[] localVarAuthNames = new String[] {  };
 
 
-    return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("FakeApi.testEnumParameters", localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * Fake endpoint to test group parameters (optional)
@@ -855,7 +855,7 @@ if (booleanGroup != null)
     String[] localVarAuthNames = new String[] {  };
 
 
-    return apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("FakeApi.testGroupParameters", localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * test inline additionalProperties
@@ -919,7 +919,7 @@ if (booleanGroup != null)
     String[] localVarAuthNames = new String[] {  };
 
 
-    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("FakeApi.testInlineAdditionalProperties", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * test json serialization of form data
@@ -994,7 +994,7 @@ if (param2 != null)
     String[] localVarAuthNames = new String[] {  };
 
 
-    return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("FakeApi.testJsonFormData", localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * 
@@ -1091,6 +1091,6 @@ if (param2 != null)
     String[] localVarAuthNames = new String[] {  };
 
 
-    return apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("FakeApi.testQueryParameterCollectionFormat", localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
 }
diff --git a/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java b/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java
index e4f033f2a10..212495a02bf 100644
--- a/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java
+++ b/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java
@@ -97,6 +97,6 @@ public class FakeClassnameTags123Api {
     String[] localVarAuthNames = new String[] { "api_key_query" };
 
     GenericType<Client> localVarReturnType = new GenericType<Client>() {};
-    return apiClient.invokeAPI(localVarPath, "PATCH", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("FakeClassnameTags123Api.testClassname", localVarPath, "PATCH", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
 }
diff --git a/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/api/PetApi.java
index 11467f78a10..a60eb51225e 100644
--- a/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/api/PetApi.java
+++ b/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/api/PetApi.java
@@ -101,7 +101,7 @@ public class PetApi {
     String[] localVarAuthNames = new String[] { "petstore_auth" };
 
 
-    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("PetApi.addPet", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * Deletes a pet
@@ -172,7 +172,7 @@ public class PetApi {
     String[] localVarAuthNames = new String[] { "petstore_auth" };
 
 
-    return apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("PetApi.deletePet", localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * Finds Pets by status
@@ -239,7 +239,7 @@ public class PetApi {
     String[] localVarAuthNames = new String[] { "petstore_auth" };
 
     GenericType<List<Pet>> localVarReturnType = new GenericType<List<Pet>>() {};
-    return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("PetApi.findPetsByStatus", localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
   /**
    * Finds Pets by tags
@@ -310,7 +310,7 @@ public class PetApi {
     String[] localVarAuthNames = new String[] { "petstore_auth" };
 
     GenericType<List<Pet>> localVarReturnType = new GenericType<List<Pet>>() {};
-    return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("PetApi.findPetsByTags", localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
   /**
    * Find pet by ID
@@ -379,7 +379,7 @@ public class PetApi {
     String[] localVarAuthNames = new String[] { "api_key" };
 
     GenericType<Pet> localVarReturnType = new GenericType<Pet>() {};
-    return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("PetApi.getPetById", localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
   /**
    * Update an existing pet
@@ -449,7 +449,7 @@ public class PetApi {
     String[] localVarAuthNames = new String[] { "petstore_auth" };
 
 
-    return apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("PetApi.updatePet", localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * Updates a pet in the store with form data
@@ -522,7 +522,7 @@ if (status != null)
     String[] localVarAuthNames = new String[] { "petstore_auth" };
 
 
-    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("PetApi.updatePetWithForm", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * uploads an image
@@ -595,7 +595,7 @@ if (file != null)
     String[] localVarAuthNames = new String[] { "petstore_auth" };
 
     GenericType<ModelApiResponse> localVarReturnType = new GenericType<ModelApiResponse>() {};
-    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("PetApi.uploadFile", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
   /**
    * uploads an image (required)
@@ -673,6 +673,6 @@ if (requiredFile != null)
     String[] localVarAuthNames = new String[] { "petstore_auth" };
 
     GenericType<ModelApiResponse> localVarReturnType = new GenericType<ModelApiResponse>() {};
-    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("PetApi.uploadFileWithRequiredFile", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
 }
diff --git a/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/api/StoreApi.java b/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/api/StoreApi.java
index 42734da7a61..605ff809c10 100644
--- a/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/api/StoreApi.java
+++ b/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/api/StoreApi.java
@@ -100,7 +100,7 @@ public class StoreApi {
     String[] localVarAuthNames = new String[] {  };
 
 
-    return apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("StoreApi.deleteOrder", localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * Returns pet inventories by status
@@ -157,7 +157,7 @@ public class StoreApi {
     String[] localVarAuthNames = new String[] { "api_key" };
 
     GenericType<Map<String, Integer>> localVarReturnType = new GenericType<Map<String, Integer>>() {};
-    return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("StoreApi.getInventory", localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
   /**
    * Find purchase order by ID
@@ -226,7 +226,7 @@ public class StoreApi {
     String[] localVarAuthNames = new String[] {  };
 
     GenericType<Order> localVarReturnType = new GenericType<Order>() {};
-    return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("StoreApi.getOrderById", localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
   /**
    * Place an order for a pet
@@ -292,6 +292,6 @@ public class StoreApi {
     String[] localVarAuthNames = new String[] {  };
 
     GenericType<Order> localVarReturnType = new GenericType<Order>() {};
-    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("StoreApi.placeOrder", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
 }
diff --git a/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/api/UserApi.java b/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/api/UserApi.java
index ab4ae8c089f..22d77c4d35a 100644
--- a/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/api/UserApi.java
+++ b/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/api/UserApi.java
@@ -97,7 +97,7 @@ public class UserApi {
     String[] localVarAuthNames = new String[] {  };
 
 
-    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("UserApi.createUser", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * Creates list of users with given input array
@@ -161,7 +161,7 @@ public class UserApi {
     String[] localVarAuthNames = new String[] {  };
 
 
-    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("UserApi.createUsersWithArrayInput", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * Creates list of users with given input array
@@ -225,7 +225,7 @@ public class UserApi {
     String[] localVarAuthNames = new String[] {  };
 
 
-    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("UserApi.createUsersWithListInput", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * Delete user
@@ -292,7 +292,7 @@ public class UserApi {
     String[] localVarAuthNames = new String[] {  };
 
 
-    return apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("UserApi.deleteUser", localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * Get user by user name
@@ -361,7 +361,7 @@ public class UserApi {
     String[] localVarAuthNames = new String[] {  };
 
     GenericType<User> localVarReturnType = new GenericType<User>() {};
-    return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("UserApi.getUserByName", localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
   /**
    * Logs user into the system
@@ -436,7 +436,7 @@ public class UserApi {
     String[] localVarAuthNames = new String[] {  };
 
     GenericType<String> localVarReturnType = new GenericType<String>() {};
-    return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("UserApi.loginUser", localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
   /**
    * Logs out current logged in user session
@@ -493,7 +493,7 @@ public class UserApi {
     String[] localVarAuthNames = new String[] {  };
 
 
-    return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("UserApi.logoutUser", localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * Updated user
@@ -567,6 +567,6 @@ public class UserApi {
     String[] localVarAuthNames = new String[] {  };
 
 
-    return apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("UserApi.updateUser", localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
 }
diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/ApiClient.java
index bd0facace11..b990c618452 100644
--- a/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/ApiClient.java
+++ b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/ApiClient.java
@@ -31,7 +31,9 @@ import java.util.Collections;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Arrays;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.TimeZone;
@@ -49,6 +51,9 @@ import org.openapitools.client.auth.Authentication;
 import org.openapitools.client.auth.HttpBasicAuth;
 import org.openapitools.client.auth.HttpBearerAuth;
 import org.openapitools.client.auth.ApiKeyAuth;
+import org.openapitools.client.ServerConfiguration;
+import org.openapitools.client.ServerVariable;
+
 import org.openapitools.client.auth.OAuth;
 
 
@@ -56,6 +61,19 @@ public class ApiClient {
   protected Map<String, String> defaultHeaderMap = new HashMap<String, String>();
   protected Map<String, String> defaultCookieMap = new HashMap<String, String>();
   protected String basePath = "http://petstore.swagger.io:80/v2";
+  protected ServerConfiguration[] servers = {
+    new ServerConfiguration(
+      "http://petstore.swagger.io:80/v2",
+      "No description provided",
+      new HashMap<String, ServerVariable>()
+    )
+  };
+  protected Integer serverIndex = 0;
+  protected Map<String, String> serverVariables = null;
+  protected Map<String, List<ServerConfiguration>> operationServers = new HashMap<String, List<ServerConfiguration>>() {{
+  }};
+  protected Map<String, Integer> operationServerIndex = new HashMap<String, Integer>();
+  protected Map<String, Map<String, String>> operationServerVariables = new HashMap<String, Map<String, String>>();
   protected boolean debugging = false;
   protected int connectionTimeout = 0;
   private int readTimeout = 0;
@@ -113,6 +131,33 @@ public class ApiClient {
     return this;
   }
 
+  public ServerConfiguration[] getServers() {
+    return servers;
+  }
+
+  public ApiClient setServers(ServerConfiguration[] servers) {
+    this.servers = servers;
+    return this;
+  }
+
+  public Integer getServerIndex() {
+    return serverIndex;
+  }
+
+  public ApiClient setServerIndex(Integer serverIndex) {
+    this.serverIndex = serverIndex;
+    return this;
+  }
+
+  public Map<String, String> getServerVariables() {
+    return serverVariables;
+  }
+
+  public ApiClient setServerVariables(Map<String, String> serverVariables) {
+    this.serverVariables = serverVariables;
+    return this;
+  }
+
   /**
    * Get authentications (key: authentication name, value: authentication).
    * @return Map of authentication object
@@ -654,6 +699,7 @@ public class ApiClient {
    * Invoke API by sending HTTP request with the given options.
    *
    * @param <T> Type
+   * @param operation The qualified name of the operation
    * @param path The sub-path of the HTTP URL
    * @param method The request method, one of "GET", "POST", "PUT", "HEAD" and "DELETE"
    * @param queryParams The query parameters
@@ -668,12 +714,24 @@ public class ApiClient {
    * @return The response body in type of string
    * @throws ApiException API exception
    */
-  public <T> ApiResponse<T> invokeAPI(String path, String method, List<Pair> queryParams, Object body, Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String accept, String contentType, String[] authNames, GenericType<T> returnType) throws ApiException {
+  public <T> ApiResponse<T> invokeAPI(String operation, String path, String method, List<Pair> queryParams, Object body, Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String accept, String contentType, String[] authNames, GenericType<T> returnType) throws ApiException {
     updateParamsForAuth(authNames, queryParams, headerParams, cookieParams);
 
-    // Not using `.target(this.basePath).path(path)` below,
+    // Not using `.target(targetURL).path(path)` below,
     // to support (constant) query string in `path`, e.g. "/posts?draft=1"
-    WebTarget target = httpClient.target(this.basePath + path);
+    String targetURL;
+    if (serverIndex != null) {
+      if (operationServers.containsKey(operation)) {
+        Integer index = operationServerIndex.getOrDefault(operation, serverIndex);
+        Map<String, String> variables = operationServerVariables.getOrDefault(operation, serverVariables);
+        targetURL = operationServers.get(operation)[index].URL(variables);
+      } else {
+        targetURL = servers[serverIndex].URL(serverVariables) + path;
+      }
+    } else {
+      targetURL = this.basePath + path;
+    }
+    WebTarget target = httpClient.target(targetURL);
 
     if (queryParams != null) {
       for (Pair queryParam : queryParams) {
diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/ServerConfiguration.java
new file mode 100644
index 00000000000..43b5a16b308
--- /dev/null
+++ b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -0,0 +1,60 @@
+package org.openapitools.client;
+
+import java.util.Map;
+
+import com.datadog.api.v1.client.ServerVariable;
+
+/**
+ * Representing a Server configuration.
+ */
+public class ServerConfiguration {
+    public String URL;
+    public String description;
+    public Map<String, ServerVariable> variables;
+
+    /**
+     * @param A URL to the target host.
+     * @param description A describtion of the host designated by the URL.
+     * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
+     */
+    public ServerConfiguration(String URL, String description, Map<String, ServerVariable> variables) {
+        this.URL = URL;
+        this.description = description;
+        this.variables = variables;
+    }
+
+    /**
+     * Format URL template using given variables.
+     *
+     * @param variables A map between a variable name and its value.
+     * @return Formatted URL.
+     */
+    public String URL(Map<String, String> variables) {
+        String url = this.URL;
+
+        // go through variables and replace placeholders
+        for (Map.Entry<String, ServerVariable> variable: this.variables.entrySet()) {
+            String name = variable.getKey();
+            ServerVariable serverVariable = variable.getValue();
+            String value = serverVariable.defaultValue;
+
+            if (variables != null && variables.containsKey(name)) {
+                value = variables.get(name);
+                if (serverVariable.enumValues.size() > 0 && !serverVariable.enumValues.contains(value)) {
+                    throw new RuntimeException("The variable " + name + " in the server URL has invalid value " + value + ".");
+                }
+            }
+            url = url.replaceAll("\\{" + name + "\\}", value);
+        }
+        return url;
+    }
+
+    /**
+     * Format URL template using default server variables.
+     *
+     * @return Formatted URL.
+     */
+    public String URL() {
+        return URL(null);
+    }
+}
diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/ServerVariable.java b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/ServerVariable.java
new file mode 100644
index 00000000000..c2f13e21666
--- /dev/null
+++ b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/ServerVariable.java
@@ -0,0 +1,23 @@
+package org.openapitools.client;
+
+import java.util.HashSet;
+
+/**
+ * Representing a Server Variable for server URL template substitution.
+ */
+public class ServerVariable {
+    public String description;
+    public String defaultValue;
+    public HashSet<String> enumValues = null;
+
+    /**
+     * @param description A description for the server variable.
+     * @param defaultValue The default value to use for substitution.
+     * @param enumValues An enumeration of string values to be used if the substitution options are from a limited set.
+     */
+    public ServerVariable(String description, String defaultValue, HashSet<String> enumValues) {
+        this.description = description;
+        this.defaultValue = defaultValue;
+        this.enumValues = enumValues;
+    }
+}
diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/api/AnotherFakeApi.java b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/api/AnotherFakeApi.java
index 9d0776bb227..006ee5a2290 100644
--- a/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/api/AnotherFakeApi.java
+++ b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/api/AnotherFakeApi.java
@@ -97,6 +97,6 @@ public class AnotherFakeApi {
     String[] localVarAuthNames = new String[] {  };
 
     GenericType<Client> localVarReturnType = new GenericType<Client>() {};
-    return apiClient.invokeAPI(localVarPath, "PATCH", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("AnotherFakeApi.call123testSpecialTags", localVarPath, "PATCH", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
 }
diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/api/FakeApi.java
index 22ed9fd99a2..de57812ac6a 100644
--- a/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/api/FakeApi.java
+++ b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/api/FakeApi.java
@@ -105,7 +105,7 @@ public class FakeApi {
     String[] localVarAuthNames = new String[] {  };
 
 
-    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("FakeApi.createXmlItem", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * 
@@ -164,7 +164,7 @@ public class FakeApi {
     String[] localVarAuthNames = new String[] {  };
 
     GenericType<Boolean> localVarReturnType = new GenericType<Boolean>() {};
-    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("FakeApi.fakeOuterBooleanSerialize", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
   /**
    * 
@@ -223,7 +223,7 @@ public class FakeApi {
     String[] localVarAuthNames = new String[] {  };
 
     GenericType<OuterComposite> localVarReturnType = new GenericType<OuterComposite>() {};
-    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("FakeApi.fakeOuterCompositeSerialize", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
   /**
    * 
@@ -282,7 +282,7 @@ public class FakeApi {
     String[] localVarAuthNames = new String[] {  };
 
     GenericType<BigDecimal> localVarReturnType = new GenericType<BigDecimal>() {};
-    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("FakeApi.fakeOuterNumberSerialize", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
   /**
    * 
@@ -341,7 +341,7 @@ public class FakeApi {
     String[] localVarAuthNames = new String[] {  };
 
     GenericType<String> localVarReturnType = new GenericType<String>() {};
-    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("FakeApi.fakeOuterStringSerialize", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
   /**
    * 
@@ -405,7 +405,7 @@ public class FakeApi {
     String[] localVarAuthNames = new String[] {  };
 
 
-    return apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("FakeApi.testBodyWithFileSchema", localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * 
@@ -477,7 +477,7 @@ public class FakeApi {
     String[] localVarAuthNames = new String[] {  };
 
 
-    return apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("FakeApi.testBodyWithQueryParams", localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * To test \&quot;client\&quot; model
@@ -541,7 +541,7 @@ public class FakeApi {
     String[] localVarAuthNames = new String[] {  };
 
     GenericType<Client> localVarReturnType = new GenericType<Client>() {};
-    return apiClient.invokeAPI(localVarPath, "PATCH", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("FakeApi.testClientModel", localVarPath, "PATCH", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
   /**
    * Fake endpoint for testing various parameters  假端點  偽のエンドポイント  가짜 엔드 포인트
@@ -676,7 +676,7 @@ if (paramCallback != null)
     String[] localVarAuthNames = new String[] { "http_basic_test" };
 
 
-    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("FakeApi.testEndpointParameters", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * To test enum parameters
@@ -763,7 +763,7 @@ if (enumFormString != null)
     String[] localVarAuthNames = new String[] {  };
 
 
-    return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("FakeApi.testEnumParameters", localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * Fake endpoint to test group parameters (optional)
@@ -855,7 +855,7 @@ if (booleanGroup != null)
     String[] localVarAuthNames = new String[] {  };
 
 
-    return apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("FakeApi.testGroupParameters", localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * test inline additionalProperties
@@ -919,7 +919,7 @@ if (booleanGroup != null)
     String[] localVarAuthNames = new String[] {  };
 
 
-    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("FakeApi.testInlineAdditionalProperties", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * test json serialization of form data
@@ -994,7 +994,7 @@ if (param2 != null)
     String[] localVarAuthNames = new String[] {  };
 
 
-    return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("FakeApi.testJsonFormData", localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * 
@@ -1091,6 +1091,6 @@ if (param2 != null)
     String[] localVarAuthNames = new String[] {  };
 
 
-    return apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("FakeApi.testQueryParameterCollectionFormat", localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
 }
diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java
index e4f033f2a10..212495a02bf 100644
--- a/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java
+++ b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java
@@ -97,6 +97,6 @@ public class FakeClassnameTags123Api {
     String[] localVarAuthNames = new String[] { "api_key_query" };
 
     GenericType<Client> localVarReturnType = new GenericType<Client>() {};
-    return apiClient.invokeAPI(localVarPath, "PATCH", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("FakeClassnameTags123Api.testClassname", localVarPath, "PATCH", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
 }
diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/api/PetApi.java
index 11467f78a10..a60eb51225e 100644
--- a/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/api/PetApi.java
+++ b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/api/PetApi.java
@@ -101,7 +101,7 @@ public class PetApi {
     String[] localVarAuthNames = new String[] { "petstore_auth" };
 
 
-    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("PetApi.addPet", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * Deletes a pet
@@ -172,7 +172,7 @@ public class PetApi {
     String[] localVarAuthNames = new String[] { "petstore_auth" };
 
 
-    return apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("PetApi.deletePet", localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * Finds Pets by status
@@ -239,7 +239,7 @@ public class PetApi {
     String[] localVarAuthNames = new String[] { "petstore_auth" };
 
     GenericType<List<Pet>> localVarReturnType = new GenericType<List<Pet>>() {};
-    return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("PetApi.findPetsByStatus", localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
   /**
    * Finds Pets by tags
@@ -310,7 +310,7 @@ public class PetApi {
     String[] localVarAuthNames = new String[] { "petstore_auth" };
 
     GenericType<List<Pet>> localVarReturnType = new GenericType<List<Pet>>() {};
-    return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("PetApi.findPetsByTags", localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
   /**
    * Find pet by ID
@@ -379,7 +379,7 @@ public class PetApi {
     String[] localVarAuthNames = new String[] { "api_key" };
 
     GenericType<Pet> localVarReturnType = new GenericType<Pet>() {};
-    return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("PetApi.getPetById", localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
   /**
    * Update an existing pet
@@ -449,7 +449,7 @@ public class PetApi {
     String[] localVarAuthNames = new String[] { "petstore_auth" };
 
 
-    return apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("PetApi.updatePet", localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * Updates a pet in the store with form data
@@ -522,7 +522,7 @@ if (status != null)
     String[] localVarAuthNames = new String[] { "petstore_auth" };
 
 
-    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("PetApi.updatePetWithForm", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * uploads an image
@@ -595,7 +595,7 @@ if (file != null)
     String[] localVarAuthNames = new String[] { "petstore_auth" };
 
     GenericType<ModelApiResponse> localVarReturnType = new GenericType<ModelApiResponse>() {};
-    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("PetApi.uploadFile", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
   /**
    * uploads an image (required)
@@ -673,6 +673,6 @@ if (requiredFile != null)
     String[] localVarAuthNames = new String[] { "petstore_auth" };
 
     GenericType<ModelApiResponse> localVarReturnType = new GenericType<ModelApiResponse>() {};
-    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("PetApi.uploadFileWithRequiredFile", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
 }
diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/api/StoreApi.java b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/api/StoreApi.java
index 42734da7a61..605ff809c10 100644
--- a/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/api/StoreApi.java
+++ b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/api/StoreApi.java
@@ -100,7 +100,7 @@ public class StoreApi {
     String[] localVarAuthNames = new String[] {  };
 
 
-    return apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("StoreApi.deleteOrder", localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * Returns pet inventories by status
@@ -157,7 +157,7 @@ public class StoreApi {
     String[] localVarAuthNames = new String[] { "api_key" };
 
     GenericType<Map<String, Integer>> localVarReturnType = new GenericType<Map<String, Integer>>() {};
-    return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("StoreApi.getInventory", localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
   /**
    * Find purchase order by ID
@@ -226,7 +226,7 @@ public class StoreApi {
     String[] localVarAuthNames = new String[] {  };
 
     GenericType<Order> localVarReturnType = new GenericType<Order>() {};
-    return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("StoreApi.getOrderById", localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
   /**
    * Place an order for a pet
@@ -292,6 +292,6 @@ public class StoreApi {
     String[] localVarAuthNames = new String[] {  };
 
     GenericType<Order> localVarReturnType = new GenericType<Order>() {};
-    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("StoreApi.placeOrder", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
 }
diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/api/UserApi.java b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/api/UserApi.java
index ab4ae8c089f..22d77c4d35a 100644
--- a/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/api/UserApi.java
+++ b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/api/UserApi.java
@@ -97,7 +97,7 @@ public class UserApi {
     String[] localVarAuthNames = new String[] {  };
 
 
-    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("UserApi.createUser", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * Creates list of users with given input array
@@ -161,7 +161,7 @@ public class UserApi {
     String[] localVarAuthNames = new String[] {  };
 
 
-    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("UserApi.createUsersWithArrayInput", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * Creates list of users with given input array
@@ -225,7 +225,7 @@ public class UserApi {
     String[] localVarAuthNames = new String[] {  };
 
 
-    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("UserApi.createUsersWithListInput", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * Delete user
@@ -292,7 +292,7 @@ public class UserApi {
     String[] localVarAuthNames = new String[] {  };
 
 
-    return apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("UserApi.deleteUser", localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * Get user by user name
@@ -361,7 +361,7 @@ public class UserApi {
     String[] localVarAuthNames = new String[] {  };
 
     GenericType<User> localVarReturnType = new GenericType<User>() {};
-    return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("UserApi.getUserByName", localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
   /**
    * Logs user into the system
@@ -436,7 +436,7 @@ public class UserApi {
     String[] localVarAuthNames = new String[] {  };
 
     GenericType<String> localVarReturnType = new GenericType<String>() {};
-    return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("UserApi.loginUser", localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
   /**
    * Logs out current logged in user session
@@ -493,7 +493,7 @@ public class UserApi {
     String[] localVarAuthNames = new String[] {  };
 
 
-    return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("UserApi.logoutUser", localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * Updated user
@@ -567,6 +567,6 @@ public class UserApi {
     String[] localVarAuthNames = new String[] {  };
 
 
-    return apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("UserApi.updateUser", localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
 }
diff --git a/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/ApiClient.java
index bd0facace11..b990c618452 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/ApiClient.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/ApiClient.java
@@ -31,7 +31,9 @@ import java.util.Collections;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Arrays;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.TimeZone;
@@ -49,6 +51,9 @@ import org.openapitools.client.auth.Authentication;
 import org.openapitools.client.auth.HttpBasicAuth;
 import org.openapitools.client.auth.HttpBearerAuth;
 import org.openapitools.client.auth.ApiKeyAuth;
+import org.openapitools.client.ServerConfiguration;
+import org.openapitools.client.ServerVariable;
+
 import org.openapitools.client.auth.OAuth;
 
 
@@ -56,6 +61,19 @@ public class ApiClient {
   protected Map<String, String> defaultHeaderMap = new HashMap<String, String>();
   protected Map<String, String> defaultCookieMap = new HashMap<String, String>();
   protected String basePath = "http://petstore.swagger.io:80/v2";
+  protected ServerConfiguration[] servers = {
+    new ServerConfiguration(
+      "http://petstore.swagger.io:80/v2",
+      "No description provided",
+      new HashMap<String, ServerVariable>()
+    )
+  };
+  protected Integer serverIndex = 0;
+  protected Map<String, String> serverVariables = null;
+  protected Map<String, List<ServerConfiguration>> operationServers = new HashMap<String, List<ServerConfiguration>>() {{
+  }};
+  protected Map<String, Integer> operationServerIndex = new HashMap<String, Integer>();
+  protected Map<String, Map<String, String>> operationServerVariables = new HashMap<String, Map<String, String>>();
   protected boolean debugging = false;
   protected int connectionTimeout = 0;
   private int readTimeout = 0;
@@ -113,6 +131,33 @@ public class ApiClient {
     return this;
   }
 
+  public ServerConfiguration[] getServers() {
+    return servers;
+  }
+
+  public ApiClient setServers(ServerConfiguration[] servers) {
+    this.servers = servers;
+    return this;
+  }
+
+  public Integer getServerIndex() {
+    return serverIndex;
+  }
+
+  public ApiClient setServerIndex(Integer serverIndex) {
+    this.serverIndex = serverIndex;
+    return this;
+  }
+
+  public Map<String, String> getServerVariables() {
+    return serverVariables;
+  }
+
+  public ApiClient setServerVariables(Map<String, String> serverVariables) {
+    this.serverVariables = serverVariables;
+    return this;
+  }
+
   /**
    * Get authentications (key: authentication name, value: authentication).
    * @return Map of authentication object
@@ -654,6 +699,7 @@ public class ApiClient {
    * Invoke API by sending HTTP request with the given options.
    *
    * @param <T> Type
+   * @param operation The qualified name of the operation
    * @param path The sub-path of the HTTP URL
    * @param method The request method, one of "GET", "POST", "PUT", "HEAD" and "DELETE"
    * @param queryParams The query parameters
@@ -668,12 +714,24 @@ public class ApiClient {
    * @return The response body in type of string
    * @throws ApiException API exception
    */
-  public <T> ApiResponse<T> invokeAPI(String path, String method, List<Pair> queryParams, Object body, Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String accept, String contentType, String[] authNames, GenericType<T> returnType) throws ApiException {
+  public <T> ApiResponse<T> invokeAPI(String operation, String path, String method, List<Pair> queryParams, Object body, Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String accept, String contentType, String[] authNames, GenericType<T> returnType) throws ApiException {
     updateParamsForAuth(authNames, queryParams, headerParams, cookieParams);
 
-    // Not using `.target(this.basePath).path(path)` below,
+    // Not using `.target(targetURL).path(path)` below,
     // to support (constant) query string in `path`, e.g. "/posts?draft=1"
-    WebTarget target = httpClient.target(this.basePath + path);
+    String targetURL;
+    if (serverIndex != null) {
+      if (operationServers.containsKey(operation)) {
+        Integer index = operationServerIndex.getOrDefault(operation, serverIndex);
+        Map<String, String> variables = operationServerVariables.getOrDefault(operation, serverVariables);
+        targetURL = operationServers.get(operation)[index].URL(variables);
+      } else {
+        targetURL = servers[serverIndex].URL(serverVariables) + path;
+      }
+    } else {
+      targetURL = this.basePath + path;
+    }
+    WebTarget target = httpClient.target(targetURL);
 
     if (queryParams != null) {
       for (Pair queryParam : queryParams) {
diff --git a/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/ServerConfiguration.java
new file mode 100644
index 00000000000..43b5a16b308
--- /dev/null
+++ b/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -0,0 +1,60 @@
+package org.openapitools.client;
+
+import java.util.Map;
+
+import com.datadog.api.v1.client.ServerVariable;
+
+/**
+ * Representing a Server configuration.
+ */
+public class ServerConfiguration {
+    public String URL;
+    public String description;
+    public Map<String, ServerVariable> variables;
+
+    /**
+     * @param A URL to the target host.
+     * @param description A describtion of the host designated by the URL.
+     * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
+     */
+    public ServerConfiguration(String URL, String description, Map<String, ServerVariable> variables) {
+        this.URL = URL;
+        this.description = description;
+        this.variables = variables;
+    }
+
+    /**
+     * Format URL template using given variables.
+     *
+     * @param variables A map between a variable name and its value.
+     * @return Formatted URL.
+     */
+    public String URL(Map<String, String> variables) {
+        String url = this.URL;
+
+        // go through variables and replace placeholders
+        for (Map.Entry<String, ServerVariable> variable: this.variables.entrySet()) {
+            String name = variable.getKey();
+            ServerVariable serverVariable = variable.getValue();
+            String value = serverVariable.defaultValue;
+
+            if (variables != null && variables.containsKey(name)) {
+                value = variables.get(name);
+                if (serverVariable.enumValues.size() > 0 && !serverVariable.enumValues.contains(value)) {
+                    throw new RuntimeException("The variable " + name + " in the server URL has invalid value " + value + ".");
+                }
+            }
+            url = url.replaceAll("\\{" + name + "\\}", value);
+        }
+        return url;
+    }
+
+    /**
+     * Format URL template using default server variables.
+     *
+     * @return Formatted URL.
+     */
+    public String URL() {
+        return URL(null);
+    }
+}
diff --git a/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/ServerVariable.java b/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/ServerVariable.java
new file mode 100644
index 00000000000..c2f13e21666
--- /dev/null
+++ b/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/ServerVariable.java
@@ -0,0 +1,23 @@
+package org.openapitools.client;
+
+import java.util.HashSet;
+
+/**
+ * Representing a Server Variable for server URL template substitution.
+ */
+public class ServerVariable {
+    public String description;
+    public String defaultValue;
+    public HashSet<String> enumValues = null;
+
+    /**
+     * @param description A description for the server variable.
+     * @param defaultValue The default value to use for substitution.
+     * @param enumValues An enumeration of string values to be used if the substitution options are from a limited set.
+     */
+    public ServerVariable(String description, String defaultValue, HashSet<String> enumValues) {
+        this.description = description;
+        this.defaultValue = defaultValue;
+        this.enumValues = enumValues;
+    }
+}
diff --git a/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/api/AnotherFakeApi.java b/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/api/AnotherFakeApi.java
index 9d0776bb227..006ee5a2290 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/api/AnotherFakeApi.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/api/AnotherFakeApi.java
@@ -97,6 +97,6 @@ public class AnotherFakeApi {
     String[] localVarAuthNames = new String[] {  };
 
     GenericType<Client> localVarReturnType = new GenericType<Client>() {};
-    return apiClient.invokeAPI(localVarPath, "PATCH", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("AnotherFakeApi.call123testSpecialTags", localVarPath, "PATCH", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
 }
diff --git a/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/api/FakeApi.java
index 28099fcab83..1ca3732a4c0 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/api/FakeApi.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/api/FakeApi.java
@@ -105,7 +105,7 @@ public class FakeApi {
     String[] localVarAuthNames = new String[] {  };
 
 
-    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("FakeApi.createXmlItem", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * 
@@ -164,7 +164,7 @@ public class FakeApi {
     String[] localVarAuthNames = new String[] {  };
 
     GenericType<Boolean> localVarReturnType = new GenericType<Boolean>() {};
-    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("FakeApi.fakeOuterBooleanSerialize", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
   /**
    * 
@@ -223,7 +223,7 @@ public class FakeApi {
     String[] localVarAuthNames = new String[] {  };
 
     GenericType<OuterComposite> localVarReturnType = new GenericType<OuterComposite>() {};
-    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("FakeApi.fakeOuterCompositeSerialize", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
   /**
    * 
@@ -282,7 +282,7 @@ public class FakeApi {
     String[] localVarAuthNames = new String[] {  };
 
     GenericType<BigDecimal> localVarReturnType = new GenericType<BigDecimal>() {};
-    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("FakeApi.fakeOuterNumberSerialize", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
   /**
    * 
@@ -341,7 +341,7 @@ public class FakeApi {
     String[] localVarAuthNames = new String[] {  };
 
     GenericType<String> localVarReturnType = new GenericType<String>() {};
-    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("FakeApi.fakeOuterStringSerialize", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
   /**
    * 
@@ -405,7 +405,7 @@ public class FakeApi {
     String[] localVarAuthNames = new String[] {  };
 
 
-    return apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("FakeApi.testBodyWithFileSchema", localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * 
@@ -477,7 +477,7 @@ public class FakeApi {
     String[] localVarAuthNames = new String[] {  };
 
 
-    return apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("FakeApi.testBodyWithQueryParams", localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * To test \&quot;client\&quot; model
@@ -541,7 +541,7 @@ public class FakeApi {
     String[] localVarAuthNames = new String[] {  };
 
     GenericType<Client> localVarReturnType = new GenericType<Client>() {};
-    return apiClient.invokeAPI(localVarPath, "PATCH", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("FakeApi.testClientModel", localVarPath, "PATCH", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
   /**
    * Fake endpoint for testing various parameters  假端點  偽のエンドポイント  가짜 엔드 포인트
@@ -676,7 +676,7 @@ if (paramCallback != null)
     String[] localVarAuthNames = new String[] { "http_basic_test" };
 
 
-    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("FakeApi.testEndpointParameters", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * To test enum parameters
@@ -763,7 +763,7 @@ if (enumFormString != null)
     String[] localVarAuthNames = new String[] {  };
 
 
-    return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("FakeApi.testEnumParameters", localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * Fake endpoint to test group parameters (optional)
@@ -855,7 +855,7 @@ if (booleanGroup != null)
     String[] localVarAuthNames = new String[] {  };
 
 
-    return apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("FakeApi.testGroupParameters", localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * test inline additionalProperties
@@ -919,7 +919,7 @@ if (booleanGroup != null)
     String[] localVarAuthNames = new String[] {  };
 
 
-    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("FakeApi.testInlineAdditionalProperties", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * test json serialization of form data
@@ -994,7 +994,7 @@ if (param2 != null)
     String[] localVarAuthNames = new String[] {  };
 
 
-    return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("FakeApi.testJsonFormData", localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * 
@@ -1091,6 +1091,6 @@ if (param2 != null)
     String[] localVarAuthNames = new String[] {  };
 
 
-    return apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("FakeApi.testQueryParameterCollectionFormat", localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
 }
diff --git a/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java b/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java
index e4f033f2a10..212495a02bf 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java
@@ -97,6 +97,6 @@ public class FakeClassnameTags123Api {
     String[] localVarAuthNames = new String[] { "api_key_query" };
 
     GenericType<Client> localVarReturnType = new GenericType<Client>() {};
-    return apiClient.invokeAPI(localVarPath, "PATCH", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("FakeClassnameTags123Api.testClassname", localVarPath, "PATCH", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
 }
diff --git a/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/api/PetApi.java
index 11467f78a10..a60eb51225e 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/api/PetApi.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/api/PetApi.java
@@ -101,7 +101,7 @@ public class PetApi {
     String[] localVarAuthNames = new String[] { "petstore_auth" };
 
 
-    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("PetApi.addPet", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * Deletes a pet
@@ -172,7 +172,7 @@ public class PetApi {
     String[] localVarAuthNames = new String[] { "petstore_auth" };
 
 
-    return apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("PetApi.deletePet", localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * Finds Pets by status
@@ -239,7 +239,7 @@ public class PetApi {
     String[] localVarAuthNames = new String[] { "petstore_auth" };
 
     GenericType<List<Pet>> localVarReturnType = new GenericType<List<Pet>>() {};
-    return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("PetApi.findPetsByStatus", localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
   /**
    * Finds Pets by tags
@@ -310,7 +310,7 @@ public class PetApi {
     String[] localVarAuthNames = new String[] { "petstore_auth" };
 
     GenericType<List<Pet>> localVarReturnType = new GenericType<List<Pet>>() {};
-    return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("PetApi.findPetsByTags", localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
   /**
    * Find pet by ID
@@ -379,7 +379,7 @@ public class PetApi {
     String[] localVarAuthNames = new String[] { "api_key" };
 
     GenericType<Pet> localVarReturnType = new GenericType<Pet>() {};
-    return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("PetApi.getPetById", localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
   /**
    * Update an existing pet
@@ -449,7 +449,7 @@ public class PetApi {
     String[] localVarAuthNames = new String[] { "petstore_auth" };
 
 
-    return apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("PetApi.updatePet", localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * Updates a pet in the store with form data
@@ -522,7 +522,7 @@ if (status != null)
     String[] localVarAuthNames = new String[] { "petstore_auth" };
 
 
-    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("PetApi.updatePetWithForm", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * uploads an image
@@ -595,7 +595,7 @@ if (file != null)
     String[] localVarAuthNames = new String[] { "petstore_auth" };
 
     GenericType<ModelApiResponse> localVarReturnType = new GenericType<ModelApiResponse>() {};
-    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("PetApi.uploadFile", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
   /**
    * uploads an image (required)
@@ -673,6 +673,6 @@ if (requiredFile != null)
     String[] localVarAuthNames = new String[] { "petstore_auth" };
 
     GenericType<ModelApiResponse> localVarReturnType = new GenericType<ModelApiResponse>() {};
-    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("PetApi.uploadFileWithRequiredFile", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
 }
diff --git a/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/api/StoreApi.java b/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/api/StoreApi.java
index 42734da7a61..605ff809c10 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/api/StoreApi.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/api/StoreApi.java
@@ -100,7 +100,7 @@ public class StoreApi {
     String[] localVarAuthNames = new String[] {  };
 
 
-    return apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("StoreApi.deleteOrder", localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * Returns pet inventories by status
@@ -157,7 +157,7 @@ public class StoreApi {
     String[] localVarAuthNames = new String[] { "api_key" };
 
     GenericType<Map<String, Integer>> localVarReturnType = new GenericType<Map<String, Integer>>() {};
-    return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("StoreApi.getInventory", localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
   /**
    * Find purchase order by ID
@@ -226,7 +226,7 @@ public class StoreApi {
     String[] localVarAuthNames = new String[] {  };
 
     GenericType<Order> localVarReturnType = new GenericType<Order>() {};
-    return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("StoreApi.getOrderById", localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
   /**
    * Place an order for a pet
@@ -292,6 +292,6 @@ public class StoreApi {
     String[] localVarAuthNames = new String[] {  };
 
     GenericType<Order> localVarReturnType = new GenericType<Order>() {};
-    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("StoreApi.placeOrder", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
 }
diff --git a/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/api/UserApi.java b/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/api/UserApi.java
index ab4ae8c089f..22d77c4d35a 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/api/UserApi.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/api/UserApi.java
@@ -97,7 +97,7 @@ public class UserApi {
     String[] localVarAuthNames = new String[] {  };
 
 
-    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("UserApi.createUser", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * Creates list of users with given input array
@@ -161,7 +161,7 @@ public class UserApi {
     String[] localVarAuthNames = new String[] {  };
 
 
-    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("UserApi.createUsersWithArrayInput", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * Creates list of users with given input array
@@ -225,7 +225,7 @@ public class UserApi {
     String[] localVarAuthNames = new String[] {  };
 
 
-    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("UserApi.createUsersWithListInput", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * Delete user
@@ -292,7 +292,7 @@ public class UserApi {
     String[] localVarAuthNames = new String[] {  };
 
 
-    return apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("UserApi.deleteUser", localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * Get user by user name
@@ -361,7 +361,7 @@ public class UserApi {
     String[] localVarAuthNames = new String[] {  };
 
     GenericType<User> localVarReturnType = new GenericType<User>() {};
-    return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("UserApi.getUserByName", localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
   /**
    * Logs user into the system
@@ -436,7 +436,7 @@ public class UserApi {
     String[] localVarAuthNames = new String[] {  };
 
     GenericType<String> localVarReturnType = new GenericType<String>() {};
-    return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+    return apiClient.invokeAPI("UserApi.loginUser", localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
       }
   /**
    * Logs out current logged in user session
@@ -493,7 +493,7 @@ public class UserApi {
     String[] localVarAuthNames = new String[] {  };
 
 
-    return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("UserApi.logoutUser", localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
   /**
    * Updated user
@@ -567,6 +567,6 @@ public class UserApi {
     String[] localVarAuthNames = new String[] {  };
 
 
-    return apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
+    return apiClient.invokeAPI("UserApi.updateUser", localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
   }
 }
diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/ServerConfiguration.java
new file mode 100644
index 00000000000..43b5a16b308
--- /dev/null
+++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -0,0 +1,60 @@
+package org.openapitools.client;
+
+import java.util.Map;
+
+import com.datadog.api.v1.client.ServerVariable;
+
+/**
+ * Representing a Server configuration.
+ */
+public class ServerConfiguration {
+    public String URL;
+    public String description;
+    public Map<String, ServerVariable> variables;
+
+    /**
+     * @param A URL to the target host.
+     * @param description A describtion of the host designated by the URL.
+     * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
+     */
+    public ServerConfiguration(String URL, String description, Map<String, ServerVariable> variables) {
+        this.URL = URL;
+        this.description = description;
+        this.variables = variables;
+    }
+
+    /**
+     * Format URL template using given variables.
+     *
+     * @param variables A map between a variable name and its value.
+     * @return Formatted URL.
+     */
+    public String URL(Map<String, String> variables) {
+        String url = this.URL;
+
+        // go through variables and replace placeholders
+        for (Map.Entry<String, ServerVariable> variable: this.variables.entrySet()) {
+            String name = variable.getKey();
+            ServerVariable serverVariable = variable.getValue();
+            String value = serverVariable.defaultValue;
+
+            if (variables != null && variables.containsKey(name)) {
+                value = variables.get(name);
+                if (serverVariable.enumValues.size() > 0 && !serverVariable.enumValues.contains(value)) {
+                    throw new RuntimeException("The variable " + name + " in the server URL has invalid value " + value + ".");
+                }
+            }
+            url = url.replaceAll("\\{" + name + "\\}", value);
+        }
+        return url;
+    }
+
+    /**
+     * Format URL template using default server variables.
+     *
+     * @return Formatted URL.
+     */
+    public String URL() {
+        return URL(null);
+    }
+}
diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/ServerVariable.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/ServerVariable.java
new file mode 100644
index 00000000000..c2f13e21666
--- /dev/null
+++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/ServerVariable.java
@@ -0,0 +1,23 @@
+package org.openapitools.client;
+
+import java.util.HashSet;
+
+/**
+ * Representing a Server Variable for server URL template substitution.
+ */
+public class ServerVariable {
+    public String description;
+    public String defaultValue;
+    public HashSet<String> enumValues = null;
+
+    /**
+     * @param description A description for the server variable.
+     * @param defaultValue The default value to use for substitution.
+     * @param enumValues An enumeration of string values to be used if the substitution options are from a limited set.
+     */
+    public ServerVariable(String description, String defaultValue, HashSet<String> enumValues) {
+        this.description = description;
+        this.defaultValue = defaultValue;
+        this.enumValues = enumValues;
+    }
+}
diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/ServerConfiguration.java
new file mode 100644
index 00000000000..43b5a16b308
--- /dev/null
+++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -0,0 +1,60 @@
+package org.openapitools.client;
+
+import java.util.Map;
+
+import com.datadog.api.v1.client.ServerVariable;
+
+/**
+ * Representing a Server configuration.
+ */
+public class ServerConfiguration {
+    public String URL;
+    public String description;
+    public Map<String, ServerVariable> variables;
+
+    /**
+     * @param A URL to the target host.
+     * @param description A describtion of the host designated by the URL.
+     * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
+     */
+    public ServerConfiguration(String URL, String description, Map<String, ServerVariable> variables) {
+        this.URL = URL;
+        this.description = description;
+        this.variables = variables;
+    }
+
+    /**
+     * Format URL template using given variables.
+     *
+     * @param variables A map between a variable name and its value.
+     * @return Formatted URL.
+     */
+    public String URL(Map<String, String> variables) {
+        String url = this.URL;
+
+        // go through variables and replace placeholders
+        for (Map.Entry<String, ServerVariable> variable: this.variables.entrySet()) {
+            String name = variable.getKey();
+            ServerVariable serverVariable = variable.getValue();
+            String value = serverVariable.defaultValue;
+
+            if (variables != null && variables.containsKey(name)) {
+                value = variables.get(name);
+                if (serverVariable.enumValues.size() > 0 && !serverVariable.enumValues.contains(value)) {
+                    throw new RuntimeException("The variable " + name + " in the server URL has invalid value " + value + ".");
+                }
+            }
+            url = url.replaceAll("\\{" + name + "\\}", value);
+        }
+        return url;
+    }
+
+    /**
+     * Format URL template using default server variables.
+     *
+     * @return Formatted URL.
+     */
+    public String URL() {
+        return URL(null);
+    }
+}
diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/ServerVariable.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/ServerVariable.java
new file mode 100644
index 00000000000..c2f13e21666
--- /dev/null
+++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/ServerVariable.java
@@ -0,0 +1,23 @@
+package org.openapitools.client;
+
+import java.util.HashSet;
+
+/**
+ * Representing a Server Variable for server URL template substitution.
+ */
+public class ServerVariable {
+    public String description;
+    public String defaultValue;
+    public HashSet<String> enumValues = null;
+
+    /**
+     * @param description A description for the server variable.
+     * @param defaultValue The default value to use for substitution.
+     * @param enumValues An enumeration of string values to be used if the substitution options are from a limited set.
+     */
+    public ServerVariable(String description, String defaultValue, HashSet<String> enumValues) {
+        this.description = description;
+        this.defaultValue = defaultValue;
+        this.enumValues = enumValues;
+    }
+}
diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ServerConfiguration.java
new file mode 100644
index 00000000000..43b5a16b308
--- /dev/null
+++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -0,0 +1,60 @@
+package org.openapitools.client;
+
+import java.util.Map;
+
+import com.datadog.api.v1.client.ServerVariable;
+
+/**
+ * Representing a Server configuration.
+ */
+public class ServerConfiguration {
+    public String URL;
+    public String description;
+    public Map<String, ServerVariable> variables;
+
+    /**
+     * @param A URL to the target host.
+     * @param description A describtion of the host designated by the URL.
+     * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
+     */
+    public ServerConfiguration(String URL, String description, Map<String, ServerVariable> variables) {
+        this.URL = URL;
+        this.description = description;
+        this.variables = variables;
+    }
+
+    /**
+     * Format URL template using given variables.
+     *
+     * @param variables A map between a variable name and its value.
+     * @return Formatted URL.
+     */
+    public String URL(Map<String, String> variables) {
+        String url = this.URL;
+
+        // go through variables and replace placeholders
+        for (Map.Entry<String, ServerVariable> variable: this.variables.entrySet()) {
+            String name = variable.getKey();
+            ServerVariable serverVariable = variable.getValue();
+            String value = serverVariable.defaultValue;
+
+            if (variables != null && variables.containsKey(name)) {
+                value = variables.get(name);
+                if (serverVariable.enumValues.size() > 0 && !serverVariable.enumValues.contains(value)) {
+                    throw new RuntimeException("The variable " + name + " in the server URL has invalid value " + value + ".");
+                }
+            }
+            url = url.replaceAll("\\{" + name + "\\}", value);
+        }
+        return url;
+    }
+
+    /**
+     * Format URL template using default server variables.
+     *
+     * @return Formatted URL.
+     */
+    public String URL() {
+        return URL(null);
+    }
+}
diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ServerVariable.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ServerVariable.java
new file mode 100644
index 00000000000..c2f13e21666
--- /dev/null
+++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ServerVariable.java
@@ -0,0 +1,23 @@
+package org.openapitools.client;
+
+import java.util.HashSet;
+
+/**
+ * Representing a Server Variable for server URL template substitution.
+ */
+public class ServerVariable {
+    public String description;
+    public String defaultValue;
+    public HashSet<String> enumValues = null;
+
+    /**
+     * @param description A description for the server variable.
+     * @param defaultValue The default value to use for substitution.
+     * @param enumValues An enumeration of string values to be used if the substitution options are from a limited set.
+     */
+    public ServerVariable(String description, String defaultValue, HashSet<String> enumValues) {
+        this.description = description;
+        this.defaultValue = defaultValue;
+        this.enumValues = enumValues;
+    }
+}
diff --git a/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/ServerConfiguration.java
new file mode 100644
index 00000000000..43b5a16b308
--- /dev/null
+++ b/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -0,0 +1,60 @@
+package org.openapitools.client;
+
+import java.util.Map;
+
+import com.datadog.api.v1.client.ServerVariable;
+
+/**
+ * Representing a Server configuration.
+ */
+public class ServerConfiguration {
+    public String URL;
+    public String description;
+    public Map<String, ServerVariable> variables;
+
+    /**
+     * @param A URL to the target host.
+     * @param description A describtion of the host designated by the URL.
+     * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
+     */
+    public ServerConfiguration(String URL, String description, Map<String, ServerVariable> variables) {
+        this.URL = URL;
+        this.description = description;
+        this.variables = variables;
+    }
+
+    /**
+     * Format URL template using given variables.
+     *
+     * @param variables A map between a variable name and its value.
+     * @return Formatted URL.
+     */
+    public String URL(Map<String, String> variables) {
+        String url = this.URL;
+
+        // go through variables and replace placeholders
+        for (Map.Entry<String, ServerVariable> variable: this.variables.entrySet()) {
+            String name = variable.getKey();
+            ServerVariable serverVariable = variable.getValue();
+            String value = serverVariable.defaultValue;
+
+            if (variables != null && variables.containsKey(name)) {
+                value = variables.get(name);
+                if (serverVariable.enumValues.size() > 0 && !serverVariable.enumValues.contains(value)) {
+                    throw new RuntimeException("The variable " + name + " in the server URL has invalid value " + value + ".");
+                }
+            }
+            url = url.replaceAll("\\{" + name + "\\}", value);
+        }
+        return url;
+    }
+
+    /**
+     * Format URL template using default server variables.
+     *
+     * @return Formatted URL.
+     */
+    public String URL() {
+        return URL(null);
+    }
+}
diff --git a/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/ServerVariable.java b/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/ServerVariable.java
new file mode 100644
index 00000000000..c2f13e21666
--- /dev/null
+++ b/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/ServerVariable.java
@@ -0,0 +1,23 @@
+package org.openapitools.client;
+
+import java.util.HashSet;
+
+/**
+ * Representing a Server Variable for server URL template substitution.
+ */
+public class ServerVariable {
+    public String description;
+    public String defaultValue;
+    public HashSet<String> enumValues = null;
+
+    /**
+     * @param description A description for the server variable.
+     * @param defaultValue The default value to use for substitution.
+     * @param enumValues An enumeration of string values to be used if the substitution options are from a limited set.
+     */
+    public ServerVariable(String description, String defaultValue, HashSet<String> enumValues) {
+        this.description = description;
+        this.defaultValue = defaultValue;
+        this.enumValues = enumValues;
+    }
+}
diff --git a/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/ServerConfiguration.java
new file mode 100644
index 00000000000..43b5a16b308
--- /dev/null
+++ b/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -0,0 +1,60 @@
+package org.openapitools.client;
+
+import java.util.Map;
+
+import com.datadog.api.v1.client.ServerVariable;
+
+/**
+ * Representing a Server configuration.
+ */
+public class ServerConfiguration {
+    public String URL;
+    public String description;
+    public Map<String, ServerVariable> variables;
+
+    /**
+     * @param A URL to the target host.
+     * @param description A describtion of the host designated by the URL.
+     * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
+     */
+    public ServerConfiguration(String URL, String description, Map<String, ServerVariable> variables) {
+        this.URL = URL;
+        this.description = description;
+        this.variables = variables;
+    }
+
+    /**
+     * Format URL template using given variables.
+     *
+     * @param variables A map between a variable name and its value.
+     * @return Formatted URL.
+     */
+    public String URL(Map<String, String> variables) {
+        String url = this.URL;
+
+        // go through variables and replace placeholders
+        for (Map.Entry<String, ServerVariable> variable: this.variables.entrySet()) {
+            String name = variable.getKey();
+            ServerVariable serverVariable = variable.getValue();
+            String value = serverVariable.defaultValue;
+
+            if (variables != null && variables.containsKey(name)) {
+                value = variables.get(name);
+                if (serverVariable.enumValues.size() > 0 && !serverVariable.enumValues.contains(value)) {
+                    throw new RuntimeException("The variable " + name + " in the server URL has invalid value " + value + ".");
+                }
+            }
+            url = url.replaceAll("\\{" + name + "\\}", value);
+        }
+        return url;
+    }
+
+    /**
+     * Format URL template using default server variables.
+     *
+     * @return Formatted URL.
+     */
+    public String URL() {
+        return URL(null);
+    }
+}
diff --git a/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/ServerVariable.java b/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/ServerVariable.java
new file mode 100644
index 00000000000..c2f13e21666
--- /dev/null
+++ b/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/ServerVariable.java
@@ -0,0 +1,23 @@
+package org.openapitools.client;
+
+import java.util.HashSet;
+
+/**
+ * Representing a Server Variable for server URL template substitution.
+ */
+public class ServerVariable {
+    public String description;
+    public String defaultValue;
+    public HashSet<String> enumValues = null;
+
+    /**
+     * @param description A description for the server variable.
+     * @param defaultValue The default value to use for substitution.
+     * @param enumValues An enumeration of string values to be used if the substitution options are from a limited set.
+     */
+    public ServerVariable(String description, String defaultValue, HashSet<String> enumValues) {
+        this.description = description;
+        this.defaultValue = defaultValue;
+        this.enumValues = enumValues;
+    }
+}
diff --git a/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/ServerConfiguration.java
new file mode 100644
index 00000000000..43b5a16b308
--- /dev/null
+++ b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -0,0 +1,60 @@
+package org.openapitools.client;
+
+import java.util.Map;
+
+import com.datadog.api.v1.client.ServerVariable;
+
+/**
+ * Representing a Server configuration.
+ */
+public class ServerConfiguration {
+    public String URL;
+    public String description;
+    public Map<String, ServerVariable> variables;
+
+    /**
+     * @param A URL to the target host.
+     * @param description A describtion of the host designated by the URL.
+     * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
+     */
+    public ServerConfiguration(String URL, String description, Map<String, ServerVariable> variables) {
+        this.URL = URL;
+        this.description = description;
+        this.variables = variables;
+    }
+
+    /**
+     * Format URL template using given variables.
+     *
+     * @param variables A map between a variable name and its value.
+     * @return Formatted URL.
+     */
+    public String URL(Map<String, String> variables) {
+        String url = this.URL;
+
+        // go through variables and replace placeholders
+        for (Map.Entry<String, ServerVariable> variable: this.variables.entrySet()) {
+            String name = variable.getKey();
+            ServerVariable serverVariable = variable.getValue();
+            String value = serverVariable.defaultValue;
+
+            if (variables != null && variables.containsKey(name)) {
+                value = variables.get(name);
+                if (serverVariable.enumValues.size() > 0 && !serverVariable.enumValues.contains(value)) {
+                    throw new RuntimeException("The variable " + name + " in the server URL has invalid value " + value + ".");
+                }
+            }
+            url = url.replaceAll("\\{" + name + "\\}", value);
+        }
+        return url;
+    }
+
+    /**
+     * Format URL template using default server variables.
+     *
+     * @return Formatted URL.
+     */
+    public String URL() {
+        return URL(null);
+    }
+}
diff --git a/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/ServerVariable.java b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/ServerVariable.java
new file mode 100644
index 00000000000..c2f13e21666
--- /dev/null
+++ b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/ServerVariable.java
@@ -0,0 +1,23 @@
+package org.openapitools.client;
+
+import java.util.HashSet;
+
+/**
+ * Representing a Server Variable for server URL template substitution.
+ */
+public class ServerVariable {
+    public String description;
+    public String defaultValue;
+    public HashSet<String> enumValues = null;
+
+    /**
+     * @param description A description for the server variable.
+     * @param defaultValue The default value to use for substitution.
+     * @param enumValues An enumeration of string values to be used if the substitution options are from a limited set.
+     */
+    public ServerVariable(String description, String defaultValue, HashSet<String> enumValues) {
+        this.description = description;
+        this.defaultValue = defaultValue;
+        this.enumValues = enumValues;
+    }
+}
diff --git a/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/ServerConfiguration.java
new file mode 100644
index 00000000000..43b5a16b308
--- /dev/null
+++ b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -0,0 +1,60 @@
+package org.openapitools.client;
+
+import java.util.Map;
+
+import com.datadog.api.v1.client.ServerVariable;
+
+/**
+ * Representing a Server configuration.
+ */
+public class ServerConfiguration {
+    public String URL;
+    public String description;
+    public Map<String, ServerVariable> variables;
+
+    /**
+     * @param A URL to the target host.
+     * @param description A describtion of the host designated by the URL.
+     * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
+     */
+    public ServerConfiguration(String URL, String description, Map<String, ServerVariable> variables) {
+        this.URL = URL;
+        this.description = description;
+        this.variables = variables;
+    }
+
+    /**
+     * Format URL template using given variables.
+     *
+     * @param variables A map between a variable name and its value.
+     * @return Formatted URL.
+     */
+    public String URL(Map<String, String> variables) {
+        String url = this.URL;
+
+        // go through variables and replace placeholders
+        for (Map.Entry<String, ServerVariable> variable: this.variables.entrySet()) {
+            String name = variable.getKey();
+            ServerVariable serverVariable = variable.getValue();
+            String value = serverVariable.defaultValue;
+
+            if (variables != null && variables.containsKey(name)) {
+                value = variables.get(name);
+                if (serverVariable.enumValues.size() > 0 && !serverVariable.enumValues.contains(value)) {
+                    throw new RuntimeException("The variable " + name + " in the server URL has invalid value " + value + ".");
+                }
+            }
+            url = url.replaceAll("\\{" + name + "\\}", value);
+        }
+        return url;
+    }
+
+    /**
+     * Format URL template using default server variables.
+     *
+     * @return Formatted URL.
+     */
+    public String URL() {
+        return URL(null);
+    }
+}
diff --git a/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/ServerVariable.java b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/ServerVariable.java
new file mode 100644
index 00000000000..c2f13e21666
--- /dev/null
+++ b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/ServerVariable.java
@@ -0,0 +1,23 @@
+package org.openapitools.client;
+
+import java.util.HashSet;
+
+/**
+ * Representing a Server Variable for server URL template substitution.
+ */
+public class ServerVariable {
+    public String description;
+    public String defaultValue;
+    public HashSet<String> enumValues = null;
+
+    /**
+     * @param description A description for the server variable.
+     * @param defaultValue The default value to use for substitution.
+     * @param enumValues An enumeration of string values to be used if the substitution options are from a limited set.
+     */
+    public ServerVariable(String description, String defaultValue, HashSet<String> enumValues) {
+        this.description = description;
+        this.defaultValue = defaultValue;
+        this.enumValues = enumValues;
+    }
+}
diff --git a/samples/client/petstore/java/retrofit/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/retrofit/src/main/java/org/openapitools/client/ServerConfiguration.java
new file mode 100644
index 00000000000..43b5a16b308
--- /dev/null
+++ b/samples/client/petstore/java/retrofit/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -0,0 +1,60 @@
+package org.openapitools.client;
+
+import java.util.Map;
+
+import com.datadog.api.v1.client.ServerVariable;
+
+/**
+ * Representing a Server configuration.
+ */
+public class ServerConfiguration {
+    public String URL;
+    public String description;
+    public Map<String, ServerVariable> variables;
+
+    /**
+     * @param A URL to the target host.
+     * @param description A describtion of the host designated by the URL.
+     * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
+     */
+    public ServerConfiguration(String URL, String description, Map<String, ServerVariable> variables) {
+        this.URL = URL;
+        this.description = description;
+        this.variables = variables;
+    }
+
+    /**
+     * Format URL template using given variables.
+     *
+     * @param variables A map between a variable name and its value.
+     * @return Formatted URL.
+     */
+    public String URL(Map<String, String> variables) {
+        String url = this.URL;
+
+        // go through variables and replace placeholders
+        for (Map.Entry<String, ServerVariable> variable: this.variables.entrySet()) {
+            String name = variable.getKey();
+            ServerVariable serverVariable = variable.getValue();
+            String value = serverVariable.defaultValue;
+
+            if (variables != null && variables.containsKey(name)) {
+                value = variables.get(name);
+                if (serverVariable.enumValues.size() > 0 && !serverVariable.enumValues.contains(value)) {
+                    throw new RuntimeException("The variable " + name + " in the server URL has invalid value " + value + ".");
+                }
+            }
+            url = url.replaceAll("\\{" + name + "\\}", value);
+        }
+        return url;
+    }
+
+    /**
+     * Format URL template using default server variables.
+     *
+     * @return Formatted URL.
+     */
+    public String URL() {
+        return URL(null);
+    }
+}
diff --git a/samples/client/petstore/java/retrofit/src/main/java/org/openapitools/client/ServerVariable.java b/samples/client/petstore/java/retrofit/src/main/java/org/openapitools/client/ServerVariable.java
new file mode 100644
index 00000000000..c2f13e21666
--- /dev/null
+++ b/samples/client/petstore/java/retrofit/src/main/java/org/openapitools/client/ServerVariable.java
@@ -0,0 +1,23 @@
+package org.openapitools.client;
+
+import java.util.HashSet;
+
+/**
+ * Representing a Server Variable for server URL template substitution.
+ */
+public class ServerVariable {
+    public String description;
+    public String defaultValue;
+    public HashSet<String> enumValues = null;
+
+    /**
+     * @param description A description for the server variable.
+     * @param defaultValue The default value to use for substitution.
+     * @param enumValues An enumeration of string values to be used if the substitution options are from a limited set.
+     */
+    public ServerVariable(String description, String defaultValue, HashSet<String> enumValues) {
+        this.description = description;
+        this.defaultValue = defaultValue;
+        this.enumValues = enumValues;
+    }
+}
diff --git a/samples/client/petstore/java/retrofit2-play24/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/retrofit2-play24/src/main/java/org/openapitools/client/ServerConfiguration.java
new file mode 100644
index 00000000000..43b5a16b308
--- /dev/null
+++ b/samples/client/petstore/java/retrofit2-play24/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -0,0 +1,60 @@
+package org.openapitools.client;
+
+import java.util.Map;
+
+import com.datadog.api.v1.client.ServerVariable;
+
+/**
+ * Representing a Server configuration.
+ */
+public class ServerConfiguration {
+    public String URL;
+    public String description;
+    public Map<String, ServerVariable> variables;
+
+    /**
+     * @param A URL to the target host.
+     * @param description A describtion of the host designated by the URL.
+     * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
+     */
+    public ServerConfiguration(String URL, String description, Map<String, ServerVariable> variables) {
+        this.URL = URL;
+        this.description = description;
+        this.variables = variables;
+    }
+
+    /**
+     * Format URL template using given variables.
+     *
+     * @param variables A map between a variable name and its value.
+     * @return Formatted URL.
+     */
+    public String URL(Map<String, String> variables) {
+        String url = this.URL;
+
+        // go through variables and replace placeholders
+        for (Map.Entry<String, ServerVariable> variable: this.variables.entrySet()) {
+            String name = variable.getKey();
+            ServerVariable serverVariable = variable.getValue();
+            String value = serverVariable.defaultValue;
+
+            if (variables != null && variables.containsKey(name)) {
+                value = variables.get(name);
+                if (serverVariable.enumValues.size() > 0 && !serverVariable.enumValues.contains(value)) {
+                    throw new RuntimeException("The variable " + name + " in the server URL has invalid value " + value + ".");
+                }
+            }
+            url = url.replaceAll("\\{" + name + "\\}", value);
+        }
+        return url;
+    }
+
+    /**
+     * Format URL template using default server variables.
+     *
+     * @return Formatted URL.
+     */
+    public String URL() {
+        return URL(null);
+    }
+}
diff --git a/samples/client/petstore/java/retrofit2-play24/src/main/java/org/openapitools/client/ServerVariable.java b/samples/client/petstore/java/retrofit2-play24/src/main/java/org/openapitools/client/ServerVariable.java
new file mode 100644
index 00000000000..c2f13e21666
--- /dev/null
+++ b/samples/client/petstore/java/retrofit2-play24/src/main/java/org/openapitools/client/ServerVariable.java
@@ -0,0 +1,23 @@
+package org.openapitools.client;
+
+import java.util.HashSet;
+
+/**
+ * Representing a Server Variable for server URL template substitution.
+ */
+public class ServerVariable {
+    public String description;
+    public String defaultValue;
+    public HashSet<String> enumValues = null;
+
+    /**
+     * @param description A description for the server variable.
+     * @param defaultValue The default value to use for substitution.
+     * @param enumValues An enumeration of string values to be used if the substitution options are from a limited set.
+     */
+    public ServerVariable(String description, String defaultValue, HashSet<String> enumValues) {
+        this.description = description;
+        this.defaultValue = defaultValue;
+        this.enumValues = enumValues;
+    }
+}
diff --git a/samples/client/petstore/java/retrofit2-play25/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/retrofit2-play25/src/main/java/org/openapitools/client/ServerConfiguration.java
new file mode 100644
index 00000000000..43b5a16b308
--- /dev/null
+++ b/samples/client/petstore/java/retrofit2-play25/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -0,0 +1,60 @@
+package org.openapitools.client;
+
+import java.util.Map;
+
+import com.datadog.api.v1.client.ServerVariable;
+
+/**
+ * Representing a Server configuration.
+ */
+public class ServerConfiguration {
+    public String URL;
+    public String description;
+    public Map<String, ServerVariable> variables;
+
+    /**
+     * @param A URL to the target host.
+     * @param description A describtion of the host designated by the URL.
+     * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
+     */
+    public ServerConfiguration(String URL, String description, Map<String, ServerVariable> variables) {
+        this.URL = URL;
+        this.description = description;
+        this.variables = variables;
+    }
+
+    /**
+     * Format URL template using given variables.
+     *
+     * @param variables A map between a variable name and its value.
+     * @return Formatted URL.
+     */
+    public String URL(Map<String, String> variables) {
+        String url = this.URL;
+
+        // go through variables and replace placeholders
+        for (Map.Entry<String, ServerVariable> variable: this.variables.entrySet()) {
+            String name = variable.getKey();
+            ServerVariable serverVariable = variable.getValue();
+            String value = serverVariable.defaultValue;
+
+            if (variables != null && variables.containsKey(name)) {
+                value = variables.get(name);
+                if (serverVariable.enumValues.size() > 0 && !serverVariable.enumValues.contains(value)) {
+                    throw new RuntimeException("The variable " + name + " in the server URL has invalid value " + value + ".");
+                }
+            }
+            url = url.replaceAll("\\{" + name + "\\}", value);
+        }
+        return url;
+    }
+
+    /**
+     * Format URL template using default server variables.
+     *
+     * @return Formatted URL.
+     */
+    public String URL() {
+        return URL(null);
+    }
+}
diff --git a/samples/client/petstore/java/retrofit2-play25/src/main/java/org/openapitools/client/ServerVariable.java b/samples/client/petstore/java/retrofit2-play25/src/main/java/org/openapitools/client/ServerVariable.java
new file mode 100644
index 00000000000..c2f13e21666
--- /dev/null
+++ b/samples/client/petstore/java/retrofit2-play25/src/main/java/org/openapitools/client/ServerVariable.java
@@ -0,0 +1,23 @@
+package org.openapitools.client;
+
+import java.util.HashSet;
+
+/**
+ * Representing a Server Variable for server URL template substitution.
+ */
+public class ServerVariable {
+    public String description;
+    public String defaultValue;
+    public HashSet<String> enumValues = null;
+
+    /**
+     * @param description A description for the server variable.
+     * @param defaultValue The default value to use for substitution.
+     * @param enumValues An enumeration of string values to be used if the substitution options are from a limited set.
+     */
+    public ServerVariable(String description, String defaultValue, HashSet<String> enumValues) {
+        this.description = description;
+        this.defaultValue = defaultValue;
+        this.enumValues = enumValues;
+    }
+}
diff --git a/samples/client/petstore/java/retrofit2-play26/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/retrofit2-play26/src/main/java/org/openapitools/client/ServerConfiguration.java
new file mode 100644
index 00000000000..43b5a16b308
--- /dev/null
+++ b/samples/client/petstore/java/retrofit2-play26/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -0,0 +1,60 @@
+package org.openapitools.client;
+
+import java.util.Map;
+
+import com.datadog.api.v1.client.ServerVariable;
+
+/**
+ * Representing a Server configuration.
+ */
+public class ServerConfiguration {
+    public String URL;
+    public String description;
+    public Map<String, ServerVariable> variables;
+
+    /**
+     * @param A URL to the target host.
+     * @param description A describtion of the host designated by the URL.
+     * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
+     */
+    public ServerConfiguration(String URL, String description, Map<String, ServerVariable> variables) {
+        this.URL = URL;
+        this.description = description;
+        this.variables = variables;
+    }
+
+    /**
+     * Format URL template using given variables.
+     *
+     * @param variables A map between a variable name and its value.
+     * @return Formatted URL.
+     */
+    public String URL(Map<String, String> variables) {
+        String url = this.URL;
+
+        // go through variables and replace placeholders
+        for (Map.Entry<String, ServerVariable> variable: this.variables.entrySet()) {
+            String name = variable.getKey();
+            ServerVariable serverVariable = variable.getValue();
+            String value = serverVariable.defaultValue;
+
+            if (variables != null && variables.containsKey(name)) {
+                value = variables.get(name);
+                if (serverVariable.enumValues.size() > 0 && !serverVariable.enumValues.contains(value)) {
+                    throw new RuntimeException("The variable " + name + " in the server URL has invalid value " + value + ".");
+                }
+            }
+            url = url.replaceAll("\\{" + name + "\\}", value);
+        }
+        return url;
+    }
+
+    /**
+     * Format URL template using default server variables.
+     *
+     * @return Formatted URL.
+     */
+    public String URL() {
+        return URL(null);
+    }
+}
diff --git a/samples/client/petstore/java/retrofit2-play26/src/main/java/org/openapitools/client/ServerVariable.java b/samples/client/petstore/java/retrofit2-play26/src/main/java/org/openapitools/client/ServerVariable.java
new file mode 100644
index 00000000000..c2f13e21666
--- /dev/null
+++ b/samples/client/petstore/java/retrofit2-play26/src/main/java/org/openapitools/client/ServerVariable.java
@@ -0,0 +1,23 @@
+package org.openapitools.client;
+
+import java.util.HashSet;
+
+/**
+ * Representing a Server Variable for server URL template substitution.
+ */
+public class ServerVariable {
+    public String description;
+    public String defaultValue;
+    public HashSet<String> enumValues = null;
+
+    /**
+     * @param description A description for the server variable.
+     * @param defaultValue The default value to use for substitution.
+     * @param enumValues An enumeration of string values to be used if the substitution options are from a limited set.
+     */
+    public ServerVariable(String description, String defaultValue, HashSet<String> enumValues) {
+        this.description = description;
+        this.defaultValue = defaultValue;
+        this.enumValues = enumValues;
+    }
+}
diff --git a/samples/client/petstore/java/retrofit2/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/retrofit2/src/main/java/org/openapitools/client/ServerConfiguration.java
new file mode 100644
index 00000000000..43b5a16b308
--- /dev/null
+++ b/samples/client/petstore/java/retrofit2/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -0,0 +1,60 @@
+package org.openapitools.client;
+
+import java.util.Map;
+
+import com.datadog.api.v1.client.ServerVariable;
+
+/**
+ * Representing a Server configuration.
+ */
+public class ServerConfiguration {
+    public String URL;
+    public String description;
+    public Map<String, ServerVariable> variables;
+
+    /**
+     * @param A URL to the target host.
+     * @param description A describtion of the host designated by the URL.
+     * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
+     */
+    public ServerConfiguration(String URL, String description, Map<String, ServerVariable> variables) {
+        this.URL = URL;
+        this.description = description;
+        this.variables = variables;
+    }
+
+    /**
+     * Format URL template using given variables.
+     *
+     * @param variables A map between a variable name and its value.
+     * @return Formatted URL.
+     */
+    public String URL(Map<String, String> variables) {
+        String url = this.URL;
+
+        // go through variables and replace placeholders
+        for (Map.Entry<String, ServerVariable> variable: this.variables.entrySet()) {
+            String name = variable.getKey();
+            ServerVariable serverVariable = variable.getValue();
+            String value = serverVariable.defaultValue;
+
+            if (variables != null && variables.containsKey(name)) {
+                value = variables.get(name);
+                if (serverVariable.enumValues.size() > 0 && !serverVariable.enumValues.contains(value)) {
+                    throw new RuntimeException("The variable " + name + " in the server URL has invalid value " + value + ".");
+                }
+            }
+            url = url.replaceAll("\\{" + name + "\\}", value);
+        }
+        return url;
+    }
+
+    /**
+     * Format URL template using default server variables.
+     *
+     * @return Formatted URL.
+     */
+    public String URL() {
+        return URL(null);
+    }
+}
diff --git a/samples/client/petstore/java/retrofit2/src/main/java/org/openapitools/client/ServerVariable.java b/samples/client/petstore/java/retrofit2/src/main/java/org/openapitools/client/ServerVariable.java
new file mode 100644
index 00000000000..c2f13e21666
--- /dev/null
+++ b/samples/client/petstore/java/retrofit2/src/main/java/org/openapitools/client/ServerVariable.java
@@ -0,0 +1,23 @@
+package org.openapitools.client;
+
+import java.util.HashSet;
+
+/**
+ * Representing a Server Variable for server URL template substitution.
+ */
+public class ServerVariable {
+    public String description;
+    public String defaultValue;
+    public HashSet<String> enumValues = null;
+
+    /**
+     * @param description A description for the server variable.
+     * @param defaultValue The default value to use for substitution.
+     * @param enumValues An enumeration of string values to be used if the substitution options are from a limited set.
+     */
+    public ServerVariable(String description, String defaultValue, HashSet<String> enumValues) {
+        this.description = description;
+        this.defaultValue = defaultValue;
+        this.enumValues = enumValues;
+    }
+}
diff --git a/samples/client/petstore/java/retrofit2rx/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/retrofit2rx/src/main/java/org/openapitools/client/ServerConfiguration.java
new file mode 100644
index 00000000000..43b5a16b308
--- /dev/null
+++ b/samples/client/petstore/java/retrofit2rx/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -0,0 +1,60 @@
+package org.openapitools.client;
+
+import java.util.Map;
+
+import com.datadog.api.v1.client.ServerVariable;
+
+/**
+ * Representing a Server configuration.
+ */
+public class ServerConfiguration {
+    public String URL;
+    public String description;
+    public Map<String, ServerVariable> variables;
+
+    /**
+     * @param A URL to the target host.
+     * @param description A describtion of the host designated by the URL.
+     * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
+     */
+    public ServerConfiguration(String URL, String description, Map<String, ServerVariable> variables) {
+        this.URL = URL;
+        this.description = description;
+        this.variables = variables;
+    }
+
+    /**
+     * Format URL template using given variables.
+     *
+     * @param variables A map between a variable name and its value.
+     * @return Formatted URL.
+     */
+    public String URL(Map<String, String> variables) {
+        String url = this.URL;
+
+        // go through variables and replace placeholders
+        for (Map.Entry<String, ServerVariable> variable: this.variables.entrySet()) {
+            String name = variable.getKey();
+            ServerVariable serverVariable = variable.getValue();
+            String value = serverVariable.defaultValue;
+
+            if (variables != null && variables.containsKey(name)) {
+                value = variables.get(name);
+                if (serverVariable.enumValues.size() > 0 && !serverVariable.enumValues.contains(value)) {
+                    throw new RuntimeException("The variable " + name + " in the server URL has invalid value " + value + ".");
+                }
+            }
+            url = url.replaceAll("\\{" + name + "\\}", value);
+        }
+        return url;
+    }
+
+    /**
+     * Format URL template using default server variables.
+     *
+     * @return Formatted URL.
+     */
+    public String URL() {
+        return URL(null);
+    }
+}
diff --git a/samples/client/petstore/java/retrofit2rx/src/main/java/org/openapitools/client/ServerVariable.java b/samples/client/petstore/java/retrofit2rx/src/main/java/org/openapitools/client/ServerVariable.java
new file mode 100644
index 00000000000..c2f13e21666
--- /dev/null
+++ b/samples/client/petstore/java/retrofit2rx/src/main/java/org/openapitools/client/ServerVariable.java
@@ -0,0 +1,23 @@
+package org.openapitools.client;
+
+import java.util.HashSet;
+
+/**
+ * Representing a Server Variable for server URL template substitution.
+ */
+public class ServerVariable {
+    public String description;
+    public String defaultValue;
+    public HashSet<String> enumValues = null;
+
+    /**
+     * @param description A description for the server variable.
+     * @param defaultValue The default value to use for substitution.
+     * @param enumValues An enumeration of string values to be used if the substitution options are from a limited set.
+     */
+    public ServerVariable(String description, String defaultValue, HashSet<String> enumValues) {
+        this.description = description;
+        this.defaultValue = defaultValue;
+        this.enumValues = enumValues;
+    }
+}
diff --git a/samples/client/petstore/java/retrofit2rx2/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/retrofit2rx2/src/main/java/org/openapitools/client/ServerConfiguration.java
new file mode 100644
index 00000000000..43b5a16b308
--- /dev/null
+++ b/samples/client/petstore/java/retrofit2rx2/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -0,0 +1,60 @@
+package org.openapitools.client;
+
+import java.util.Map;
+
+import com.datadog.api.v1.client.ServerVariable;
+
+/**
+ * Representing a Server configuration.
+ */
+public class ServerConfiguration {
+    public String URL;
+    public String description;
+    public Map<String, ServerVariable> variables;
+
+    /**
+     * @param A URL to the target host.
+     * @param description A describtion of the host designated by the URL.
+     * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
+     */
+    public ServerConfiguration(String URL, String description, Map<String, ServerVariable> variables) {
+        this.URL = URL;
+        this.description = description;
+        this.variables = variables;
+    }
+
+    /**
+     * Format URL template using given variables.
+     *
+     * @param variables A map between a variable name and its value.
+     * @return Formatted URL.
+     */
+    public String URL(Map<String, String> variables) {
+        String url = this.URL;
+
+        // go through variables and replace placeholders
+        for (Map.Entry<String, ServerVariable> variable: this.variables.entrySet()) {
+            String name = variable.getKey();
+            ServerVariable serverVariable = variable.getValue();
+            String value = serverVariable.defaultValue;
+
+            if (variables != null && variables.containsKey(name)) {
+                value = variables.get(name);
+                if (serverVariable.enumValues.size() > 0 && !serverVariable.enumValues.contains(value)) {
+                    throw new RuntimeException("The variable " + name + " in the server URL has invalid value " + value + ".");
+                }
+            }
+            url = url.replaceAll("\\{" + name + "\\}", value);
+        }
+        return url;
+    }
+
+    /**
+     * Format URL template using default server variables.
+     *
+     * @return Formatted URL.
+     */
+    public String URL() {
+        return URL(null);
+    }
+}
diff --git a/samples/client/petstore/java/retrofit2rx2/src/main/java/org/openapitools/client/ServerVariable.java b/samples/client/petstore/java/retrofit2rx2/src/main/java/org/openapitools/client/ServerVariable.java
new file mode 100644
index 00000000000..c2f13e21666
--- /dev/null
+++ b/samples/client/petstore/java/retrofit2rx2/src/main/java/org/openapitools/client/ServerVariable.java
@@ -0,0 +1,23 @@
+package org.openapitools.client;
+
+import java.util.HashSet;
+
+/**
+ * Representing a Server Variable for server URL template substitution.
+ */
+public class ServerVariable {
+    public String description;
+    public String defaultValue;
+    public HashSet<String> enumValues = null;
+
+    /**
+     * @param description A description for the server variable.
+     * @param defaultValue The default value to use for substitution.
+     * @param enumValues An enumeration of string values to be used if the substitution options are from a limited set.
+     */
+    public ServerVariable(String description, String defaultValue, HashSet<String> enumValues) {
+        this.description = description;
+        this.defaultValue = defaultValue;
+        this.enumValues = enumValues;
+    }
+}
diff --git a/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/ServerConfiguration.java
new file mode 100644
index 00000000000..43b5a16b308
--- /dev/null
+++ b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -0,0 +1,60 @@
+package org.openapitools.client;
+
+import java.util.Map;
+
+import com.datadog.api.v1.client.ServerVariable;
+
+/**
+ * Representing a Server configuration.
+ */
+public class ServerConfiguration {
+    public String URL;
+    public String description;
+    public Map<String, ServerVariable> variables;
+
+    /**
+     * @param A URL to the target host.
+     * @param description A describtion of the host designated by the URL.
+     * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
+     */
+    public ServerConfiguration(String URL, String description, Map<String, ServerVariable> variables) {
+        this.URL = URL;
+        this.description = description;
+        this.variables = variables;
+    }
+
+    /**
+     * Format URL template using given variables.
+     *
+     * @param variables A map between a variable name and its value.
+     * @return Formatted URL.
+     */
+    public String URL(Map<String, String> variables) {
+        String url = this.URL;
+
+        // go through variables and replace placeholders
+        for (Map.Entry<String, ServerVariable> variable: this.variables.entrySet()) {
+            String name = variable.getKey();
+            ServerVariable serverVariable = variable.getValue();
+            String value = serverVariable.defaultValue;
+
+            if (variables != null && variables.containsKey(name)) {
+                value = variables.get(name);
+                if (serverVariable.enumValues.size() > 0 && !serverVariable.enumValues.contains(value)) {
+                    throw new RuntimeException("The variable " + name + " in the server URL has invalid value " + value + ".");
+                }
+            }
+            url = url.replaceAll("\\{" + name + "\\}", value);
+        }
+        return url;
+    }
+
+    /**
+     * Format URL template using default server variables.
+     *
+     * @return Formatted URL.
+     */
+    public String URL() {
+        return URL(null);
+    }
+}
diff --git a/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/ServerVariable.java b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/ServerVariable.java
new file mode 100644
index 00000000000..c2f13e21666
--- /dev/null
+++ b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/ServerVariable.java
@@ -0,0 +1,23 @@
+package org.openapitools.client;
+
+import java.util.HashSet;
+
+/**
+ * Representing a Server Variable for server URL template substitution.
+ */
+public class ServerVariable {
+    public String description;
+    public String defaultValue;
+    public HashSet<String> enumValues = null;
+
+    /**
+     * @param description A description for the server variable.
+     * @param defaultValue The default value to use for substitution.
+     * @param enumValues An enumeration of string values to be used if the substitution options are from a limited set.
+     */
+    public ServerVariable(String description, String defaultValue, HashSet<String> enumValues) {
+        this.description = description;
+        this.defaultValue = defaultValue;
+        this.enumValues = enumValues;
+    }
+}
diff --git a/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/ServerConfiguration.java
new file mode 100644
index 00000000000..43b5a16b308
--- /dev/null
+++ b/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -0,0 +1,60 @@
+package org.openapitools.client;
+
+import java.util.Map;
+
+import com.datadog.api.v1.client.ServerVariable;
+
+/**
+ * Representing a Server configuration.
+ */
+public class ServerConfiguration {
+    public String URL;
+    public String description;
+    public Map<String, ServerVariable> variables;
+
+    /**
+     * @param A URL to the target host.
+     * @param description A describtion of the host designated by the URL.
+     * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
+     */
+    public ServerConfiguration(String URL, String description, Map<String, ServerVariable> variables) {
+        this.URL = URL;
+        this.description = description;
+        this.variables = variables;
+    }
+
+    /**
+     * Format URL template using given variables.
+     *
+     * @param variables A map between a variable name and its value.
+     * @return Formatted URL.
+     */
+    public String URL(Map<String, String> variables) {
+        String url = this.URL;
+
+        // go through variables and replace placeholders
+        for (Map.Entry<String, ServerVariable> variable: this.variables.entrySet()) {
+            String name = variable.getKey();
+            ServerVariable serverVariable = variable.getValue();
+            String value = serverVariable.defaultValue;
+
+            if (variables != null && variables.containsKey(name)) {
+                value = variables.get(name);
+                if (serverVariable.enumValues.size() > 0 && !serverVariable.enumValues.contains(value)) {
+                    throw new RuntimeException("The variable " + name + " in the server URL has invalid value " + value + ".");
+                }
+            }
+            url = url.replaceAll("\\{" + name + "\\}", value);
+        }
+        return url;
+    }
+
+    /**
+     * Format URL template using default server variables.
+     *
+     * @return Formatted URL.
+     */
+    public String URL() {
+        return URL(null);
+    }
+}
diff --git a/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/ServerVariable.java b/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/ServerVariable.java
new file mode 100644
index 00000000000..c2f13e21666
--- /dev/null
+++ b/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/ServerVariable.java
@@ -0,0 +1,23 @@
+package org.openapitools.client;
+
+import java.util.HashSet;
+
+/**
+ * Representing a Server Variable for server URL template substitution.
+ */
+public class ServerVariable {
+    public String description;
+    public String defaultValue;
+    public HashSet<String> enumValues = null;
+
+    /**
+     * @param description A description for the server variable.
+     * @param defaultValue The default value to use for substitution.
+     * @param enumValues An enumeration of string values to be used if the substitution options are from a limited set.
+     */
+    public ServerVariable(String description, String defaultValue, HashSet<String> enumValues) {
+        this.description = description;
+        this.defaultValue = defaultValue;
+        this.enumValues = enumValues;
+    }
+}
-- 
GitLab


From 807ece0fa5d7293639bc62d8d698c8a4ff00ae22 Mon Sep 17 00:00:00 2001
From: Jiri Kuncar <jiri.kuncar@gmail.com>
Date: Wed, 15 Jan 2020 18:17:40 +0100
Subject: [PATCH 02/10] Deprecate old signature of invokeAPI method

---
 .../resources/Java/libraries/jersey2/ApiClient.mustache   | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/ApiClient.mustache
index ee4d7a6d10c..bef8929e660 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/ApiClient.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/ApiClient.mustache
@@ -906,6 +906,14 @@ public class ApiClient {
     }
   }
 
+  /**
+   * @deprecated Add qualified name of the operation as a first parameter.
+   */
+  @Deprecated
+  public <T> ApiResponse<T> invokeAPI(String path, String method, List<Pair> queryParams, Object body, Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String accept, String contentType, String[] authNames, GenericType<T> returnType) throws ApiException {
+    return invokeAPI(null, path, method, queryParams, body, headerParams, cookieParams, formParams, accept, contentType, authNames, returnType);
+  }
+
   /**
    * Build the Client used to make HTTP requests.
    * @param debugging Debug setting
-- 
GitLab


From 6577bde7638a546f7badc1cf88938a9633fa2e1a Mon Sep 17 00:00:00 2001
From: Jiri Kuncar <jiri.kuncar@gmail.com>
Date: Wed, 15 Jan 2020 18:20:29 +0100
Subject: [PATCH 03/10] Regenerated

---
 .../main/java/org/openapitools/client/ApiClient.java   | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/ApiClient.java
index b990c618452..1bde12126f4 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/ApiClient.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/ApiClient.java
@@ -724,7 +724,7 @@ public class ApiClient {
       if (operationServers.containsKey(operation)) {
         Integer index = operationServerIndex.getOrDefault(operation, serverIndex);
         Map<String, String> variables = operationServerVariables.getOrDefault(operation, serverVariables);
-        targetURL = operationServers.get(operation)[index].URL(variables);
+        targetURL = operationServers.get(operation).get(index).URL(variables);
       } else {
         targetURL = servers[serverIndex].URL(serverVariables) + path;
       }
@@ -835,6 +835,14 @@ public class ApiClient {
     }
   }
 
+  /**
+   * @deprecated Add qualified name of the operation as a first parameter.
+   */
+  @Deprecated
+  public <T> ApiResponse<T> invokeAPI(String path, String method, List<Pair> queryParams, Object body, Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String accept, String contentType, String[] authNames, GenericType<T> returnType) throws ApiException {
+    return invokeAPI(null, path, method, queryParams, body, headerParams, cookieParams, formParams, accept, contentType, authNames, returnType);
+  }
+
   /**
    * Build the Client used to make HTTP requests.
    * @param debugging Debug setting
-- 
GitLab


From 5b93d63ac9b0bc3e5336669a1c49621de601f375 Mon Sep 17 00:00:00 2001
From: Jiri Kuncar <jiri.kuncar@gmail.com>
Date: Thu, 16 Jan 2020 11:40:54 +0100
Subject: [PATCH 04/10] throw ArrayIndexOutOfBoundsException

---
 .../main/resources/Java/ApiClient.mustache    | 15 ++++++----
 .../Java/libraries/jersey2/ApiClient.mustache | 28 +++++++++++++------
 2 files changed, 30 insertions(+), 13 deletions(-)

diff --git a/modules/openapi-generator/src/main/resources/Java/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Java/ApiClient.mustache
index fe333042737..fd42a0d2fab 100644
--- a/modules/openapi-generator/src/main/resources/Java/ApiClient.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/ApiClient.mustache
@@ -67,7 +67,7 @@ public class ApiClient {
   private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
   private Map<String, String> defaultCookieMap = new HashMap<String, String>();
   private String basePath = "{{{basePath}}}";
-  protected ServerConfiguration[] servers{{#servers}}{{#-first}} = {
+  protected List<ServerConfiguration> servers = new ArrayList<ServerConfiguration>({{#servers}}{{#-first}}Arrays.asList(
 {{/-first}}    new ServerConfiguration(
       "{{{url}}}",
       "{{{description}}}{{^description}}No description provided{{/description}}",
@@ -91,7 +91,7 @@ public class ApiClient {
       }}{{/-last}}{{/variables}}
     ){{^-last}},{{/-last}}
   {{#-last}}
-  }{{/-last}}{{/servers}};
+  ){{/-last}}{{/servers}});
   protected Integer serverIndex = 0;
   protected Map<String, String> serverVariables = null;
   private boolean debugging = false;
@@ -208,11 +208,11 @@ public class ApiClient {
     return this;
   }
 
-  public ServerConfiguration[] getServers() {
+  public List<ServerConfiguration> getServers() {
     return servers;
   }
 
-  public ApiClient setServers(ServerConfiguration[] servers) {
+  public ApiClient setServers(List<ServerConfiguration> servers) {
     this.servers = servers;
     return this;
   }
@@ -686,7 +686,12 @@ public class ApiClient {
   private String buildUrl(String path, List<Pair> queryParams, List<Pair> collectionQueryParams) {
     String baseURL;
     if (serverIndex != null) {
-      baseURL = servers[serverIndex].URL(serverVariables);
+      if (index < 0 || index >= servers.size()) {
+        throw new ArrayIndexOutOfBoundsException(String.format(
+          "Invalid index %d when selecting the host settings. Must be less than %d", index, servers.size()
+        ));
+      }
+      baseURL = servers.get(serverIndex).URL(serverVariables);
     } else {
       baseURL = basePath;
     }
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/ApiClient.mustache
index bef8929e660..be4e4f6c3f7 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/ApiClient.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/ApiClient.mustache
@@ -69,7 +69,7 @@ public class ApiClient {
   protected Map<String, String> defaultHeaderMap = new HashMap<String, String>();
   protected Map<String, String> defaultCookieMap = new HashMap<String, String>();
   protected String basePath = "{{{basePath}}}";
-  protected ServerConfiguration[] servers{{#servers}}{{#-first}} = {
+  protected List<ServerConfiguration> servers = new ArrayList<ServerConfiguration>({{#servers}}{{#-first}}Arrays.asList(
 {{/-first}}    new ServerConfiguration(
       "{{{url}}}",
       "{{{description}}}{{^description}}No description provided{{/description}}",
@@ -93,7 +93,7 @@ public class ApiClient {
       }}{{/-last}}{{/variables}}
     ){{^-last}},{{/-last}}
   {{#-last}}
-  }{{/-last}}{{/servers}};
+  ){{/-last}}{{/servers}});
   protected Integer serverIndex = 0;
   protected Map<String, String> serverVariables = null;
   protected Map<String, List<ServerConfiguration>> operationServers = new HashMap<String, List<ServerConfiguration>>() {{
@@ -194,11 +194,11 @@ public class ApiClient {
     return this;
   }
 
-  public ServerConfiguration[] getServers() {
+  public List<ServerConfiguration> getServers() {
     return servers;
   }
 
-  public ApiClient setServers(ServerConfiguration[] servers) {
+  public ApiClient setServers(List<ServerConfiguration> servers) {
     this.servers = servers;
     return this;
   }
@@ -792,13 +792,25 @@ public class ApiClient {
     // to support (constant) query string in `path`, e.g. "/posts?draft=1"
     String targetURL;
     if (serverIndex != null) {
+      Integer index;
+      List<ServerConfiguration> serverConfigurations;
+      Map<String, String> variables;
+
       if (operationServers.containsKey(operation)) {
-        Integer index = operationServerIndex.getOrDefault(operation, serverIndex);
-        Map<String, String> variables = operationServerVariables.getOrDefault(operation, serverVariables);
-        targetURL = operationServers.get(operation).get(index).URL(variables);
+        index = operationServerIndex.getOrDefault(operation, serverIndex);
+        variables = operationServerVariables.getOrDefault(operation, serverVariables);
+        serverConfigurations = operationServers.get(operation);
       } else {
-        targetURL = servers[serverIndex].URL(serverVariables) + path;
+        index = serverIndex;
+        variables = serverVariables;
+        serverConfigurations = servers;
+      }
+      if (index < 0 || index >= serverConfigurations.size()) {
+        throw new ArrayIndexOutOfBoundsException(String.format(
+          "Invalid index %d when selecting the host settings. Must be less than %d", index, serverConfigurations.size()
+        ));
       }
+      targetURL = serverConfigurations.get(index).URL(variables) + path;
     } else {
       targetURL = this.basePath + path;
     }
-- 
GitLab


From 07965b9b78505b663bff0b4fb33baea3639778ab Mon Sep 17 00:00:00 2001
From: Jiri Kuncar <jiri.kuncar@gmail.com>
Date: Thu, 16 Jan 2020 11:56:56 +0100
Subject: [PATCH 05/10] Regenerated

---
 .../org/openapitools/client/ApiClient.java    | 15 +++++---
 .../org/openapitools/client/ApiClient.java    | 36 ++++++++++++++-----
 .../org/openapitools/client/ApiClient.java    | 36 ++++++++++++++-----
 .../org/openapitools/client/ApiClient.java    | 28 ++++++++++-----
 4 files changed, 86 insertions(+), 29 deletions(-)

diff --git a/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/ApiClient.java
index ce9605199da..5f55427560d 100644
--- a/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/ApiClient.java
+++ b/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/ApiClient.java
@@ -66,13 +66,13 @@ public class ApiClient {
   private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
   private Map<String, String> defaultCookieMap = new HashMap<String, String>();
   private String basePath = "http://petstore.swagger.io:80/v2";
-  protected ServerConfiguration[] servers = {
+  protected List<ServerConfiguration> servers = new ArrayList<ServerConfiguration>(Arrays.asList(
     new ServerConfiguration(
       "http://petstore.swagger.io:80/v2",
       "No description provided",
       new HashMap<String, ServerVariable>()
     )
-  };
+  ));
   protected Integer serverIndex = 0;
   protected Map<String, String> serverVariables = null;
   private boolean debugging = false;
@@ -181,11 +181,11 @@ public class ApiClient {
     return this;
   }
 
-  public ServerConfiguration[] getServers() {
+  public List<ServerConfiguration> getServers() {
     return servers;
   }
 
-  public ApiClient setServers(ServerConfiguration[] servers) {
+  public ApiClient setServers(List<ServerConfiguration> servers) {
     this.servers = servers;
     return this;
   }
@@ -657,7 +657,12 @@ public class ApiClient {
   private String buildUrl(String path, List<Pair> queryParams, List<Pair> collectionQueryParams) {
     String baseURL;
     if (serverIndex != null) {
-      baseURL = servers[serverIndex].URL(serverVariables);
+      if (index < 0 || index >= servers.size()) {
+        throw new ArrayIndexOutOfBoundsException(String.format(
+          "Invalid index %d when selecting the host settings. Must be less than %d", index, servers.size()
+        ));
+      }
+      baseURL = servers.get(serverIndex).URL(serverVariables);
     } else {
       baseURL = basePath;
     }
diff --git a/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/ApiClient.java
index 89095f0680d..0ebac9eb3bd 100644
--- a/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/ApiClient.java
+++ b/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/ApiClient.java
@@ -60,13 +60,13 @@ public class ApiClient {
   protected Map<String, String> defaultHeaderMap = new HashMap<String, String>();
   protected Map<String, String> defaultCookieMap = new HashMap<String, String>();
   protected String basePath = "http://petstore.swagger.io:80/v2";
-  protected ServerConfiguration[] servers = {
+  protected List<ServerConfiguration> servers = new ArrayList<ServerConfiguration>(Arrays.asList(
     new ServerConfiguration(
       "http://petstore.swagger.io:80/v2",
       "No description provided",
       new HashMap<String, ServerVariable>()
     )
-  };
+  ));
   protected Integer serverIndex = 0;
   protected Map<String, String> serverVariables = null;
   protected Map<String, List<ServerConfiguration>> operationServers = new HashMap<String, List<ServerConfiguration>>() {{
@@ -130,11 +130,11 @@ public class ApiClient {
     return this;
   }
 
-  public ServerConfiguration[] getServers() {
+  public List<ServerConfiguration> getServers() {
     return servers;
   }
 
-  public ApiClient setServers(ServerConfiguration[] servers) {
+  public ApiClient setServers(List<ServerConfiguration> servers) {
     this.servers = servers;
     return this;
   }
@@ -721,13 +721,25 @@ public class ApiClient {
     // to support (constant) query string in `path`, e.g. "/posts?draft=1"
     String targetURL;
     if (serverIndex != null) {
+      Integer index;
+      List<ServerConfiguration> serverConfigurations;
+      Map<String, String> variables;
+
       if (operationServers.containsKey(operation)) {
-        Integer index = operationServerIndex.getOrDefault(operation, serverIndex);
-        Map<String, String> variables = operationServerVariables.getOrDefault(operation, serverVariables);
-        targetURL = operationServers.get(operation)[index].URL(variables);
+        index = operationServerIndex.getOrDefault(operation, serverIndex);
+        variables = operationServerVariables.getOrDefault(operation, serverVariables);
+        serverConfigurations = operationServers.get(operation);
       } else {
-        targetURL = servers[serverIndex].URL(serverVariables) + path;
+        index = serverIndex;
+        variables = serverVariables;
+        serverConfigurations = servers;
+      }
+      if (index < 0 || index >= serverConfigurations.size()) {
+        throw new ArrayIndexOutOfBoundsException(String.format(
+          "Invalid index %d when selecting the host settings. Must be less than %d", index, serverConfigurations.size()
+        ));
       }
+      targetURL = serverConfigurations.get(index).URL(variables) + path;
     } else {
       targetURL = this.basePath + path;
     }
@@ -835,6 +847,14 @@ public class ApiClient {
     }
   }
 
+  /**
+   * @deprecated Add qualified name of the operation as a first parameter.
+   */
+  @Deprecated
+  public <T> ApiResponse<T> invokeAPI(String path, String method, List<Pair> queryParams, Object body, Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String accept, String contentType, String[] authNames, GenericType<T> returnType) throws ApiException {
+    return invokeAPI(null, path, method, queryParams, body, headerParams, cookieParams, formParams, accept, contentType, authNames, returnType);
+  }
+
   /**
    * Build the Client used to make HTTP requests.
    * @param debugging Debug setting
diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/ApiClient.java
index b990c618452..88984d8ceab 100644
--- a/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/ApiClient.java
+++ b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/ApiClient.java
@@ -61,13 +61,13 @@ public class ApiClient {
   protected Map<String, String> defaultHeaderMap = new HashMap<String, String>();
   protected Map<String, String> defaultCookieMap = new HashMap<String, String>();
   protected String basePath = "http://petstore.swagger.io:80/v2";
-  protected ServerConfiguration[] servers = {
+  protected List<ServerConfiguration> servers = new ArrayList<ServerConfiguration>(Arrays.asList(
     new ServerConfiguration(
       "http://petstore.swagger.io:80/v2",
       "No description provided",
       new HashMap<String, ServerVariable>()
     )
-  };
+  ));
   protected Integer serverIndex = 0;
   protected Map<String, String> serverVariables = null;
   protected Map<String, List<ServerConfiguration>> operationServers = new HashMap<String, List<ServerConfiguration>>() {{
@@ -131,11 +131,11 @@ public class ApiClient {
     return this;
   }
 
-  public ServerConfiguration[] getServers() {
+  public List<ServerConfiguration> getServers() {
     return servers;
   }
 
-  public ApiClient setServers(ServerConfiguration[] servers) {
+  public ApiClient setServers(List<ServerConfiguration> servers) {
     this.servers = servers;
     return this;
   }
@@ -721,13 +721,25 @@ public class ApiClient {
     // to support (constant) query string in `path`, e.g. "/posts?draft=1"
     String targetURL;
     if (serverIndex != null) {
+      Integer index;
+      List<ServerConfiguration> serverConfigurations;
+      Map<String, String> variables;
+
       if (operationServers.containsKey(operation)) {
-        Integer index = operationServerIndex.getOrDefault(operation, serverIndex);
-        Map<String, String> variables = operationServerVariables.getOrDefault(operation, serverVariables);
-        targetURL = operationServers.get(operation)[index].URL(variables);
+        index = operationServerIndex.getOrDefault(operation, serverIndex);
+        variables = operationServerVariables.getOrDefault(operation, serverVariables);
+        serverConfigurations = operationServers.get(operation);
       } else {
-        targetURL = servers[serverIndex].URL(serverVariables) + path;
+        index = serverIndex;
+        variables = serverVariables;
+        serverConfigurations = servers;
+      }
+      if (index < 0 || index >= serverConfigurations.size()) {
+        throw new ArrayIndexOutOfBoundsException(String.format(
+          "Invalid index %d when selecting the host settings. Must be less than %d", index, serverConfigurations.size()
+        ));
       }
+      targetURL = serverConfigurations.get(index).URL(variables) + path;
     } else {
       targetURL = this.basePath + path;
     }
@@ -835,6 +847,14 @@ public class ApiClient {
     }
   }
 
+  /**
+   * @deprecated Add qualified name of the operation as a first parameter.
+   */
+  @Deprecated
+  public <T> ApiResponse<T> invokeAPI(String path, String method, List<Pair> queryParams, Object body, Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String accept, String contentType, String[] authNames, GenericType<T> returnType) throws ApiException {
+    return invokeAPI(null, path, method, queryParams, body, headerParams, cookieParams, formParams, accept, contentType, authNames, returnType);
+  }
+
   /**
    * Build the Client used to make HTTP requests.
    * @param debugging Debug setting
diff --git a/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/ApiClient.java
index 1bde12126f4..88984d8ceab 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/ApiClient.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/ApiClient.java
@@ -61,13 +61,13 @@ public class ApiClient {
   protected Map<String, String> defaultHeaderMap = new HashMap<String, String>();
   protected Map<String, String> defaultCookieMap = new HashMap<String, String>();
   protected String basePath = "http://petstore.swagger.io:80/v2";
-  protected ServerConfiguration[] servers = {
+  protected List<ServerConfiguration> servers = new ArrayList<ServerConfiguration>(Arrays.asList(
     new ServerConfiguration(
       "http://petstore.swagger.io:80/v2",
       "No description provided",
       new HashMap<String, ServerVariable>()
     )
-  };
+  ));
   protected Integer serverIndex = 0;
   protected Map<String, String> serverVariables = null;
   protected Map<String, List<ServerConfiguration>> operationServers = new HashMap<String, List<ServerConfiguration>>() {{
@@ -131,11 +131,11 @@ public class ApiClient {
     return this;
   }
 
-  public ServerConfiguration[] getServers() {
+  public List<ServerConfiguration> getServers() {
     return servers;
   }
 
-  public ApiClient setServers(ServerConfiguration[] servers) {
+  public ApiClient setServers(List<ServerConfiguration> servers) {
     this.servers = servers;
     return this;
   }
@@ -721,13 +721,25 @@ public class ApiClient {
     // to support (constant) query string in `path`, e.g. "/posts?draft=1"
     String targetURL;
     if (serverIndex != null) {
+      Integer index;
+      List<ServerConfiguration> serverConfigurations;
+      Map<String, String> variables;
+
       if (operationServers.containsKey(operation)) {
-        Integer index = operationServerIndex.getOrDefault(operation, serverIndex);
-        Map<String, String> variables = operationServerVariables.getOrDefault(operation, serverVariables);
-        targetURL = operationServers.get(operation).get(index).URL(variables);
+        index = operationServerIndex.getOrDefault(operation, serverIndex);
+        variables = operationServerVariables.getOrDefault(operation, serverVariables);
+        serverConfigurations = operationServers.get(operation);
       } else {
-        targetURL = servers[serverIndex].URL(serverVariables) + path;
+        index = serverIndex;
+        variables = serverVariables;
+        serverConfigurations = servers;
+      }
+      if (index < 0 || index >= serverConfigurations.size()) {
+        throw new ArrayIndexOutOfBoundsException(String.format(
+          "Invalid index %d when selecting the host settings. Must be less than %d", index, serverConfigurations.size()
+        ));
       }
+      targetURL = serverConfigurations.get(index).URL(variables) + path;
     } else {
       targetURL = this.basePath + path;
     }
-- 
GitLab


From edca168d19e1cbca10593e42e21354d1b0521e6c Mon Sep 17 00:00:00 2001
From: Jiri Kuncar <jiri.kuncar@gmail.com>
Date: Tue, 11 Feb 2020 16:37:23 +0100
Subject: [PATCH 06/10] Update
 modules/openapi-generator/src/main/resources/Java/ServerConfiguration.mustache

---
 .../src/main/resources/Java/ServerConfiguration.mustache        | 2 --
 .../main/resources/Java/libraries/jersey2/ApiClient.mustache    | 2 --
 2 files changed, 4 deletions(-)

diff --git a/modules/openapi-generator/src/main/resources/Java/ServerConfiguration.mustache b/modules/openapi-generator/src/main/resources/Java/ServerConfiguration.mustache
index c76a097d24c..8c9bd14e982 100644
--- a/modules/openapi-generator/src/main/resources/Java/ServerConfiguration.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/ServerConfiguration.mustache
@@ -2,8 +2,6 @@ package {{invokerPackage}};
 
 import java.util.Map;
 
-import com.datadog.api.v1.client.ServerVariable;
-
 /**
  * Representing a Server configuration.
  */
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/ApiClient.mustache
index 57f279db47c..ca3a733cbf6 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/ApiClient.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/ApiClient.mustache
@@ -57,8 +57,6 @@ import {{invokerPackage}}.auth.Authentication;
 import {{invokerPackage}}.auth.HttpBasicAuth;
 import {{invokerPackage}}.auth.HttpBearerAuth;
 import {{invokerPackage}}.auth.ApiKeyAuth;
-import {{invokerPackage}}.ServerConfiguration;
-import {{invokerPackage}}.ServerVariable;
 
 {{#hasOAuthMethods}}
 import {{invokerPackage}}.auth.OAuth;
-- 
GitLab


From d98c7ddfef44a28f5967649173383e810123ccca Mon Sep 17 00:00:00 2001
From: Jiri Kuncar <jiri.kuncar@gmail.com>
Date: Tue, 11 Feb 2020 16:51:42 +0100
Subject: [PATCH 07/10] Regenerated

---
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 --
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 --
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 --
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 --
 .../src/main/java/org/openapitools/client/ApiClient.java        | 2 --
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 --
 .../src/main/java/org/openapitools/client/ApiClient.java        | 2 --
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 --
 .../src/main/java/org/openapitools/client/ApiClient.java        | 2 --
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 --
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 --
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 --
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 --
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 --
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 --
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 --
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 --
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 --
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 --
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 --
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 --
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 --
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 --
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 --
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 --
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 --
 26 files changed, 52 deletions(-)

diff --git a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/ServerConfiguration.java
index 43b5a16b308..2bfa47e7c4f 100644
--- a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -2,8 +2,6 @@ package org.openapitools.client;
 
 import java.util.Map;
 
-import com.datadog.api.v1.client.ServerVariable;
-
 /**
  * Representing a Server configuration.
  */
diff --git a/samples/client/petstore/java/feign10x/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/feign10x/src/main/java/org/openapitools/client/ServerConfiguration.java
index 43b5a16b308..2bfa47e7c4f 100644
--- a/samples/client/petstore/java/feign10x/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/feign10x/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -2,8 +2,6 @@ package org.openapitools.client;
 
 import java.util.Map;
 
-import com.datadog.api.v1.client.ServerVariable;
-
 /**
  * Representing a Server configuration.
  */
diff --git a/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/ServerConfiguration.java
index 43b5a16b308..2bfa47e7c4f 100644
--- a/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -2,8 +2,6 @@ package org.openapitools.client;
 
 import java.util.Map;
 
-import com.datadog.api.v1.client.ServerVariable;
-
 /**
  * Representing a Server configuration.
  */
diff --git a/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/ServerConfiguration.java
index 43b5a16b308..2bfa47e7c4f 100644
--- a/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -2,8 +2,6 @@ package org.openapitools.client;
 
 import java.util.Map;
 
-import com.datadog.api.v1.client.ServerVariable;
-
 /**
  * Representing a Server configuration.
  */
diff --git a/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/ApiClient.java
index cdd8994b209..6610d66c395 100644
--- a/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/ApiClient.java
+++ b/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/ApiClient.java
@@ -50,8 +50,6 @@ import org.openapitools.client.auth.Authentication;
 import org.openapitools.client.auth.HttpBasicAuth;
 import org.openapitools.client.auth.HttpBearerAuth;
 import org.openapitools.client.auth.ApiKeyAuth;
-import org.openapitools.client.ServerConfiguration;
-import org.openapitools.client.ServerVariable;
 
 import org.openapitools.client.auth.OAuth;
 
diff --git a/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/ServerConfiguration.java
index 43b5a16b308..2bfa47e7c4f 100644
--- a/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -2,8 +2,6 @@ package org.openapitools.client;
 
 import java.util.Map;
 
-import com.datadog.api.v1.client.ServerVariable;
-
 /**
  * Representing a Server configuration.
  */
diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/ApiClient.java
index 6e29eeddbd7..a5486312eca 100644
--- a/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/ApiClient.java
+++ b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/ApiClient.java
@@ -51,8 +51,6 @@ import org.openapitools.client.auth.Authentication;
 import org.openapitools.client.auth.HttpBasicAuth;
 import org.openapitools.client.auth.HttpBearerAuth;
 import org.openapitools.client.auth.ApiKeyAuth;
-import org.openapitools.client.ServerConfiguration;
-import org.openapitools.client.ServerVariable;
 
 import org.openapitools.client.auth.OAuth;
 
diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/ServerConfiguration.java
index 43b5a16b308..2bfa47e7c4f 100644
--- a/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -2,8 +2,6 @@ package org.openapitools.client;
 
 import java.util.Map;
 
-import com.datadog.api.v1.client.ServerVariable;
-
 /**
  * Representing a Server configuration.
  */
diff --git a/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/ApiClient.java
index 6e29eeddbd7..a5486312eca 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/ApiClient.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/ApiClient.java
@@ -51,8 +51,6 @@ import org.openapitools.client.auth.Authentication;
 import org.openapitools.client.auth.HttpBasicAuth;
 import org.openapitools.client.auth.HttpBearerAuth;
 import org.openapitools.client.auth.ApiKeyAuth;
-import org.openapitools.client.ServerConfiguration;
-import org.openapitools.client.ServerVariable;
 
 import org.openapitools.client.auth.OAuth;
 
diff --git a/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/ServerConfiguration.java
index 43b5a16b308..2bfa47e7c4f 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -2,8 +2,6 @@ package org.openapitools.client;
 
 import java.util.Map;
 
-import com.datadog.api.v1.client.ServerVariable;
-
 /**
  * Representing a Server configuration.
  */
diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/ServerConfiguration.java
index 43b5a16b308..2bfa47e7c4f 100644
--- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -2,8 +2,6 @@ package org.openapitools.client;
 
 import java.util.Map;
 
-import com.datadog.api.v1.client.ServerVariable;
-
 /**
  * Representing a Server configuration.
  */
diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/ServerConfiguration.java
index 43b5a16b308..2bfa47e7c4f 100644
--- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -2,8 +2,6 @@ package org.openapitools.client;
 
 import java.util.Map;
 
-import com.datadog.api.v1.client.ServerVariable;
-
 /**
  * Representing a Server configuration.
  */
diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ServerConfiguration.java
index 43b5a16b308..2bfa47e7c4f 100644
--- a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -2,8 +2,6 @@ package org.openapitools.client;
 
 import java.util.Map;
 
-import com.datadog.api.v1.client.ServerVariable;
-
 /**
  * Representing a Server configuration.
  */
diff --git a/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/ServerConfiguration.java
index 43b5a16b308..2bfa47e7c4f 100644
--- a/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -2,8 +2,6 @@ package org.openapitools.client;
 
 import java.util.Map;
 
-import com.datadog.api.v1.client.ServerVariable;
-
 /**
  * Representing a Server configuration.
  */
diff --git a/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/ServerConfiguration.java
index 43b5a16b308..2bfa47e7c4f 100644
--- a/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -2,8 +2,6 @@ package org.openapitools.client;
 
 import java.util.Map;
 
-import com.datadog.api.v1.client.ServerVariable;
-
 /**
  * Representing a Server configuration.
  */
diff --git a/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/ServerConfiguration.java
index 43b5a16b308..2bfa47e7c4f 100644
--- a/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -2,8 +2,6 @@ package org.openapitools.client;
 
 import java.util.Map;
 
-import com.datadog.api.v1.client.ServerVariable;
-
 /**
  * Representing a Server configuration.
  */
diff --git a/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/ServerConfiguration.java
index 43b5a16b308..2bfa47e7c4f 100644
--- a/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -2,8 +2,6 @@ package org.openapitools.client;
 
 import java.util.Map;
 
-import com.datadog.api.v1.client.ServerVariable;
-
 /**
  * Representing a Server configuration.
  */
diff --git a/samples/client/petstore/java/retrofit/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/retrofit/src/main/java/org/openapitools/client/ServerConfiguration.java
index 43b5a16b308..2bfa47e7c4f 100644
--- a/samples/client/petstore/java/retrofit/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/retrofit/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -2,8 +2,6 @@ package org.openapitools.client;
 
 import java.util.Map;
 
-import com.datadog.api.v1.client.ServerVariable;
-
 /**
  * Representing a Server configuration.
  */
diff --git a/samples/client/petstore/java/retrofit2-play24/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/retrofit2-play24/src/main/java/org/openapitools/client/ServerConfiguration.java
index 43b5a16b308..2bfa47e7c4f 100644
--- a/samples/client/petstore/java/retrofit2-play24/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/retrofit2-play24/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -2,8 +2,6 @@ package org.openapitools.client;
 
 import java.util.Map;
 
-import com.datadog.api.v1.client.ServerVariable;
-
 /**
  * Representing a Server configuration.
  */
diff --git a/samples/client/petstore/java/retrofit2-play25/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/retrofit2-play25/src/main/java/org/openapitools/client/ServerConfiguration.java
index 43b5a16b308..2bfa47e7c4f 100644
--- a/samples/client/petstore/java/retrofit2-play25/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/retrofit2-play25/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -2,8 +2,6 @@ package org.openapitools.client;
 
 import java.util.Map;
 
-import com.datadog.api.v1.client.ServerVariable;
-
 /**
  * Representing a Server configuration.
  */
diff --git a/samples/client/petstore/java/retrofit2-play26/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/retrofit2-play26/src/main/java/org/openapitools/client/ServerConfiguration.java
index 43b5a16b308..2bfa47e7c4f 100644
--- a/samples/client/petstore/java/retrofit2-play26/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/retrofit2-play26/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -2,8 +2,6 @@ package org.openapitools.client;
 
 import java.util.Map;
 
-import com.datadog.api.v1.client.ServerVariable;
-
 /**
  * Representing a Server configuration.
  */
diff --git a/samples/client/petstore/java/retrofit2/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/retrofit2/src/main/java/org/openapitools/client/ServerConfiguration.java
index 43b5a16b308..2bfa47e7c4f 100644
--- a/samples/client/petstore/java/retrofit2/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/retrofit2/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -2,8 +2,6 @@ package org.openapitools.client;
 
 import java.util.Map;
 
-import com.datadog.api.v1.client.ServerVariable;
-
 /**
  * Representing a Server configuration.
  */
diff --git a/samples/client/petstore/java/retrofit2rx/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/retrofit2rx/src/main/java/org/openapitools/client/ServerConfiguration.java
index 43b5a16b308..2bfa47e7c4f 100644
--- a/samples/client/petstore/java/retrofit2rx/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/retrofit2rx/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -2,8 +2,6 @@ package org.openapitools.client;
 
 import java.util.Map;
 
-import com.datadog.api.v1.client.ServerVariable;
-
 /**
  * Representing a Server configuration.
  */
diff --git a/samples/client/petstore/java/retrofit2rx2/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/retrofit2rx2/src/main/java/org/openapitools/client/ServerConfiguration.java
index 43b5a16b308..2bfa47e7c4f 100644
--- a/samples/client/petstore/java/retrofit2rx2/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/retrofit2rx2/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -2,8 +2,6 @@ package org.openapitools.client;
 
 import java.util.Map;
 
-import com.datadog.api.v1.client.ServerVariable;
-
 /**
  * Representing a Server configuration.
  */
diff --git a/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/ServerConfiguration.java
index 43b5a16b308..2bfa47e7c4f 100644
--- a/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -2,8 +2,6 @@ package org.openapitools.client;
 
 import java.util.Map;
 
-import com.datadog.api.v1.client.ServerVariable;
-
 /**
  * Representing a Server configuration.
  */
diff --git a/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/ServerConfiguration.java
index 43b5a16b308..2bfa47e7c4f 100644
--- a/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -2,8 +2,6 @@ package org.openapitools.client;
 
 import java.util.Map;
 
-import com.datadog.api.v1.client.ServerVariable;
-
 /**
  * Representing a Server configuration.
  */
-- 
GitLab


From b0b1cfec3fc448a6f67744c208f18879d10ba5d8 Mon Sep 17 00:00:00 2001
From: Jiri Kuncar <jiri.kuncar@gmail.com>
Date: Wed, 12 Feb 2020 10:21:44 +0100
Subject: [PATCH 08/10] Fix imports and typo in index name

---
 .../src/main/resources/Java/ApiClient.mustache              | 6 ++----
 .../src/main/java/org/openapitools/client/ApiClient.java    | 6 ++----
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/modules/openapi-generator/src/main/resources/Java/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Java/ApiClient.mustache
index fd42a0d2fab..8b71c1551e3 100644
--- a/modules/openapi-generator/src/main/resources/Java/ApiClient.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/ApiClient.mustache
@@ -56,8 +56,6 @@ import {{invokerPackage}}.auth.Authentication;
 import {{invokerPackage}}.auth.HttpBasicAuth;
 import {{invokerPackage}}.auth.HttpBearerAuth;
 import {{invokerPackage}}.auth.ApiKeyAuth;
-import {{invokerPackage}}.ServerConfiguration;
-import {{invokerPackage}}.ServerVariable;
 {{#hasOAuthMethods}}
 import {{invokerPackage}}.auth.OAuth;
 {{/hasOAuthMethods}}
@@ -686,9 +684,9 @@ public class ApiClient {
   private String buildUrl(String path, List<Pair> queryParams, List<Pair> collectionQueryParams) {
     String baseURL;
     if (serverIndex != null) {
-      if (index < 0 || index >= servers.size()) {
+      if (serverIndex < 0 || serverIndex >= servers.size()) {
         throw new ArrayIndexOutOfBoundsException(String.format(
-          "Invalid index %d when selecting the host settings. Must be less than %d", index, servers.size()
+          "Invalid index %d when selecting the host settings. Must be less than %d", serverIndex, servers.size()
         ));
       }
       baseURL = servers.get(serverIndex).URL(serverVariables);
diff --git a/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/ApiClient.java
index 5f55427560d..5707dc8c747 100644
--- a/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/ApiClient.java
+++ b/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/ApiClient.java
@@ -57,8 +57,6 @@ import org.openapitools.client.auth.Authentication;
 import org.openapitools.client.auth.HttpBasicAuth;
 import org.openapitools.client.auth.HttpBearerAuth;
 import org.openapitools.client.auth.ApiKeyAuth;
-import org.openapitools.client.ServerConfiguration;
-import org.openapitools.client.ServerVariable;
 import org.openapitools.client.auth.OAuth;
 
 
@@ -657,9 +655,9 @@ public class ApiClient {
   private String buildUrl(String path, List<Pair> queryParams, List<Pair> collectionQueryParams) {
     String baseURL;
     if (serverIndex != null) {
-      if (index < 0 || index >= servers.size()) {
+      if (serverIndex < 0 || serverIndex >= servers.size()) {
         throw new ArrayIndexOutOfBoundsException(String.format(
-          "Invalid index %d when selecting the host settings. Must be less than %d", index, servers.size()
+          "Invalid index %d when selecting the host settings. Must be less than %d", serverIndex, servers.size()
         ));
       }
       baseURL = servers.get(serverIndex).URL(serverVariables);
-- 
GitLab


From e299f8da88b080b98788260d6b4cf08a1fa2cebb Mon Sep 17 00:00:00 2001
From: Jiri Kuncar <jiri.kuncar@gmail.com>
Date: Wed, 12 Feb 2020 10:56:32 +0100
Subject: [PATCH 09/10] Fix javadoc

---
 .../src/main/resources/Java/ServerConfiguration.mustache        | 2 +-
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/modules/openapi-generator/src/main/resources/Java/ServerConfiguration.mustache b/modules/openapi-generator/src/main/resources/Java/ServerConfiguration.mustache
index 8c9bd14e982..f976c542b19 100644
--- a/modules/openapi-generator/src/main/resources/Java/ServerConfiguration.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/ServerConfiguration.mustache
@@ -11,7 +11,7 @@ public class ServerConfiguration {
     public Map<String, ServerVariable> variables;
 
     /**
-     * @param A URL to the target host.
+     * @param URL A URL to the target host.
      * @param description A describtion of the host designated by the URL.
      * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
      */
diff --git a/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/ServerConfiguration.java
index 2bfa47e7c4f..a1107a8690e 100644
--- a/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/jersey1/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -11,7 +11,7 @@ public class ServerConfiguration {
     public Map<String, ServerVariable> variables;
 
     /**
-     * @param A URL to the target host.
+     * @param URL A URL to the target host.
      * @param description A describtion of the host designated by the URL.
      * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
      */
-- 
GitLab


From 63a26c8d547f095864093785190f32c0bf84b022 Mon Sep 17 00:00:00 2001
From: Jim Schubert <james.schubert@gmail.com>
Date: Sun, 16 Feb 2020 11:16:47 -0500
Subject: [PATCH 10/10] [java] Regenerate samples

---
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 +-
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 +-
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 +-
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 +-
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 +-
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 +-
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 +-
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 +-
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 +-
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 +-
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 +-
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 +-
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 +-
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 +-
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 +-
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 +-
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 +-
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 +-
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 +-
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 +-
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 +-
 .../main/java/org/openapitools/client/ServerConfiguration.java  | 2 +-
 22 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/ServerConfiguration.java
index 2bfa47e7c4f..a1107a8690e 100644
--- a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -11,7 +11,7 @@ public class ServerConfiguration {
     public Map<String, ServerVariable> variables;
 
     /**
-     * @param A URL to the target host.
+     * @param URL A URL to the target host.
      * @param description A describtion of the host designated by the URL.
      * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
      */
diff --git a/samples/client/petstore/java/feign10x/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/feign10x/src/main/java/org/openapitools/client/ServerConfiguration.java
index 2bfa47e7c4f..a1107a8690e 100644
--- a/samples/client/petstore/java/feign10x/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/feign10x/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -11,7 +11,7 @@ public class ServerConfiguration {
     public Map<String, ServerVariable> variables;
 
     /**
-     * @param A URL to the target host.
+     * @param URL A URL to the target host.
      * @param description A describtion of the host designated by the URL.
      * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
      */
diff --git a/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/ServerConfiguration.java
index 2bfa47e7c4f..a1107a8690e 100644
--- a/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -11,7 +11,7 @@ public class ServerConfiguration {
     public Map<String, ServerVariable> variables;
 
     /**
-     * @param A URL to the target host.
+     * @param URL A URL to the target host.
      * @param description A describtion of the host designated by the URL.
      * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
      */
diff --git a/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/ServerConfiguration.java
index 2bfa47e7c4f..a1107a8690e 100644
--- a/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/jersey2-java6/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -11,7 +11,7 @@ public class ServerConfiguration {
     public Map<String, ServerVariable> variables;
 
     /**
-     * @param A URL to the target host.
+     * @param URL A URL to the target host.
      * @param description A describtion of the host designated by the URL.
      * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
      */
diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/ServerConfiguration.java
index 2bfa47e7c4f..a1107a8690e 100644
--- a/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -11,7 +11,7 @@ public class ServerConfiguration {
     public Map<String, ServerVariable> variables;
 
     /**
-     * @param A URL to the target host.
+     * @param URL A URL to the target host.
      * @param description A describtion of the host designated by the URL.
      * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
      */
diff --git a/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/ServerConfiguration.java
index 2bfa47e7c4f..a1107a8690e 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -11,7 +11,7 @@ public class ServerConfiguration {
     public Map<String, ServerVariable> variables;
 
     /**
-     * @param A URL to the target host.
+     * @param URL A URL to the target host.
      * @param description A describtion of the host designated by the URL.
      * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
      */
diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/ServerConfiguration.java
index 2bfa47e7c4f..a1107a8690e 100644
--- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -11,7 +11,7 @@ public class ServerConfiguration {
     public Map<String, ServerVariable> variables;
 
     /**
-     * @param A URL to the target host.
+     * @param URL A URL to the target host.
      * @param description A describtion of the host designated by the URL.
      * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
      */
diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/ServerConfiguration.java
index 2bfa47e7c4f..a1107a8690e 100644
--- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -11,7 +11,7 @@ public class ServerConfiguration {
     public Map<String, ServerVariable> variables;
 
     /**
-     * @param A URL to the target host.
+     * @param URL A URL to the target host.
      * @param description A describtion of the host designated by the URL.
      * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
      */
diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ServerConfiguration.java
index 2bfa47e7c4f..a1107a8690e 100644
--- a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -11,7 +11,7 @@ public class ServerConfiguration {
     public Map<String, ServerVariable> variables;
 
     /**
-     * @param A URL to the target host.
+     * @param URL A URL to the target host.
      * @param description A describtion of the host designated by the URL.
      * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
      */
diff --git a/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/ServerConfiguration.java
index 2bfa47e7c4f..a1107a8690e 100644
--- a/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -11,7 +11,7 @@ public class ServerConfiguration {
     public Map<String, ServerVariable> variables;
 
     /**
-     * @param A URL to the target host.
+     * @param URL A URL to the target host.
      * @param description A describtion of the host designated by the URL.
      * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
      */
diff --git a/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/ServerConfiguration.java
index 2bfa47e7c4f..a1107a8690e 100644
--- a/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -11,7 +11,7 @@ public class ServerConfiguration {
     public Map<String, ServerVariable> variables;
 
     /**
-     * @param A URL to the target host.
+     * @param URL A URL to the target host.
      * @param description A describtion of the host designated by the URL.
      * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
      */
diff --git a/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/ServerConfiguration.java
index 2bfa47e7c4f..a1107a8690e 100644
--- a/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -11,7 +11,7 @@ public class ServerConfiguration {
     public Map<String, ServerVariable> variables;
 
     /**
-     * @param A URL to the target host.
+     * @param URL A URL to the target host.
      * @param description A describtion of the host designated by the URL.
      * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
      */
diff --git a/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/ServerConfiguration.java
index 2bfa47e7c4f..a1107a8690e 100644
--- a/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -11,7 +11,7 @@ public class ServerConfiguration {
     public Map<String, ServerVariable> variables;
 
     /**
-     * @param A URL to the target host.
+     * @param URL A URL to the target host.
      * @param description A describtion of the host designated by the URL.
      * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
      */
diff --git a/samples/client/petstore/java/retrofit/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/retrofit/src/main/java/org/openapitools/client/ServerConfiguration.java
index 2bfa47e7c4f..a1107a8690e 100644
--- a/samples/client/petstore/java/retrofit/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/retrofit/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -11,7 +11,7 @@ public class ServerConfiguration {
     public Map<String, ServerVariable> variables;
 
     /**
-     * @param A URL to the target host.
+     * @param URL A URL to the target host.
      * @param description A describtion of the host designated by the URL.
      * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
      */
diff --git a/samples/client/petstore/java/retrofit2-play24/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/retrofit2-play24/src/main/java/org/openapitools/client/ServerConfiguration.java
index 2bfa47e7c4f..a1107a8690e 100644
--- a/samples/client/petstore/java/retrofit2-play24/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/retrofit2-play24/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -11,7 +11,7 @@ public class ServerConfiguration {
     public Map<String, ServerVariable> variables;
 
     /**
-     * @param A URL to the target host.
+     * @param URL A URL to the target host.
      * @param description A describtion of the host designated by the URL.
      * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
      */
diff --git a/samples/client/petstore/java/retrofit2-play25/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/retrofit2-play25/src/main/java/org/openapitools/client/ServerConfiguration.java
index 2bfa47e7c4f..a1107a8690e 100644
--- a/samples/client/petstore/java/retrofit2-play25/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/retrofit2-play25/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -11,7 +11,7 @@ public class ServerConfiguration {
     public Map<String, ServerVariable> variables;
 
     /**
-     * @param A URL to the target host.
+     * @param URL A URL to the target host.
      * @param description A describtion of the host designated by the URL.
      * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
      */
diff --git a/samples/client/petstore/java/retrofit2-play26/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/retrofit2-play26/src/main/java/org/openapitools/client/ServerConfiguration.java
index 2bfa47e7c4f..a1107a8690e 100644
--- a/samples/client/petstore/java/retrofit2-play26/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/retrofit2-play26/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -11,7 +11,7 @@ public class ServerConfiguration {
     public Map<String, ServerVariable> variables;
 
     /**
-     * @param A URL to the target host.
+     * @param URL A URL to the target host.
      * @param description A describtion of the host designated by the URL.
      * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
      */
diff --git a/samples/client/petstore/java/retrofit2/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/retrofit2/src/main/java/org/openapitools/client/ServerConfiguration.java
index 2bfa47e7c4f..a1107a8690e 100644
--- a/samples/client/petstore/java/retrofit2/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/retrofit2/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -11,7 +11,7 @@ public class ServerConfiguration {
     public Map<String, ServerVariable> variables;
 
     /**
-     * @param A URL to the target host.
+     * @param URL A URL to the target host.
      * @param description A describtion of the host designated by the URL.
      * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
      */
diff --git a/samples/client/petstore/java/retrofit2rx/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/retrofit2rx/src/main/java/org/openapitools/client/ServerConfiguration.java
index 2bfa47e7c4f..a1107a8690e 100644
--- a/samples/client/petstore/java/retrofit2rx/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/retrofit2rx/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -11,7 +11,7 @@ public class ServerConfiguration {
     public Map<String, ServerVariable> variables;
 
     /**
-     * @param A URL to the target host.
+     * @param URL A URL to the target host.
      * @param description A describtion of the host designated by the URL.
      * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
      */
diff --git a/samples/client/petstore/java/retrofit2rx2/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/retrofit2rx2/src/main/java/org/openapitools/client/ServerConfiguration.java
index 2bfa47e7c4f..a1107a8690e 100644
--- a/samples/client/petstore/java/retrofit2rx2/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/retrofit2rx2/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -11,7 +11,7 @@ public class ServerConfiguration {
     public Map<String, ServerVariable> variables;
 
     /**
-     * @param A URL to the target host.
+     * @param URL A URL to the target host.
      * @param description A describtion of the host designated by the URL.
      * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
      */
diff --git a/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/ServerConfiguration.java
index 2bfa47e7c4f..a1107a8690e 100644
--- a/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -11,7 +11,7 @@ public class ServerConfiguration {
     public Map<String, ServerVariable> variables;
 
     /**
-     * @param A URL to the target host.
+     * @param URL A URL to the target host.
      * @param description A describtion of the host designated by the URL.
      * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
      */
diff --git a/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/ServerConfiguration.java
index 2bfa47e7c4f..a1107a8690e 100644
--- a/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/ServerConfiguration.java
+++ b/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -11,7 +11,7 @@ public class ServerConfiguration {
     public Map<String, ServerVariable> variables;
 
     /**
-     * @param A URL to the target host.
+     * @param URL A URL to the target host.
      * @param description A describtion of the host designated by the URL.
      * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
      */
-- 
GitLab