Skip to content

Bump org.openapitools:openapi-generator from 7.4.0 to 7.12.0 #1010

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
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
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@
<artifactId>swagger-annotations</artifactId>
<version>2.2.7</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</dependency>
</dependencies>

<packaging>jar</packaging>
Expand Down
1 change: 0 additions & 1 deletion boat-maven-plugin/src/it/example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<properties>

<boat-maven-plugin.version>@pom.version@</boat-maven-plugin.version>
<!-- <boat-maven-plugin.version>0.12.0-SNAPS§HOT</boat-maven-plugin.version>-->
<jackson-databind-nullable-version>0.2.3</jackson-databind-nullable-version>

<jackson.version>2.13.3</jackson.version>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,5 @@
package com.backbase.oss.boat;

import static java.lang.String.format;
import static java.util.Arrays.stream;
import static java.util.Collections.emptyMap;
import static java.util.stream.Collectors.joining;
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyAdditionalPropertiesKvp;
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyAdditionalPropertiesKvpList;
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyImportMappingsKvp;
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyImportMappingsKvpList;
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyInstantiationTypesKvp;
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyInstantiationTypesKvpList;
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyLanguageSpecificPrimitivesCsv;
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyLanguageSpecificPrimitivesCsvList;
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyOpenAPINormalizerKvpList;
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyReservedWordsMappingsKvp;
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyReservedWordsMappingsKvpList;
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applySchemaMappingsKvp;
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applySchemaMappingsKvpList;
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyServerVariablesKvp;
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyServerVariablesKvpList;
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyTypeMappingsKvp;
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyTypeMappingsKvpList;

import com.backbase.oss.boat.transformers.Bundler;
import com.backbase.oss.boat.transformers.DereferenceComponentsPropertiesTransformer;
import com.backbase.oss.boat.transformers.UnAliasTransformer;
Expand All @@ -33,31 +10,6 @@
import io.swagger.v3.core.util.Yaml;
import io.swagger.v3.parser.core.models.AuthorizationValue;
import io.swagger.v3.parser.util.ClasspathHelper;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLConnection;
import java.nio.channels.Channels;
import java.nio.channels.FileChannel;
import java.nio.channels.ReadableByteChannel;
import java.nio.charset.StandardCharsets;
import java.nio.file.StandardCopyOption;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.maven.plugin.MojoExecutionException;
Expand All @@ -66,17 +18,36 @@
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.openapitools.codegen.CliOption;
import org.openapitools.codegen.ClientOptInput;
import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.DefaultGenerator;
import org.openapitools.codegen.*;
import org.openapitools.codegen.auth.AuthParser;
import org.openapitools.codegen.config.CodegenConfigurator;
import org.openapitools.codegen.config.GlobalSettings;
import org.openapitools.codegen.utils.OptionUtils;
import org.sonatype.plexus.build.incremental.BuildContext;
import org.sonatype.plexus.build.incremental.DefaultBuildContext;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.*;
import java.nio.channels.Channels;
import java.nio.channels.FileChannel;
import java.nio.channels.ReadableByteChannel;
import java.nio.charset.StandardCharsets;
import java.nio.file.StandardCopyOption;
import java.util.*;
import java.util.Map.Entry;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static java.lang.String.format;
import static java.util.Arrays.stream;
import static java.util.Collections.emptyMap;
import static java.util.stream.Collectors.joining;
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.*;

/**
* Generates client/server code from an OpenAPI json/yaml definition.
*/
Expand Down Expand Up @@ -573,13 +544,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
java.nio.file.Files.copy(inputSpecFile.toPath(), copyTo.toPath(), StandardCopyOption.REPLACE_EXISTING);
}

// attempt to read from config file
CodegenConfigurator configurator = CodegenConfigurator.fromFile(configurationFile);

// if a config file wasn't specified or we were unable to read it
if (configurator == null) {
configurator = new CodegenConfigurator();
}
final CodegenConfigurator configurator = loadCodegenConfigurator();

configurator.setVerbose(verbose);

Expand Down Expand Up @@ -857,7 +822,10 @@ public void execute() throws MojoExecutionException, MojoFailureException {
}

if (openapiNormalizer != null && (configOptions == null || !configOptions.containsKey("openapi-normalizer"))) {
applyOpenAPINormalizerKvpList(openapiNormalizer, configurator);
for (String propString: openapiNormalizer) {
OptionUtils.parseCommaSeparatedTuples(propString)
.forEach(p -> configurator.addOpenapiNormalizer(p.getLeft(), p.getRight()));
}
}

// Apply Schema Mappings
Expand Down Expand Up @@ -953,6 +921,16 @@ public void execute() throws MojoExecutionException, MojoFailureException {
}
}

/**
* Attempt to read from config file, return default otherwise.
*
* @return The CodegenConfigurator loaded from file or a default.
*/
private CodegenConfigurator loadCodegenConfigurator() {
CodegenConfigurator configurator = CodegenConfigurator.fromFile(configurationFile);
return configurator != null ? configurator : new CodegenConfigurator();
}

protected Collection<String> getGeneratorSpecificSupportingFiles() {
return Collections.emptySet();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.backbase.oss.codegen.java;

import com.backbase.oss.codegen.java.BoatCodeGenUtils.CodegenValueType;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema;
import lombok.Getter;
import lombok.Setter;
Expand Down Expand Up @@ -157,7 +156,7 @@ private boolean isArrayTypeOfEnum(Schema s) {
if (!ModelUtils.isArraySchema(target)) {
return false;
}
Schema items = getSchemaItems((ArraySchema) target);
Schema items = target.getItems();
if (items.get$ref() != null) {
items = openAPI.getComponents().getSchemas().get(ModelUtils.getSimpleRef(items.get$ref()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,6 @@ public void postProcessModelProperty(CodegenModel model, CodegenProperty propert
if (shouldSerializeBigDecimalAsString(property)) {
property.vendorExtensions.put("x-extra-annotation", "@JsonSerialize(using = BigDecimalCustomSerializer.class)");
model.imports.add("BigDecimalCustomSerializer");
model.imports.add("JsonSerialize");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ public BoatSpringCodegenProperty(CodegenProperty codegenProperty) {
defaultValue = "new HashMap<>()";
isMap = true;
}
this.nameInCamelCase = StringUtils.capitalize(this.nameInCamelCase);
}
@Override
public String toString() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
{{>licenseInfo}}
package {{invokerPackage}};

import com.fasterxml.jackson.core.type.TypeReference;

import java.util.Collections;
import java.util.Map;

{{>generatedAnnotation}}
public abstract class BaseApi {

protected ApiClient apiClient;

public BaseApi() {
this(Configuration.getDefaultApiClient());
}

public BaseApi(ApiClient apiClient) {
this.apiClient = apiClient;
}

public ApiClient getApiClient() {
return apiClient;
}

public void setApiClient(ApiClient apiClient) {
this.apiClient = apiClient;
}

/**
* Directly invoke the API for the given URL. Useful if the API returns direct links/URLs for subsequent requests.
* @param url The URL for the request, either full URL or only the path.
* @param method The HTTP method for the request.
* @throws ApiException if fails to make API call.
*/
public void invokeAPI(String url, String method) throws ApiException {
invokeAPI(url, method, null, null, Collections.emptyMap());
}

/**
* Directly invoke the API for the given URL. Useful if the API returns direct links/URLs for subsequent requests.
* @param url The URL for the request, either full URL or only the path.
* @param method The HTTP method for the request.
* @param additionalHeaders Additional headers for the request.
* @throws ApiException if fails to make API call.
*/
public void invokeAPI(String url, String method, Map<String, String> additionalHeaders) throws ApiException {
invokeAPI(url, method, null, null, additionalHeaders);
}

/**
* Directly invoke the API for the given URL. Useful if the API returns direct links/URLs for subsequent requests.
* @param url The URL for the request, either full URL or only the path.
* @param method The HTTP method for the request.
* @param request The request object.
* @throws ApiException if fails to make API call.
*/
public void invokeAPI(String url, String method, Object request) throws ApiException {
invokeAPI(url, method, request, null, Collections.emptyMap());
}

/**
* Directly invoke the API for the given URL. Useful if the API returns direct links/URLs for subsequent requests.
* @param url The URL for the request, either full URL or only the path.
* @param method The HTTP method for the request.
* @param request The request object.
* @param additionalHeaders Additional headers for the request.
* @throws ApiException if fails to make API call.
*/
public void invokeAPI(String url, String method, Object request, Map<String, String> additionalHeaders) throws ApiException {
invokeAPI(url, method, request, null, additionalHeaders);
}

/**
* Directly invoke the API for the given URL. Useful if the API returns direct links/URLs for subsequent requests.
* @param url The URL for the request, either full URL or only the path.
* @param method The HTTP method for the request.
* @param returnType The return type.
* @return The API response in the specified type.
* @throws ApiException if fails to make API call.
*/
public <T> T invokeAPI(String url, String method, TypeReference<T> returnType) throws ApiException {
return invokeAPI(url, method, null, returnType, Collections.emptyMap());
}

/**
* Directly invoke the API for the given URL. Useful if the API returns direct links/URLs for subsequent requests.
* @param url The URL for the request, either full URL or only the path.
* @param method The HTTP method for the request.
* @param request The request object.
* @param returnType The return type.
* @return The API response in the specified type.
* @throws ApiException if fails to make API call.
*/
public <T> T invokeAPI(String url, String method, Object request, TypeReference<T> returnType) throws ApiException {
return invokeAPI(url, method, request, returnType, Collections.emptyMap());
}

/**
* Directly invoke the API for the given URL. Useful if the API returns direct links/URLs for subsequent requests.
* @param url The URL for the request, either full URL or only the path.
* @param method The HTTP method for the request.
* @param request The request object.
* @param returnType The return type.
* @param additionalHeaders Additional headers for the request.
* @return The API response in the specified type.
* @throws ApiException if fails to make API call.
*/
public abstract <T> T invokeAPI(String url, String method, Object request, TypeReference<T> returnType, Map<String, String> additionalHeaders) throws ApiException;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{{>licenseInfo}}

package {{invokerPackage}};

import org.springframework.web.client.RestClientException;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;

{{>generatedAnnotation}}
public abstract class BaseApi {

protected ApiClient apiClient;

public BaseApi() {
this(new ApiClient());
}

public BaseApi(ApiClient apiClient) {
this.apiClient = apiClient;
}

public ApiClient getApiClient() {
return apiClient;
}

public void setApiClient(ApiClient apiClient) {
this.apiClient = apiClient;
}

/**
* Directly invoke the API for the given URL. Useful if the API returns direct links/URLs for subsequent requests.
* @param url The URL for the request, either full URL or only the path.
* @param method The HTTP method for the request.
* @return ResponseEntity&lt;Void&gt;
* @throws RestClientException if an error occurs while attempting to invoke the API
*/
public ResponseEntity<Void> invokeAPI(String url, HttpMethod method) throws RestClientException {
return invokeAPI(url, method, null, new ParameterizedTypeReference<Void>() {});
}

/**
* Directly invoke the API for the given URL. Useful if the API returns direct links/URLs for subsequent requests.
* @param url The URL for the request, either full URL or only the path.
* @param method The HTTP method for the request.
* @param request The request object.
* @return ResponseEntity&lt;Void&gt;
* @throws RestClientException if an error occurs while attempting to invoke the API
*/
public ResponseEntity<Void> invokeAPI(String url, HttpMethod method, Object request) throws RestClientException {
return invokeAPI(url, method, request, new ParameterizedTypeReference<Void>() {});
}

/**
* Directly invoke the API for the given URL. Useful if the API returns direct links/URLs for subsequent requests.
* @param url The URL for the request, either full URL or only the path.
* @param method The HTTP method for the request.
* @param returnType The return type.
* @return ResponseEntity in the specified type.
* @throws RestClientException if an error occurs while attempting to invoke the API
*/
public <T> ResponseEntity<T> invokeAPI(String url, HttpMethod method, ParameterizedTypeReference<T> returnType) throws RestClientException {
return invokeAPI(url, method, null, returnType);
}

/**
* Directly invoke the API for the given URL. Useful if the API returns direct links/URLs for subsequent requests.
* @param url The URL for the request, either full URL or only the path.
* @param method The HTTP method for the request.
* @param request The request object.
* @param returnType The return type.
* @return ResponseEntity in the specified type.
* @throws RestClientException if an error occurs while attempting to invoke the API
*/
public abstract <T> ResponseEntity<T> invokeAPI(String url, HttpMethod method, Object request, ParameterizedTypeReference<T> returnType) throws RestClientException;
}
1 change: 1 addition & 0 deletions boat-scaffold/src/main/templates/boat-java/model.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import java.io.Serializable;
{{#jackson}}
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
{{#withXml}}
import com.fasterxml.jackson.dataformat.xml.annotation.*;
{{/withXml}}
Expand Down
Loading