Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions sdks/java-v1/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ repositories {
mavenCentral()
}

ext {
jackson_version = "2.21.6"
jackson_annotations_version = "2.21"
jackson_databind_version = "2.21.6"
jakarta_annotation_version = "1.3.5"
jersey_version = "2.35"
junit_version = "5.8.2"
mockito_version = "3.12.4"
}

tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
}
Expand Down Expand Up @@ -57,18 +67,7 @@ artifacts {
archives javadocJar, sourcesJar, fatJar
}

ext {
swagger_annotations_version = "1.6.5"
jackson_version = "2.17.1"
jackson_databind_version = "2.17.1"
jakarta_annotation_version = "1.3.5"
jersey_version = "2.35"
junit_version = "5.8.2"
mockito_version = "3.12.4"
}

dependencies {
implementation "io.swagger:swagger-annotations:$swagger_annotations_version"
implementation 'commons-codec:commons-codec:1.15'
implementation "com.google.code.findbugs:jsr305:3.0.2"
implementation "org.glassfish.jersey.core:jersey-client:$jersey_version"
Expand All @@ -77,7 +76,7 @@ dependencies {
implementation "org.glassfish.jersey.media:jersey-media-json-jackson:$jersey_version"
implementation "org.glassfish.jersey.connectors:jersey-apache-connector:$jersey_version"
implementation "com.fasterxml.jackson.core:jackson-core:$jackson_version"
implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_annotations_version"
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
Expand Down
10 changes: 5 additions & 5 deletions sdks/java-v1/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ lazy val root = (project in file(".")).
organization := "com.dropbox.sign",
name := "dropbox-sign",
version := "1.11-dev",
scalaVersion := "2.11.4",
scalaVersion := "2.11.12",
scalacOptions ++= Seq("-feature"),
Compile / javacOptions ++= Seq("-Xlint:deprecation"),
Compile / packageDoc / publishArtifact := false,
Expand All @@ -17,10 +17,10 @@ lazy val root = (project in file(".")).
"org.glassfish.jersey.media" % "jersey-media-multipart" % "2.35",
"org.glassfish.jersey.media" % "jersey-media-json-jackson" % "2.35",
"org.glassfish.jersey.connectors" % "jersey-apache-connector" % "2.35",
"com.fasterxml.jackson.core" % "jackson-core" % "2.17.1" % "compile",
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.17.1" % "compile",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.17.1" % "compile",
"com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.17.1" % "compile",
"com.fasterxml.jackson.core" % "jackson-core" % "2.21.6" % "compile",
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.21" % "compile",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.21.6" % "compile",
"com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.21.6" % "compile",
"jakarta.annotation" % "jakarta.annotation-api" % "1.3.5" % "compile",
"org.junit.jupiter" % "junit-jupiter-api" % "5.8.2" % "test"
)
Expand Down
2 changes: 1 addition & 1 deletion sdks/java-v1/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
11 changes: 6 additions & 5 deletions sdks/java-v1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson-version}</version>
<version>${jackson-annotations-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
Expand Down Expand Up @@ -352,12 +352,13 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jersey-version>2.37</jersey-version>
<jackson-version>2.17.1</jackson-version>
<jackson-databind-version>2.17.1</jackson-databind-version>
<jackson-databind-nullable-version>0.2.6</jackson-databind-nullable-version>
<jackson-version>2.21.6</jackson-version>
<jackson-annotations-version>2.21</jackson-annotations-version>
<jackson-databind-version>2.21.6</jackson-databind-version>
<jackson-databind-nullable-version>0.2.12</jackson-databind-nullable-version>
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>
<beanvalidation-version>2.0.2</beanvalidation-version>
<junit-version>5.10.0</junit-version>
<junit-version>5.14.4</junit-version>
<spotless.version>2.21.0</spotless.version>
<mockito.version>3.12.4</mockito.version>
</properties>
Expand Down
4 changes: 2 additions & 2 deletions sdks/java-v1/run-build
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

# see https://github.com/OpenAPITools/openapi-generator/tree/v7.8.0/modules/openapi-generator/src/main/resources/Java
# see https://github.com/OpenAPITools/openapi-generator/tree/v7.26.0/modules/openapi-generator/src/main/resources/Java

set -e

Expand All @@ -18,7 +18,7 @@ rm -f "${DIR}/src/main/java/com/dropbox/sign/model/"*.java

docker run --rm \
-v "${DIR}/:/local" \
openapitools/openapi-generator-cli:v7.12.0 generate \
openapitools/openapi-generator-cli:v7.26.0 generate \
-i "/local/openapi-sdk.yaml" \
-c "/local/openapi-config.yaml" \
-t "/local/templates" \
Expand Down
99 changes: 71 additions & 28 deletions sdks/java-v1/src/main/java/com/dropbox/sign/ApiClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,16 @@
/** ApiClient class. */
@javax.annotation.Generated(
value = "org.openapitools.codegen.languages.JavaClientCodegen",
comments = "Generator version: 7.12.0")
comments = "Generator version: 7.26.0")
public class ApiClient extends JavaTimeFormatter {
private static final Pattern JSON_MIME_PATTERN =
protected static final Pattern JSON_MIME_PATTERN =
Pattern.compile("(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$");

protected Map<String, String> defaultHeaderMap = new HashMap<>();
protected Map<String, String> defaultCookieMap = new HashMap<>();
protected String basePath = "https://api.hellosign.com/v3";
protected String userAgent;
private static final Logger log = Logger.getLogger(ApiClient.class.getName());
protected static final Logger log = Logger.getLogger(ApiClient.class.getName());

protected List<ServerConfiguration> servers =
new ArrayList<>(
Expand Down Expand Up @@ -119,7 +119,7 @@ public class ApiClient extends JavaTimeFormatter {
protected boolean debugging = false;
protected ClientConfig clientConfig;
protected int connectionTimeout = 0;
private int readTimeout = 0;
protected int readTimeout = 0;

protected Client httpClient;
protected JSON json;
Expand Down Expand Up @@ -287,7 +287,7 @@ public ApiClient setServerVariables(Map<String, String> serverVariables) {
return this;
}

private void updateBasePath() {
protected void updateBasePath() {
if (serverIndex != null) {
setBasePath(servers.get(serverIndex).URL(serverVariables));
}
Expand Down Expand Up @@ -463,6 +463,7 @@ public boolean isDebugging() {
*/
public ApiClient setDebugging(boolean debugging) {
this.debugging = debugging;
applyDebugSetting(this.clientConfig);
// Rebuild HTTP Client according to the new "debugging" value.
this.httpClient = buildHttpClient();
return this;
Expand Down Expand Up @@ -734,6 +735,41 @@ public String escapeString(String str) {
}
}

/**
* Format the given collection as a path parameter value according to the collection format.
* Each item is escaped individually, so that the delimiter is preserved (e.g. "a,b,c" for csv).
*
* @param collectionFormat Collection format (csv by default)
* @param value Collection value
* @return Escaped path parameter value
*/
public String collectionPathParameterToString(String collectionFormat, Collection<?> value) {
if (value == null || value.isEmpty()) {
return "";
}

// "multi" is not valid for path params, fall back to csv
String delimiter = ",";
if ("ssv".equals(collectionFormat)) {
delimiter = escapeString(" ");
} else if ("tsv".equals(collectionFormat)) {
delimiter = escapeString("\t");
} else if ("pipes".equals(collectionFormat)) {
delimiter = escapeString("|");
}

StringBuilder sb = new StringBuilder();
boolean first = true;
for (Object item : value) {
if (!first) {
sb.append(delimiter);
}
sb.append(escapeString(parameterToString(item)));
first = false;
}
return sb.toString();
}

/**
* Serialize the given Java object into string entity according the given Content-Type (only
* JSON is supported for now).
Expand Down Expand Up @@ -814,7 +850,7 @@ public Entity<?> serialize(
* @param key Key of the object
* @param multiPart MultiPart to add the form param to
*/
private void addParamToMultipart(Object value, String key, MultiPart multiPart) {
protected void addParamToMultipart(Object value, String key, MultiPart multiPart) {
if (value instanceof File) {
File file = (File) value;
FormDataContentDisposition contentDisp =
Expand Down Expand Up @@ -1021,9 +1057,11 @@ public <T> ApiResponse<T> invokeAPI(
if (index < 0 || index >= serverConfigurations.size()) {
throw new ArrayIndexOutOfBoundsException(
String.format(
java.util.Locale.ROOT,
"Invalid index %d when selecting the host settings. Must be less"
+ " than %d",
index, serverConfigurations.size()));
index,
serverConfigurations.size()));
}
targetURL = serverConfigurations.get(index).URL(variables) + path;
} else {
Expand All @@ -1033,6 +1071,22 @@ public <T> ApiResponse<T> invokeAPI(
// to support (constant) query string in `path`, e.g. "/posts?draft=1"
WebTarget target = httpClient.target(targetURL);

// put all headers in one place
Map<String, String> allHeaderParams = new HashMap<>(defaultHeaderMap);
allHeaderParams.putAll(headerParams);

if (authNames != null) {
// update different parameters (e.g. headers) for authentication
updateParamsForAuth(
authNames,
queryParams,
allHeaderParams,
cookieParams,
null,
method,
target.getUri());
}

if (queryParams != null) {
for (Pair queryParam : queryParams) {
if (queryParam.getValue() != null) {
Expand Down Expand Up @@ -1065,22 +1119,6 @@ public <T> ApiResponse<T> invokeAPI(

Entity<?> entity = serialize(body, formParams, contentType, isBodyNullable);

// put all headers in one place
Map<String, String> allHeaderParams = new HashMap<>(defaultHeaderMap);
allHeaderParams.putAll(headerParams);

if (authNames != null) {
// update different parameters (e.g. headers) for authentication
updateParamsForAuth(
authNames,
queryParams,
allHeaderParams,
cookieParams,
null,
method,
target.getUri());
}

for (Entry<String, String> entry : allHeaderParams.entrySet()) {
String value = entry.getValue();
if (value != null) {
Expand Down Expand Up @@ -1142,7 +1180,7 @@ public <T> ApiResponse<T> invokeAPI(
}
}

private Response sendRequest(
protected Response sendRequest(
String method, Invocation.Builder invocationBuilder, Entity<?> entity) {
Response response;
if ("POST".equals(method)) {
Expand Down Expand Up @@ -1203,8 +1241,10 @@ public <T> ApiResponse<T> invokeAPI(
* @return Client
*/
protected Client buildHttpClient() {
// recreate the client config to pickup changes
clientConfig = getDefaultClientConfig();
// Create ClientConfig if it has not been initialized yet
if (clientConfig == null) {
clientConfig = getDefaultClientConfig();
}

ClientBuilder clientBuilder = ClientBuilder.newBuilder();
clientBuilder = clientBuilder.withConfig(clientConfig);
Expand All @@ -1225,6 +1265,11 @@ public ClientConfig getDefaultClientConfig() {
clientConfig.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true);
// turn off compliance validation to be able to send payloads with DELETE calls
clientConfig.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
applyDebugSetting(clientConfig);
return clientConfig;
}

protected void applyDebugSetting(ClientConfig clientConfig) {
if (debugging) {
clientConfig.register(
new LoggingFeature(
Expand All @@ -1242,8 +1287,6 @@ public ClientConfig getDefaultClientConfig() {
java.util.logging.Logger.getLogger("org.glassfish.jersey.client")
.setLevel(java.util.logging.Level.SEVERE);
}

return clientConfig;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/** API Exception */
@javax.annotation.Generated(
value = "org.openapitools.codegen.languages.JavaClientCodegen",
comments = "Generator version: 7.12.0")
comments = "Generator version: 7.26.0")
public class ApiException extends Exception {
private static final long serialVersionUID = 1L;

Expand Down
31 changes: 27 additions & 4 deletions sdks/java-v1/src/main/java/com/dropbox/sign/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,18 @@

package com.dropbox.sign;

import java.util.Objects;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Supplier;

@javax.annotation.Generated(
value = "org.openapitools.codegen.languages.JavaClientCodegen",
comments = "Generator version: 7.12.0")
comments = "Generator version: 7.26.0")
public class Configuration {
public static final String VERSION = "1.11-dev";

private static volatile ApiClient defaultApiClient = new ApiClient();
private static final AtomicReference<ApiClient> defaultApiClient = new AtomicReference<>();
private static volatile Supplier<ApiClient> apiClientFactory = ApiClient::new;

/**
* Get the default API client, which would be used when creating API instances without providing
Expand All @@ -27,7 +32,18 @@ public class Configuration {
* @return Default API client
*/
public static ApiClient getDefaultApiClient() {
return defaultApiClient;
ApiClient client = defaultApiClient.get();
if (client == null) {
client =
defaultApiClient.updateAndGet(
val -> {
if (val != null) { // changed by another thread
return val;
}
return apiClientFactory.get();
});
}
return client;
}

/**
Expand All @@ -37,6 +53,13 @@ public static ApiClient getDefaultApiClient() {
* @param apiClient API client
*/
public static void setDefaultApiClient(ApiClient apiClient) {
defaultApiClient = apiClient;
defaultApiClient.set(apiClient);
}

/** set the callback used to create new ApiClient objects */
public static void setApiClientFactory(Supplier<ApiClient> factory) {
apiClientFactory = Objects.requireNonNull(factory);
}

public Configuration() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

@javax.annotation.Generated(
value = "org.openapitools.codegen.languages.JavaClientCodegen",
comments = "Generator version: 7.12.0")
comments = "Generator version: 7.26.0")
public class EventCallbackHelper {
public static final String EVENT_TYPE_ACCOUNT_CALLBACK = "account_callback";

Expand Down
Loading
Loading