From e5ff99a9c7019a259a9cf07395c2e21dd4306e5f Mon Sep 17 00:00:00 2001 From: Davide Vacca Date: Wed, 16 Oct 2024 15:59:58 +0200 Subject: [PATCH] Upgrade OpenAPI generator to v7.8.0 (was v7.7.0) --- .../update-specs-and-client-libraries.yaml | 2 +- .../java/okhttp-gson/templates/SHA256SUM | 8 +-- .../libraries/okhttp-gson/ApiClient.mustache | 59 ++++++++++++++++--- .../libraries/okhttp-gson/api.mustache | 10 ++-- .../libraries/okhttp-gson/pojo.mustache | 1 - .../libraries/okhttp-gson/pom.mustache | 17 ++---- .../php/templates/ObjectSerializer.mustache | 5 ++ generators/php/templates/SHA256SUM | 2 +- generators/typescript-axios/config.yaml | 1 + .../typescript-axios/templates/SHA256SUM | 4 +- .../templates/apiInner.mustache | 2 +- .../templates/package.mustache | 2 +- shell/generate.sh | 2 +- 13 files changed, 80 insertions(+), 35 deletions(-) diff --git a/.github/workflows/update-specs-and-client-libraries.yaml b/.github/workflows/update-specs-and-client-libraries.yaml index 43face33..bb495ea9 100644 --- a/.github/workflows/update-specs-and-client-libraries.yaml +++ b/.github/workflows/update-specs-and-client-libraries.yaml @@ -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 }} diff --git a/generators/java/okhttp-gson/templates/SHA256SUM b/generators/java/okhttp-gson/templates/SHA256SUM index f19ba404..2ad3ad95 100644 --- a/generators/java/okhttp-gson/templates/SHA256SUM +++ b/generators/java/okhttp-gson/templates/SHA256SUM @@ -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 diff --git a/generators/java/okhttp-gson/templates/libraries/okhttp-gson/ApiClient.mustache b/generators/java/okhttp-gson/templates/libraries/okhttp-gson/ApiClient.mustache index aaee1442..342d5a51 100644 --- a/generators/java/okhttp-gson/templates/libraries/okhttp-gson/ApiClient.mustache +++ b/generators/java/okhttp-gson/templates/libraries/okhttp-gson/ApiClient.mustache @@ -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). * @@ -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 freeFormParameterToPairs(Object value) { + List params = new ArrayList<>(); + + // preconditions + if (value == null || !(value instanceof Map )) { + return params; + } + + final Map valuesMap = (Map) value; + + for (Map.Entry entry : valuesMap.entrySet()) { + params.add(new Pair(entry.getKey(), parameterToString(entry.getValue()))); + } + + return params; + } + + /** * Formats the specified collection path parameter to a string value. * @@ -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; @@ -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 queryParams, List collectionQueryParams, Object body, Map headerParams, Map cookieParams, Map formParams, String[] authNames, ApiCallback callback) throws ApiException { - // aggregate queryParams (non-collection) and collectionQueryParams into allQueryParams - List allQueryParams = new ArrayList(queryParams); - allQueryParams.addAll(collectionQueryParams); - final String url = buildUrl(baseUrl, path, queryParams, collectionQueryParams); // prepare HTTP request body @@ -1433,10 +1476,12 @@ public class ApiClient { reqBody = serialize(body, contentType); } + List 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); diff --git a/generators/java/okhttp-gson/templates/libraries/okhttp-gson/api.mustache b/generators/java/okhttp-gson/templates/libraries/okhttp-gson/api.mustache index 437067d6..02d77552 100644 --- a/generators/java/okhttp-gson/templates/libraries/okhttp-gson/api.mustache +++ b/generators/java/okhttp-gson/templates/libraries/okhttp-gson/api.mustache @@ -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; @@ -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}} diff --git a/generators/java/okhttp-gson/templates/libraries/okhttp-gson/pojo.mustache b/generators/java/okhttp-gson/templates/libraries/okhttp-gson/pojo.mustache index 1ab0b6a8..57598cdb 100644 --- a/generators/java/okhttp-gson/templates/libraries/okhttp-gson/pojo.mustache +++ b/generators/java/okhttp-gson/templates/libraries/okhttp-gson/pojo.mustache @@ -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; diff --git a/generators/java/okhttp-gson/templates/libraries/okhttp-gson/pom.mustache b/generators/java/okhttp-gson/templates/libraries/okhttp-gson/pom.mustache index 7fa22253..c92140ef 100644 --- a/generators/java/okhttp-gson/templates/libraries/okhttp-gson/pom.mustache +++ b/generators/java/okhttp-gson/templates/libraries/okhttp-gson/pom.mustache @@ -395,14 +395,9 @@ {{/withAWSV4Signature}} - javax.ws.rs - jsr311-api - ${jsr311-api-version} - - - javax.ws.rs - javax.ws.rs-api - ${javax.ws.rs-api-version} + jakarta.ws.rs + jakarta.ws.rs-api + ${jakarta.ws.rs-api-version} @@ -429,7 +424,7 @@ {{#swagger2AnnotationLibrary}} 2.2.15 {{/swagger2AnnotationLibrary}} - 4.11.0 + 4.12.0 2.10.1 3.14.0 {{#openApiNullable}} @@ -450,9 +445,9 @@ {{#useBeanValidation}} 3.0.2 {{/useBeanValidation}} - 5.10.2 + 5.10.3 1.10.0 - 2.1.1 + 2.1.6 1.1.1 UTF-8 2.43.0 diff --git a/generators/php/templates/ObjectSerializer.mustache b/generators/php/templates/ObjectSerializer.mustache index bfd1b836..0289773f 100644 --- a/generators/php/templates/ObjectSerializer.mustache +++ b/generators/php/templates/ObjectSerializer.mustache @@ -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; } diff --git a/generators/php/templates/SHA256SUM b/generators/php/templates/SHA256SUM index 1c63395d..c47fe565 100644 --- a/generators/php/templates/SHA256SUM +++ b/generators/php/templates/SHA256SUM @@ -1,6 +1,6 @@ bb92a3f3107664c296ebc45c75bff7c88abf8b765565f4656a05e24234cb6d67 ./Configuration.mustache -557173b27efb57eeba6187b8b64963a49964ade8f5f6418bd514ece483f392dd ./ObjectSerializer.mustache +270c3ec9312d3cb2c5317a1df29ffb5365ff8624f1d165a1e9e356b4ea57a7f3 ./ObjectSerializer.mustache 8eebaed003795c011df87fecd1f89c630dd3f23282d80e7f407f62009e2cd0ee ./README.mustache 2d94750ad5d913f8b7fbba24681c7cc1d75e96c89ec46c379e6625c825b39020 ./model_generic.mustache 37d3333c7c3dbc6f6bffe64ce076bc512a2a1e61e986738c8e023bb745168e9a ./phpunit.xml.mustache diff --git a/generators/typescript-axios/config.yaml b/generators/typescript-axios/config.yaml index 4d062529..7670c16d 100644 --- a/generators/typescript-axios/config.yaml +++ b/generators/typescript-axios/config.yaml @@ -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: diff --git a/generators/typescript-axios/templates/SHA256SUM b/generators/typescript-axios/templates/SHA256SUM index c918a09d..6b819544 100644 --- a/generators/typescript-axios/templates/SHA256SUM +++ b/generators/typescript-axios/templates/SHA256SUM @@ -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 diff --git a/generators/typescript-axios/templates/apiInner.mustache b/generators/typescript-axios/templates/apiInner.mustache index 9ee07243..57d32331 100644 --- a/generators/typescript-axios/templates/apiInner.mustache +++ b/generators/typescript-axios/templates/apiInner.mustache @@ -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}} diff --git a/generators/typescript-axios/templates/package.mustache b/generators/typescript-axios/templates/package.mustache index 98448292..711cb54e 100644 --- a/generators/typescript-axios/templates/package.mustache +++ b/generators/typescript-axios/templates/package.mustache @@ -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 }} diff --git a/shell/generate.sh b/shell/generate.sh index 05027844..7cb58831 100755 --- a/shell/generate.sh +++ b/shell/generate.sh @@ -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}}