mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-02 21:50:55 +00:00
[Java][Client] Generate servers for okhttp-gson (#14179)
* [Java][Client] Generate servers for okhttp-gson * Update sample tests
This commit is contained in:
parent
344c49dd51
commit
9450984af8
@ -72,6 +72,33 @@ import {{invokerPackage}}.auth.OAuthFlow;
|
|||||||
public class ApiClient {
|
public class ApiClient {
|
||||||
|
|
||||||
private String basePath = "{{{basePath}}}";
|
private String basePath = "{{{basePath}}}";
|
||||||
|
protected List<ServerConfiguration> servers = new ArrayList<ServerConfiguration>({{#servers}}{{#-first}}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}});
|
||||||
|
protected Integer serverIndex = 0;
|
||||||
|
protected Map<String, String> serverVariables = null;
|
||||||
private boolean debugging = false;
|
private boolean debugging = false;
|
||||||
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
|
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
|
||||||
private Map<String, String> defaultCookieMap = new HashMap<String, String>();
|
private Map<String, String> defaultCookieMap = new HashMap<String, String>();
|
||||||
@ -261,6 +288,33 @@ public class ApiClient {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<ServerConfiguration> getServers() {
|
||||||
|
return servers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApiClient setServers(List<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 HTTP client
|
* Get HTTP client
|
||||||
*
|
*
|
||||||
@ -1399,7 +1453,18 @@ public class ApiClient {
|
|||||||
if (baseUrl != null) {
|
if (baseUrl != null) {
|
||||||
url.append(baseUrl).append(path);
|
url.append(baseUrl).append(path);
|
||||||
} else {
|
} else {
|
||||||
url.append(basePath).append(path);
|
String baseURL;
|
||||||
|
if (serverIndex != null) {
|
||||||
|
if (serverIndex < 0 || serverIndex >= servers.size()) {
|
||||||
|
throw new ArrayIndexOutOfBoundsException(String.format(
|
||||||
|
"Invalid index %d when selecting the host settings. Must be less than %d", serverIndex, servers.size()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
baseURL = servers.get(serverIndex).URL(serverVariables);
|
||||||
|
} else {
|
||||||
|
baseURL = basePath;
|
||||||
|
}
|
||||||
|
url.append(baseURL).append(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (queryParams != null && !queryParams.isEmpty()) {
|
if (queryParams != null && !queryParams.isEmpty()) {
|
||||||
|
@ -61,6 +61,15 @@ import org.openapitools.client.auth.ApiKeyAuth;
|
|||||||
public class ApiClient {
|
public class ApiClient {
|
||||||
|
|
||||||
private String basePath = "http://localhost:8082";
|
private String basePath = "http://localhost:8082";
|
||||||
|
protected List<ServerConfiguration> servers = new ArrayList<ServerConfiguration>(Arrays.asList(
|
||||||
|
new ServerConfiguration(
|
||||||
|
"http://localhost:8082",
|
||||||
|
"No description provided",
|
||||||
|
new HashMap<String, ServerVariable>()
|
||||||
|
)
|
||||||
|
));
|
||||||
|
protected Integer serverIndex = 0;
|
||||||
|
protected Map<String, String> serverVariables = null;
|
||||||
private boolean debugging = false;
|
private boolean debugging = false;
|
||||||
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
|
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
|
||||||
private Map<String, String> defaultCookieMap = new HashMap<String, String>();
|
private Map<String, String> defaultCookieMap = new HashMap<String, String>();
|
||||||
@ -154,6 +163,33 @@ public class ApiClient {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<ServerConfiguration> getServers() {
|
||||||
|
return servers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApiClient setServers(List<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 HTTP client
|
* Get HTTP client
|
||||||
*
|
*
|
||||||
@ -1196,7 +1232,18 @@ public class ApiClient {
|
|||||||
if (baseUrl != null) {
|
if (baseUrl != null) {
|
||||||
url.append(baseUrl).append(path);
|
url.append(baseUrl).append(path);
|
||||||
} else {
|
} else {
|
||||||
url.append(basePath).append(path);
|
String baseURL;
|
||||||
|
if (serverIndex != null) {
|
||||||
|
if (serverIndex < 0 || serverIndex >= servers.size()) {
|
||||||
|
throw new ArrayIndexOutOfBoundsException(String.format(
|
||||||
|
"Invalid index %d when selecting the host settings. Must be less than %d", serverIndex, servers.size()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
baseURL = servers.get(serverIndex).URL(serverVariables);
|
||||||
|
} else {
|
||||||
|
baseURL = basePath;
|
||||||
|
}
|
||||||
|
url.append(baseURL).append(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (queryParams != null && !queryParams.isEmpty()) {
|
if (queryParams != null && !queryParams.isEmpty()) {
|
||||||
|
@ -72,6 +72,15 @@ import org.openapitools.client.auth.OAuthFlow;
|
|||||||
public class ApiClient {
|
public class ApiClient {
|
||||||
|
|
||||||
private String basePath = "http://petstore.swagger.io:80/v2";
|
private String basePath = "http://petstore.swagger.io:80/v2";
|
||||||
|
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;
|
private boolean debugging = false;
|
||||||
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
|
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
|
||||||
private Map<String, String> defaultCookieMap = new HashMap<String, String>();
|
private Map<String, String> defaultCookieMap = new HashMap<String, String>();
|
||||||
@ -247,6 +256,33 @@ public class ApiClient {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<ServerConfiguration> getServers() {
|
||||||
|
return servers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApiClient setServers(List<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 HTTP client
|
* Get HTTP client
|
||||||
*
|
*
|
||||||
@ -1274,7 +1310,18 @@ public class ApiClient {
|
|||||||
if (baseUrl != null) {
|
if (baseUrl != null) {
|
||||||
url.append(baseUrl).append(path);
|
url.append(baseUrl).append(path);
|
||||||
} else {
|
} else {
|
||||||
url.append(basePath).append(path);
|
String baseURL;
|
||||||
|
if (serverIndex != null) {
|
||||||
|
if (serverIndex < 0 || serverIndex >= servers.size()) {
|
||||||
|
throw new ArrayIndexOutOfBoundsException(String.format(
|
||||||
|
"Invalid index %d when selecting the host settings. Must be less than %d", serverIndex, servers.size()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
baseURL = servers.get(serverIndex).URL(serverVariables);
|
||||||
|
} else {
|
||||||
|
baseURL = basePath;
|
||||||
|
}
|
||||||
|
url.append(baseURL).append(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (queryParams != null && !queryParams.isEmpty()) {
|
if (queryParams != null && !queryParams.isEmpty()) {
|
||||||
|
@ -66,6 +66,15 @@ import org.openapitools.client.auth.OAuthFlow;
|
|||||||
public class ApiClient {
|
public class ApiClient {
|
||||||
|
|
||||||
private String basePath = "http://petstore.swagger.io/v2";
|
private String basePath = "http://petstore.swagger.io/v2";
|
||||||
|
protected List<ServerConfiguration> servers = new ArrayList<ServerConfiguration>(Arrays.asList(
|
||||||
|
new ServerConfiguration(
|
||||||
|
"http://petstore.swagger.io/v2",
|
||||||
|
"No description provided",
|
||||||
|
new HashMap<String, ServerVariable>()
|
||||||
|
)
|
||||||
|
));
|
||||||
|
protected Integer serverIndex = 0;
|
||||||
|
protected Map<String, String> serverVariables = null;
|
||||||
private boolean debugging = false;
|
private boolean debugging = false;
|
||||||
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
|
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
|
||||||
private Map<String, String> defaultCookieMap = new HashMap<String, String>();
|
private Map<String, String> defaultCookieMap = new HashMap<String, String>();
|
||||||
@ -230,6 +239,33 @@ public class ApiClient {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<ServerConfiguration> getServers() {
|
||||||
|
return servers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApiClient setServers(List<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 HTTP client
|
* Get HTTP client
|
||||||
*
|
*
|
||||||
@ -1269,7 +1305,18 @@ public class ApiClient {
|
|||||||
if (baseUrl != null) {
|
if (baseUrl != null) {
|
||||||
url.append(baseUrl).append(path);
|
url.append(baseUrl).append(path);
|
||||||
} else {
|
} else {
|
||||||
url.append(basePath).append(path);
|
String baseURL;
|
||||||
|
if (serverIndex != null) {
|
||||||
|
if (serverIndex < 0 || serverIndex >= servers.size()) {
|
||||||
|
throw new ArrayIndexOutOfBoundsException(String.format(
|
||||||
|
"Invalid index %d when selecting the host settings. Must be less than %d", serverIndex, servers.size()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
baseURL = servers.get(serverIndex).URL(serverVariables);
|
||||||
|
} else {
|
||||||
|
baseURL = basePath;
|
||||||
|
}
|
||||||
|
url.append(baseURL).append(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (queryParams != null && !queryParams.isEmpty()) {
|
if (queryParams != null && !queryParams.isEmpty()) {
|
||||||
|
@ -66,6 +66,15 @@ import org.openapitools.client.auth.OAuthFlow;
|
|||||||
public class ApiClient {
|
public class ApiClient {
|
||||||
|
|
||||||
private String basePath = "http://petstore.swagger.io:80/v2";
|
private String basePath = "http://petstore.swagger.io:80/v2";
|
||||||
|
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;
|
private boolean debugging = false;
|
||||||
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
|
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
|
||||||
private Map<String, String> defaultCookieMap = new HashMap<String, String>();
|
private Map<String, String> defaultCookieMap = new HashMap<String, String>();
|
||||||
@ -236,6 +245,33 @@ public class ApiClient {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<ServerConfiguration> getServers() {
|
||||||
|
return servers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApiClient setServers(List<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 HTTP client
|
* Get HTTP client
|
||||||
*
|
*
|
||||||
@ -1275,7 +1311,18 @@ public class ApiClient {
|
|||||||
if (baseUrl != null) {
|
if (baseUrl != null) {
|
||||||
url.append(baseUrl).append(path);
|
url.append(baseUrl).append(path);
|
||||||
} else {
|
} else {
|
||||||
url.append(basePath).append(path);
|
String baseURL;
|
||||||
|
if (serverIndex != null) {
|
||||||
|
if (serverIndex < 0 || serverIndex >= servers.size()) {
|
||||||
|
throw new ArrayIndexOutOfBoundsException(String.format(
|
||||||
|
"Invalid index %d when selecting the host settings. Must be less than %d", serverIndex, servers.size()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
baseURL = servers.get(serverIndex).URL(serverVariables);
|
||||||
|
} else {
|
||||||
|
baseURL = basePath;
|
||||||
|
}
|
||||||
|
url.append(baseURL).append(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (queryParams != null && !queryParams.isEmpty()) {
|
if (queryParams != null && !queryParams.isEmpty()) {
|
||||||
|
@ -66,6 +66,15 @@ import org.openapitools.client.auth.OAuthFlow;
|
|||||||
public class ApiClient {
|
public class ApiClient {
|
||||||
|
|
||||||
private String basePath = "http://petstore.swagger.io/v2";
|
private String basePath = "http://petstore.swagger.io/v2";
|
||||||
|
protected List<ServerConfiguration> servers = new ArrayList<ServerConfiguration>(Arrays.asList(
|
||||||
|
new ServerConfiguration(
|
||||||
|
"http://petstore.swagger.io/v2",
|
||||||
|
"No description provided",
|
||||||
|
new HashMap<String, ServerVariable>()
|
||||||
|
)
|
||||||
|
));
|
||||||
|
protected Integer serverIndex = 0;
|
||||||
|
protected Map<String, String> serverVariables = null;
|
||||||
private boolean debugging = false;
|
private boolean debugging = false;
|
||||||
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
|
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
|
||||||
private Map<String, String> defaultCookieMap = new HashMap<String, String>();
|
private Map<String, String> defaultCookieMap = new HashMap<String, String>();
|
||||||
@ -230,6 +239,33 @@ public class ApiClient {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<ServerConfiguration> getServers() {
|
||||||
|
return servers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApiClient setServers(List<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 HTTP client
|
* Get HTTP client
|
||||||
*
|
*
|
||||||
@ -1269,7 +1305,18 @@ public class ApiClient {
|
|||||||
if (baseUrl != null) {
|
if (baseUrl != null) {
|
||||||
url.append(baseUrl).append(path);
|
url.append(baseUrl).append(path);
|
||||||
} else {
|
} else {
|
||||||
url.append(basePath).append(path);
|
String baseURL;
|
||||||
|
if (serverIndex != null) {
|
||||||
|
if (serverIndex < 0 || serverIndex >= servers.size()) {
|
||||||
|
throw new ArrayIndexOutOfBoundsException(String.format(
|
||||||
|
"Invalid index %d when selecting the host settings. Must be less than %d", serverIndex, servers.size()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
baseURL = servers.get(serverIndex).URL(serverVariables);
|
||||||
|
} else {
|
||||||
|
baseURL = basePath;
|
||||||
|
}
|
||||||
|
url.append(baseURL).append(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (queryParams != null && !queryParams.isEmpty()) {
|
if (queryParams != null && !queryParams.isEmpty()) {
|
||||||
|
@ -66,6 +66,58 @@ import org.openapitools.client.auth.OAuthFlow;
|
|||||||
public class ApiClient {
|
public class ApiClient {
|
||||||
|
|
||||||
private String basePath = "http://petstore.swagger.io:80/v2";
|
private String basePath = "http://petstore.swagger.io:80/v2";
|
||||||
|
protected List<ServerConfiguration> servers = new ArrayList<ServerConfiguration>(Arrays.asList(
|
||||||
|
new ServerConfiguration(
|
||||||
|
"http://{server}.swagger.io:{port}/v2",
|
||||||
|
"petstore server",
|
||||||
|
new HashMap<String, ServerVariable>() {{
|
||||||
|
put("server", new ServerVariable(
|
||||||
|
"No description provided",
|
||||||
|
"petstore",
|
||||||
|
new HashSet<String>(
|
||||||
|
Arrays.asList(
|
||||||
|
"petstore",
|
||||||
|
"qa-petstore",
|
||||||
|
"dev-petstore"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
));
|
||||||
|
put("port", new ServerVariable(
|
||||||
|
"No description provided",
|
||||||
|
"80",
|
||||||
|
new HashSet<String>(
|
||||||
|
Arrays.asList(
|
||||||
|
"80",
|
||||||
|
"8080"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
));
|
||||||
|
}}
|
||||||
|
),
|
||||||
|
new ServerConfiguration(
|
||||||
|
"https://localhost:8080/{version}",
|
||||||
|
"The local server",
|
||||||
|
new HashMap<String, ServerVariable>() {{
|
||||||
|
put("version", new ServerVariable(
|
||||||
|
"No description provided",
|
||||||
|
"v2",
|
||||||
|
new HashSet<String>(
|
||||||
|
Arrays.asList(
|
||||||
|
"v1",
|
||||||
|
"v2"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
));
|
||||||
|
}}
|
||||||
|
),
|
||||||
|
new ServerConfiguration(
|
||||||
|
"https://127.0.0.1/no_variable",
|
||||||
|
"The local server without variables",
|
||||||
|
new HashMap<String, ServerVariable>()
|
||||||
|
)
|
||||||
|
));
|
||||||
|
protected Integer serverIndex = 0;
|
||||||
|
protected Map<String, String> serverVariables = null;
|
||||||
private boolean debugging = false;
|
private boolean debugging = false;
|
||||||
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
|
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
|
||||||
private Map<String, String> defaultCookieMap = new HashMap<String, String>();
|
private Map<String, String> defaultCookieMap = new HashMap<String, String>();
|
||||||
@ -242,6 +294,33 @@ public class ApiClient {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<ServerConfiguration> getServers() {
|
||||||
|
return servers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApiClient setServers(List<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 HTTP client
|
* Get HTTP client
|
||||||
*
|
*
|
||||||
@ -1294,7 +1373,18 @@ public class ApiClient {
|
|||||||
if (baseUrl != null) {
|
if (baseUrl != null) {
|
||||||
url.append(baseUrl).append(path);
|
url.append(baseUrl).append(path);
|
||||||
} else {
|
} else {
|
||||||
url.append(basePath).append(path);
|
String baseURL;
|
||||||
|
if (serverIndex != null) {
|
||||||
|
if (serverIndex < 0 || serverIndex >= servers.size()) {
|
||||||
|
throw new ArrayIndexOutOfBoundsException(String.format(
|
||||||
|
"Invalid index %d when selecting the host settings. Must be less than %d", serverIndex, servers.size()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
baseURL = servers.get(serverIndex).URL(serverVariables);
|
||||||
|
} else {
|
||||||
|
baseURL = basePath;
|
||||||
|
}
|
||||||
|
url.append(baseURL).append(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (queryParams != null && !queryParams.isEmpty()) {
|
if (queryParams != null && !queryParams.isEmpty()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user