Skip to content

Commit

Permalink
Migrate to OpenAPI generator v7.8.0 (was v7.7.0)
Browse files Browse the repository at this point in the history
  • Loading branch information
dvacca-onfido committed Oct 16, 2024
1 parent 7b6e844 commit 13f6a2b
Show file tree
Hide file tree
Showing 13 changed files with 80 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/update-specs-and-client-libraries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
python_version: ${{ steps.generator.outputs.python_urllib3_version }}
ruby_version: ${{ steps.generator.outputs.ruby_faraday_version }}
container:
image: openapitools/openapi-generator-cli:v7.7.0
image: openapitools/openapi-generator-cli:v7.8.0
env:
OPENAPI_GENERATOR_COMMAND: docker-entrypoint.sh
BUMP_CLIENT_LIBRARY_VERSION: ${{ inputs.type-of-change }}
Expand Down
8 changes: 4 additions & 4 deletions generators/java/okhttp-gson/templates/SHA256SUM
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

16502193337397367078434a27f67edfc6410f4c06d12db876155885d6a49394 ./README.mustache
7b635a5f3fcc4cb2ace38f0dd0ca8252a78090e592a6c35fe5a08f7bc407ef6b ./libraries/okhttp-gson/ApiClient.mustache
aeab98c355869f50b770c6ae6586ea4a4967da9932b1ea33dae5460282edbfa9 ./libraries/okhttp-gson/api.mustache
9866a9e83531d72f155a0fdea252cfe5d340deea3d6e2da7eb64c941dc88577a ./libraries/okhttp-gson/ApiClient.mustache
1cf200f8d6f6a64eb2f0d88169691b5702dc944e801c615d02db33daee46c55c ./libraries/okhttp-gson/api.mustache
0e77feaf2d6b0818194161ac7e621189aa6e7900b45d46fa4ff1232894bb1a7a ./libraries/okhttp-gson/oneof_model.mustache
0a32d7eb71b3604d8eb295f39a0da854ea602ea9c95bf0539dc0c25942374cf0 ./libraries/okhttp-gson/pojo.mustache
63aed7ca8c0c5d881ad2c7845d33804f17280420d31bcdbcbcf8ae4f3f55e741 ./libraries/okhttp-gson/pom.mustache
f20b6129f3b473ecaa4e39f760bb1028d6c1f832928fa2f460131e2c54d66ed0 ./libraries/okhttp-gson/pojo.mustache
5866ce4047537e9b5d1038155599b8bad2f13a523ff5710ec29f16c6122ac7d7 ./libraries/okhttp-gson/pom.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,29 @@ public class ApiClient {
throw new RuntimeException("No AWS4 authentication configured!");
}

/**
* Helper method to set credentials for AWSV4 Signature
*
* @param accessKey Access Key
* @param secretKey Secret Key
* @param sessionToken Session Token
* @param region Region
* @param service Service to access to
*/
public void setAWS4Configuration(String accessKey, String secretKey, String sessionToken, String region, String service) {
{{#withAWSV4Signature}}
for (Authentication auth : authentications.values()) {
if (auth instanceof AWS4Auth) {
((AWS4Auth) auth).setCredentials(accessKey, secretKey, sessionToken);
((AWS4Auth) auth).setRegion(region);
((AWS4Auth) auth).setService(service);
return;
}
}
{{/withAWSV4Signature}}
throw new RuntimeException("No AWS4 authentication configured!");
}

/**
* Set the User-Agent header's value (by adding to the default header map).
*
Expand Down Expand Up @@ -939,6 +962,30 @@ public class ApiClient {
}
{{/dynamicOperations}}
/**
* Formats the specified free-form query parameters to a list of {@code Pair} objects.
*
* @param value The free-form query parameters.
* @return A list of {@code Pair} objects.
*/
public List<Pair> freeFormParameterToPairs(Object value) {
List<Pair> params = new ArrayList<>();
// preconditions
if (value == null || !(value instanceof Map )) {
return params;
}
final Map<String, Object> valuesMap = (Map<String, Object>) value;
for (Map.Entry<String, Object> entry : valuesMap.entrySet()) {
params.add(new Pair(entry.getKey(), parameterToString(entry.getValue())));
}
return params;
}
/**
* Formats the specified collection path parameter to a string value.
*
Expand Down Expand Up @@ -1192,7 +1239,7 @@ public class ApiClient {
* @throws java.io.IOException If fail to prepare file for download
*/
public File prepareDownloadFile(Response response) throws IOException {
{{! Code extrated to getFilenameFromResponse }}
{{! Code extracted to getFilenameFromResponse }}
String filename = getFilenameFromResponse(response);

String prefix = null;
Expand Down Expand Up @@ -1402,10 +1449,6 @@ public class ApiClient {
* @throws {{invokerPackage}}.ApiException If fail to serialize the request body object
*/
public Request buildRequest(String baseUrl, String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String[] authNames, ApiCallback callback) throws ApiException {
// aggregate queryParams (non-collection) and collectionQueryParams into allQueryParams
List<Pair> allQueryParams = new ArrayList<Pair>(queryParams);
allQueryParams.addAll(collectionQueryParams);
final String url = buildUrl(baseUrl, path, queryParams, collectionQueryParams);
// prepare HTTP request body
Expand Down Expand Up @@ -1433,10 +1476,12 @@ public class ApiClient {
reqBody = serialize(body, contentType);
}

List<Pair> updatedQueryParams = new ArrayList<>(queryParams);

// update parameters with authentication settings
updateParamsForAuth(authNames, allQueryParams, headerParams, cookieParams, requestBodyToString(reqBody), method, URI.create(url));
updateParamsForAuth(authNames, updatedQueryParams, headerParams, cookieParams, requestBodyToString(reqBody), method, URI.create(url));

final Request.Builder reqBuilder = new Request.Builder().url(url);
final Request.Builder reqBuilder = new Request.Builder().url(buildUrl(baseUrl, path, updatedQueryParams, collectionQueryParams));
processHeaderParams(headerParams, reqBuilder);
processCookieParams(cookieParams, reqBuilder);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ import jakarta.validation.constraints.*;
import jakarta.validation.Valid;
{{/useBeanValidation}}
{{#performBeanValidation}}
import {{javaxPackage}}.validation.ConstraintViolation;
import {{javaxPackage}}.validation.Validation;
import {{javaxPackage}}.validation.ValidatorFactory;
import {{javaxPackage}}.validation.executable.ExecutableValidator;
import jakarta.validation.ConstraintViolation;
import jakarta.validation.Validation;
import jakarta.validation.ValidatorFactory;
import jakarta.validation.executable.ExecutableValidator;
import java.util.Set;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
Expand Down Expand Up @@ -170,7 +170,7 @@ public class {{classname}} {
{{^dynamicOperations}}
{{#queryParams}}
if ({{paramName}} != null) {
{{#collectionFormat}}localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("{{{.}}}", {{/collectionFormat}}{{^collectionFormat}}localVarQueryParams.addAll(localVarApiClient.parameterToPair({{/collectionFormat}}"{{baseName}}", {{paramName}}));
{{#isFreeFormObject}}localVarQueryParams.addAll(localVarApiClient.freeFormParameterToPairs({{paramName}}));{{/isFreeFormObject}}{{^isFreeFormObject}}{{#collectionFormat}}localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("{{{.}}}", {{/collectionFormat}}{{^collectionFormat}}localVarQueryParams.addAll(localVarApiClient.parameterToPair({{/collectionFormat}}"{{baseName}}", {{paramName}}));{{/isFreeFormObject}}
}

{{/queryParams}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,14 +395,9 @@
</dependency>
{{/withAWSV4Signature}}
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<version>${jsr311-api-version}</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>${javax.ws.rs-api-version}</version>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
<version>${jakarta.ws.rs-api-version}</version>
</dependency>
<!-- test dependencies -->
<dependency>
Expand All @@ -429,7 +424,7 @@
{{#swagger2AnnotationLibrary}}
<swagger-annotations-version>2.2.15</swagger-annotations-version>
{{/swagger2AnnotationLibrary}}
<okhttp-version>4.11.0</okhttp-version>
<okhttp-version>4.12.0</okhttp-version>
<gson-version>2.10.1</gson-version>
<commons-lang3-version>3.14.0</commons-lang3-version>
{{#openApiNullable}}
Expand All @@ -450,9 +445,9 @@
{{#useBeanValidation}}
<beanvalidation-version>3.0.2</beanvalidation-version>
{{/useBeanValidation}}
<junit-version>5.10.2</junit-version>
<junit-version>5.10.3</junit-version>
<junit-platform-runner.version>1.10.0</junit-platform-runner.version>
<javax.ws.rs-api-version>2.1.1</javax.ws.rs-api-version>
<jakarta.ws.rs-api-version>2.1.6</jakarta.ws.rs-api-version>
<jsr311-api-version>1.1.1</jsr311-api-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spotless.version>2.43.0</spotless.version>
Expand Down
5 changes: 5 additions & 0 deletions generators/php/templates/ObjectSerializer.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,11 @@ class ObjectSerializer
$value = $flattenArray($value, $paramName);
// https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-values
if ($openApiType === 'array' && $style === 'deepObject' && $explode) {
return $value;
}
if ($openApiType === 'object' && ($style === 'deepObject' || $explode)) {
return $value;
}
Expand Down
2 changes: 1 addition & 1 deletion generators/php/templates/SHA256SUM
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

bb92a3f3107664c296ebc45c75bff7c88abf8b765565f4656a05e24234cb6d67 ./Configuration.mustache
557173b27efb57eeba6187b8b64963a49964ade8f5f6418bd514ece483f392dd ./ObjectSerializer.mustache
270c3ec9312d3cb2c5317a1df29ffb5365ff8624f1d165a1e9e356b4ea57a7f3 ./ObjectSerializer.mustache
8eebaed003795c011df87fecd1f89c630dd3f23282d80e7f407f62009e2cd0ee ./README.mustache
2d94750ad5d913f8b7fbba24681c7cc1d75e96c89ec46c379e6625c825b39020 ./model_generic.mustache
37d3333c7c3dbc6f6bffe64ce076bc512a2a1e61e986738c8e023bb745168e9a ./phpunit.xml.mustache
1 change: 1 addition & 0 deletions generators/typescript-axios/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ npmVersion: ${CLIENT_LIBRARY_VERSION}
enumUnknownDefaultCase: true
supportsES6: true
withNodeImports: true
axiosVersion: ^1.7.4
httpUserAgent: onfido-node/${CLIENT_LIBRARY_VERSION}
# Type mapping doesn't work with this generator
# typeMappings:
Expand Down
4 changes: 2 additions & 2 deletions generators/typescript-axios/templates/SHA256SUM
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

e13ee7c0cad9a79bab00e8b2a7942bc5a78f63115ece3dfd71a6472bdb02dd22 ./README.mustache
3a077701e62c4d0942657c78cf0116cbe58436e34d723d81aaed7ed0d56d2ed1 ./api.mustache
9348f10f4fae1b858223f3cd5e33a2f399061a43fb1882959627f0b52d9e0ea1 ./apiInner.mustache
1d4051cca5592db765d1f83133b10abf12cc19ef3c53690da1018c142a83727b ./apiInner.mustache
d8d68213e1a9a9983f89f688aaf31360f69d34a871cab4fc94f59a40279b13d9 ./configuration.mustache
5030fcd1954b4d981f2d06fce4900fe29c97c7b74ee66f2eb5f45e81b9252a94 ./index.mustache
28f5e210e99474200c8e5f13e4f2374c1556406eb71c15e808d81913000cd549 ./package.mustache
62bbc44c32ed454a215fc76636eaca819f012b65486485fda7499f7937557cc4 ./package.mustache
89b381b068d1849cc98721643c923ee153a5bdd69e19306dda59114ba0a2e243 ./tsconfig.mustache
2 changes: 1 addition & 1 deletion generators/typescript-axios/templates/apiInner.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ export const {{classname}}Factory = function (configuration?: Configuration, bas
},
{{/useSingleRequestParameter}}
{{^useSingleRequestParameter}}
{{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}}, {{/allParams}}options?: any): AxiosPromise<{{{returnType}}}{{^returnType}}void{{/returnType}}> {
{{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}}, {{/allParams}}options?: RawAxiosRequestConfig): AxiosPromise<{{{returnType}}}{{^returnType}}void{{/returnType}}> {
return localVarFp.{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options).then((request) => request(axios, basePath));
},
{{/useSingleRequestParameter}}
Expand Down
2 changes: 1 addition & 1 deletion generators/typescript-axios/templates/package.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
}
},
"dependencies": {
"axios": "^1.7.4" {{! Updated minimum Axios version to solve Dependabot alert }}
"axios": "{{axiosVersion}}"
},
"devDependencies": {
{{! Added dependencies for tests development - BEGIN }}
Expand Down
2 changes: 1 addition & 1 deletion shell/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ COMMON_CONFIG_FILE="generators/common/config.yaml"
GENERATORS=${*:-`find generators -name 'config.yaml' -exec dirname {} \; | sed 's/generators\///'`}
GENERATED_CONFIG_FILES=""
OPENAPI_GENERATOR_VERSION=${OPENAPI_GENERATOR_VERSION:-v7.7.0}
OPENAPI_GENERATOR_VERSION=${OPENAPI_GENERATOR_VERSION:-v7.8.0}
OPENAPI_GENERATOR_COMMAND=${OPENAPI_GENERATOR_COMMAND:-\
docker run --rm -v "$(pwd):/local" -w /local \
openapitools/openapi-generator-cli:${OPENAPI_GENERATOR_VERSION}}
Expand Down

0 comments on commit 13f6a2b

Please sign in to comment.