From 8f016530706bbad2d5dc041a0e3a093cbd637474 Mon Sep 17 00:00:00 2001 From: Mattias-Sehlstedt <60173714+Mattias-Sehlstedt@users.noreply.github.com> Date: Sun, 14 Dec 2025 23:27:55 +0100 Subject: [PATCH] [Java] [Spring Client] Add an exception provider interface to allow for easy exception redefinition --- .../codegen/languages/JavaClientCodegen.java | 2 + .../resources/Java/ExceptionProvider.mustache | 68 ++++++++++++++++ .../libraries/restclient/ApiClient.mustache | 48 ++++++++--- .../libraries/webclient/ApiClient.mustache | 48 ++++++++--- .../java/restclient/.openapi-generator/FILES | 1 + .../org/openapitools/client/ApiClient.java | 46 ++++++++--- .../client/ExceptionProvider.java | 79 +++++++++++++++++++ .../.openapi-generator/FILES | 1 + .../org/openapitools/client/ApiClient.java | 46 ++++++++--- .../client/ExceptionProvider.java | 79 +++++++++++++++++++ .../.openapi-generator/FILES | 1 + .../org/openapitools/client/ApiClient.java | 46 ++++++++--- .../client/ExceptionProvider.java | 79 +++++++++++++++++++ .../.openapi-generator/FILES | 1 + .../org/openapitools/client/ApiClient.java | 46 ++++++++--- .../client/ExceptionProvider.java | 79 +++++++++++++++++++ .../.openapi-generator/FILES | 1 + .../org/openapitools/client/ApiClient.java | 46 ++++++++--- .../client/ExceptionProvider.java | 79 +++++++++++++++++++ .../.openapi-generator/FILES | 1 + .../org/openapitools/client/ApiClient.java | 46 ++++++++--- .../client/ExceptionProvider.java | 79 +++++++++++++++++++ .../.openapi-generator/FILES | 1 + .../org/openapitools/client/ApiClient.java | 46 ++++++++--- .../client/ExceptionProvider.java | 79 +++++++++++++++++++ .../.openapi-generator/FILES | 1 + .../org/openapitools/client/ApiClient.java | 46 ++++++++--- .../client/ExceptionProvider.java | 79 +++++++++++++++++++ .../.openapi-generator/FILES | 1 + .../org/openapitools/client/ApiClient.java | 48 ++++++++--- .../client/ExceptionProvider.java | 79 +++++++++++++++++++ .../.openapi-generator/FILES | 1 + .../org/openapitools/client/ApiClient.java | 46 ++++++++--- .../client/ExceptionProvider.java | 79 +++++++++++++++++++ .../.openapi-generator/FILES | 1 + .../org/openapitools/client/ApiClient.java | 48 ++++++++--- .../client/ExceptionProvider.java | 79 +++++++++++++++++++ .../.openapi-generator/FILES | 1 + .../org/openapitools/client/ApiClient.java | 48 ++++++++--- .../client/ExceptionProvider.java | 79 +++++++++++++++++++ .../.openapi-generator/FILES | 1 + .../org/openapitools/client/ApiClient.java | 48 ++++++++--- .../client/ExceptionProvider.java | 79 +++++++++++++++++++ .../.openapi-generator/FILES | 1 + .../org/openapitools/client/ApiClient.java | 48 ++++++++--- .../client/ExceptionProvider.java | 79 +++++++++++++++++++ .../java/restclient/.openapi-generator/FILES | 1 + .../org/openapitools/client/ApiClient.java | 48 ++++++++--- .../client/ExceptionProvider.java | 79 +++++++++++++++++++ .../.openapi-generator/FILES | 1 + .../org/openapitools/client/ApiClient.java | 48 ++++++++--- .../client/ExceptionProvider.java | 79 +++++++++++++++++++ .../.openapi-generator/FILES | 1 + .../org/openapitools/client/ApiClient.java | 46 ++++++++--- .../client/ExceptionProvider.java | 79 +++++++++++++++++++ .../.openapi-generator/FILES | 1 + .../org/openapitools/client/ApiClient.java | 46 ++++++++--- .../client/ExceptionProvider.java | 79 +++++++++++++++++++ .../.openapi-generator/FILES | 1 + .../org/openapitools/client/ApiClient.java | 48 ++++++++--- .../client/ExceptionProvider.java | 79 +++++++++++++++++++ .../.openapi-generator/FILES | 1 + .../org/openapitools/client/ApiClient.java | 48 ++++++++--- .../client/ExceptionProvider.java | 79 +++++++++++++++++++ .../.openapi-generator/FILES | 1 + .../org/openapitools/client/ApiClient.java | 48 ++++++++--- .../client/ExceptionProvider.java | 79 +++++++++++++++++++ .../java/webclient/.openapi-generator/FILES | 1 + .../org/openapitools/client/ApiClient.java | 48 ++++++++--- .../client/ExceptionProvider.java | 79 +++++++++++++++++++ 70 files changed, 2707 insertions(+), 253 deletions(-) create mode 100644 modules/openapi-generator/src/main/resources/Java/ExceptionProvider.mustache create mode 100644 samples/client/echo_api/java/restclient/src/main/java/org/openapitools/client/ExceptionProvider.java create mode 100644 samples/client/others/java/restclient-enum-in-multipart/src/main/java/org/openapitools/client/ExceptionProvider.java create mode 100644 samples/client/others/java/restclient-sealedInterface/src/main/java/org/openapitools/client/ExceptionProvider.java create mode 100644 samples/client/others/java/restclient-useAbstractionForFiles/src/main/java/org/openapitools/client/ExceptionProvider.java create mode 100644 samples/client/others/java/webclient-sealedInterface/src/main/java/org/openapitools/client/ExceptionProvider.java create mode 100644 samples/client/others/java/webclient-sealedInterface_3_1/src/main/java/org/openapitools/client/ExceptionProvider.java create mode 100644 samples/client/others/java/webclient-useAbstractionForFiles/src/main/java/org/openapitools/client/ExceptionProvider.java create mode 100644 samples/client/petstore/java/restclient-nullable-arrays/src/main/java/org/openapitools/client/ExceptionProvider.java create mode 100644 samples/client/petstore/java/restclient-springBoot4-jackson2/src/main/java/org/openapitools/client/ExceptionProvider.java create mode 100644 samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/ExceptionProvider.java create mode 100644 samples/client/petstore/java/restclient-springBoot4-jackson3/src/main/java/org/openapitools/client/ExceptionProvider.java create mode 100644 samples/client/petstore/java/restclient-swagger2/src/main/java/org/openapitools/client/ExceptionProvider.java create mode 100644 samples/client/petstore/java/restclient-useSingleRequestParameter-static/src/main/java/org/openapitools/client/ExceptionProvider.java create mode 100644 samples/client/petstore/java/restclient-useSingleRequestParameter/src/main/java/org/openapitools/client/ExceptionProvider.java create mode 100644 samples/client/petstore/java/restclient/src/main/java/org/openapitools/client/ExceptionProvider.java create mode 100644 samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/ExceptionProvider.java create mode 100644 samples/client/petstore/java/webclient-nullable-arrays/src/main/java/org/openapitools/client/ExceptionProvider.java create mode 100644 samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/ExceptionProvider.java create mode 100644 samples/client/petstore/java/webclient-springBoot4-jackson3/src/main/java/org/openapitools/client/ExceptionProvider.java create mode 100644 samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/ExceptionProvider.java create mode 100644 samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/ExceptionProvider.java create mode 100644 samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/ExceptionProvider.java diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java index f779be9ed183..befc33f19e84 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java @@ -720,6 +720,7 @@ public void processOpts() { // one by one for each library. supportsAdditionalPropertiesWithComposedSchema = true; } else if (libWebClient) { + supportingFiles.add(new SupportingFile("ExceptionProvider.mustache", invokerFolder, "ExceptionProvider.java")); forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON); // Composed schemas can have the 'additionalProperties' keyword, as specified in JSON schema. @@ -729,6 +730,7 @@ public void processOpts() { // one by one for each library. supportsAdditionalPropertiesWithComposedSchema = true; } else if (libRestClient) { + supportingFiles.add(new SupportingFile("ExceptionProvider.mustache", invokerFolder, "ExceptionProvider.java")); forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON); applyJakartaPackage(); diff --git a/modules/openapi-generator/src/main/resources/Java/ExceptionProvider.mustache b/modules/openapi-generator/src/main/resources/Java/ExceptionProvider.mustache new file mode 100644 index 000000000000..81ad9020e2f4 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/Java/ExceptionProvider.mustache @@ -0,0 +1,68 @@ +{{>licenseInfo}} + +package {{invokerPackage}}; + +import org.springframework.web.client.RestClientException; +import java.text.ParseException; + +/** + * Extension point for customizing exceptions thrown by the generated API client. + *
+ * The default implementation throws {@link RuntimeException}. To use custom exception + * types, implement this interface and pass the instance to + * {@link ApiClient#setExceptionProvider(ExceptionProvider)}. + *
+ *{@code
+ * apiClient.setExceptionProvider(new ExceptionProvider() {
+ * public RuntimeException bearerAuthException() {
+ * return new MyAuthException("No Bearer authentication configured!");
+ * }
+ * });
+ * }
+ */
+public interface ExceptionProvider {
+
+ /** Returns an exception indicating that no Bearer authentication is configured. */
+ default RuntimeException bearerAuthException() {
+ return new RuntimeException("No Bearer authentication configured!");
+ }
+
+ /** Returns an exception indicating that no HTTP basic authentication is configured. */
+ default RuntimeException httpBasicAuthException() {
+ return new RuntimeException("No HTTP basic authentication configured!");
+ }
+
+ /** Returns an exception indicating that no API key authentication is configured. */
+ default RuntimeException apiKeyAuthException() {
+ return new RuntimeException("No API key authentication configured!");
+ }
+
+ /** Returns an exception indicating that no OAuth2 authentication is configured. */
+ default RuntimeException oAuth2Exception() {
+ return new RuntimeException("No OAuth2 authentication configured!");
+ }
+
+ /** Wraps a date/time parse exception. */
+ default RuntimeException dateTimeException(ParseException e) {
+ return new RuntimeException(e);
+ }
+
+ /** Wraps a Jackson serialization/deserialization exception. */
+ default RuntimeException jacksonException(Exception e) {
+ return new RuntimeException(e);
+ }
+
+ /**
+ * Returns an exception indicating that the requested authentication scheme is not configured.
+ *
+ * @param authName the name of the authentication scheme that could not be found
+ * @return a {@link RestClientException} describing the missing authentication
+ */
+ default RestClientException undefinedAuthenticationException(String authName) {
+ return new RestClientException("Authentication undefined: " + authName);
+ }
+
+ /** The default {@link ExceptionProvider} instance. */
+ ExceptionProvider DEFAULT = new ExceptionProvider() {};
+
+}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/restclient/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/restclient/ApiClient.mustache
index 61dac36a2540..a30bf9d25b6e 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/restclient/ApiClient.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/restclient/ApiClient.mustache
@@ -149,6 +149,13 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
{{/useJackson3}}
protected Map{@code
+ * apiClient.setExceptionProvider(new ExceptionProvider() {
+ * public RuntimeException bearerAuthException() {
+ * return new MyAuthException("No Bearer authentication configured!");
+ * }
+ * });
+ * }
+ */
+public interface ExceptionProvider {
+
+ /** Returns an exception indicating that no Bearer authentication is configured. */
+ default RuntimeException bearerAuthException() {
+ return new RuntimeException("No Bearer authentication configured!");
+ }
+
+ /** Returns an exception indicating that no HTTP basic authentication is configured. */
+ default RuntimeException httpBasicAuthException() {
+ return new RuntimeException("No HTTP basic authentication configured!");
+ }
+
+ /** Returns an exception indicating that no API key authentication is configured. */
+ default RuntimeException apiKeyAuthException() {
+ return new RuntimeException("No API key authentication configured!");
+ }
+
+ /** Returns an exception indicating that no OAuth2 authentication is configured. */
+ default RuntimeException oAuth2Exception() {
+ return new RuntimeException("No OAuth2 authentication configured!");
+ }
+
+ /** Wraps a date/time parse exception. */
+ default RuntimeException dateTimeException(ParseException e) {
+ return new RuntimeException(e);
+ }
+
+ /** Wraps a Jackson serialization/deserialization exception. */
+ default RuntimeException jacksonException(Exception e) {
+ return new RuntimeException(e);
+ }
+
+ /**
+ * Returns an exception indicating that the requested authentication scheme is not configured.
+ *
+ * @param authName the name of the authentication scheme that could not be found
+ * @return a {@link RestClientException} describing the missing authentication
+ */
+ default RestClientException undefinedAuthenticationException(String authName) {
+ return new RestClientException("Authentication undefined: " + authName);
+ }
+
+ /** The default {@link ExceptionProvider} instance. */
+ ExceptionProvider DEFAULT = new ExceptionProvider() {};
+
+}
\ No newline at end of file
diff --git a/samples/client/others/java/restclient-enum-in-multipart/.openapi-generator/FILES b/samples/client/others/java/restclient-enum-in-multipart/.openapi-generator/FILES
index 1ce4cca21cde..b19d56bcdd98 100644
--- a/samples/client/others/java/restclient-enum-in-multipart/.openapi-generator/FILES
+++ b/samples/client/others/java/restclient-enum-in-multipart/.openapi-generator/FILES
@@ -19,6 +19,7 @@ pom.xml
settings.gradle
src/main/AndroidManifest.xml
src/main/java/org/openapitools/client/ApiClient.java
+src/main/java/org/openapitools/client/ExceptionProvider.java
src/main/java/org/openapitools/client/JavaTimeFormatter.java
src/main/java/org/openapitools/client/RFC3339DateFormat.java
src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java
diff --git a/samples/client/others/java/restclient-enum-in-multipart/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/others/java/restclient-enum-in-multipart/src/main/java/org/openapitools/client/ApiClient.java
index a2d36a8ca35d..295d81237d8f 100644
--- a/samples/client/others/java/restclient-enum-in-multipart/src/main/java/org/openapitools/client/ApiClient.java
+++ b/samples/client/others/java/restclient-enum-in-multipart/src/main/java/org/openapitools/client/ApiClient.java
@@ -97,6 +97,13 @@ protected String collectionToString(Collection> collection) {
protected final ObjectMapper mapper;
protected Map{@code
+ * apiClient.setExceptionProvider(new ExceptionProvider() {
+ * public RuntimeException bearerAuthException() {
+ * return new MyAuthException("No Bearer authentication configured!");
+ * }
+ * });
+ * }
+ */
+public interface ExceptionProvider {
+
+ /** Returns an exception indicating that no Bearer authentication is configured. */
+ default RuntimeException bearerAuthException() {
+ return new RuntimeException("No Bearer authentication configured!");
+ }
+
+ /** Returns an exception indicating that no HTTP basic authentication is configured. */
+ default RuntimeException httpBasicAuthException() {
+ return new RuntimeException("No HTTP basic authentication configured!");
+ }
+
+ /** Returns an exception indicating that no API key authentication is configured. */
+ default RuntimeException apiKeyAuthException() {
+ return new RuntimeException("No API key authentication configured!");
+ }
+
+ /** Returns an exception indicating that no OAuth2 authentication is configured. */
+ default RuntimeException oAuth2Exception() {
+ return new RuntimeException("No OAuth2 authentication configured!");
+ }
+
+ /** Wraps a date/time parse exception. */
+ default RuntimeException dateTimeException(ParseException e) {
+ return new RuntimeException(e);
+ }
+
+ /** Wraps a Jackson serialization/deserialization exception. */
+ default RuntimeException jacksonException(Exception e) {
+ return new RuntimeException(e);
+ }
+
+ /**
+ * Returns an exception indicating that the requested authentication scheme is not configured.
+ *
+ * @param authName the name of the authentication scheme that could not be found
+ * @return a {@link RestClientException} describing the missing authentication
+ */
+ default RestClientException undefinedAuthenticationException(String authName) {
+ return new RestClientException("Authentication undefined: " + authName);
+ }
+
+ /** The default {@link ExceptionProvider} instance. */
+ ExceptionProvider DEFAULT = new ExceptionProvider() {};
+
+}
\ No newline at end of file
diff --git a/samples/client/others/java/restclient-sealedInterface/.openapi-generator/FILES b/samples/client/others/java/restclient-sealedInterface/.openapi-generator/FILES
index 79e1f1f075fa..d11eb14c0d55 100644
--- a/samples/client/others/java/restclient-sealedInterface/.openapi-generator/FILES
+++ b/samples/client/others/java/restclient-sealedInterface/.openapi-generator/FILES
@@ -38,6 +38,7 @@ pom.xml
settings.gradle
src/main/AndroidManifest.xml
src/main/java/org/openapitools/client/ApiClient.java
+src/main/java/org/openapitools/client/ExceptionProvider.java
src/main/java/org/openapitools/client/JavaTimeFormatter.java
src/main/java/org/openapitools/client/RFC3339DateFormat.java
src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java
diff --git a/samples/client/others/java/restclient-sealedInterface/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/others/java/restclient-sealedInterface/src/main/java/org/openapitools/client/ApiClient.java
index 463913c837d0..0539f1b276f8 100644
--- a/samples/client/others/java/restclient-sealedInterface/src/main/java/org/openapitools/client/ApiClient.java
+++ b/samples/client/others/java/restclient-sealedInterface/src/main/java/org/openapitools/client/ApiClient.java
@@ -97,6 +97,13 @@ protected String collectionToString(Collection> collection) {
protected final ObjectMapper mapper;
protected Map{@code
+ * apiClient.setExceptionProvider(new ExceptionProvider() {
+ * public RuntimeException bearerAuthException() {
+ * return new MyAuthException("No Bearer authentication configured!");
+ * }
+ * });
+ * }
+ */
+public interface ExceptionProvider {
+
+ /** Returns an exception indicating that no Bearer authentication is configured. */
+ default RuntimeException bearerAuthException() {
+ return new RuntimeException("No Bearer authentication configured!");
+ }
+
+ /** Returns an exception indicating that no HTTP basic authentication is configured. */
+ default RuntimeException httpBasicAuthException() {
+ return new RuntimeException("No HTTP basic authentication configured!");
+ }
+
+ /** Returns an exception indicating that no API key authentication is configured. */
+ default RuntimeException apiKeyAuthException() {
+ return new RuntimeException("No API key authentication configured!");
+ }
+
+ /** Returns an exception indicating that no OAuth2 authentication is configured. */
+ default RuntimeException oAuth2Exception() {
+ return new RuntimeException("No OAuth2 authentication configured!");
+ }
+
+ /** Wraps a date/time parse exception. */
+ default RuntimeException dateTimeException(ParseException e) {
+ return new RuntimeException(e);
+ }
+
+ /** Wraps a Jackson serialization/deserialization exception. */
+ default RuntimeException jacksonException(Exception e) {
+ return new RuntimeException(e);
+ }
+
+ /**
+ * Returns an exception indicating that the requested authentication scheme is not configured.
+ *
+ * @param authName the name of the authentication scheme that could not be found
+ * @return a {@link RestClientException} describing the missing authentication
+ */
+ default RestClientException undefinedAuthenticationException(String authName) {
+ return new RestClientException("Authentication undefined: " + authName);
+ }
+
+ /** The default {@link ExceptionProvider} instance. */
+ ExceptionProvider DEFAULT = new ExceptionProvider() {};
+
+}
\ No newline at end of file
diff --git a/samples/client/others/java/restclient-useAbstractionForFiles/.openapi-generator/FILES b/samples/client/others/java/restclient-useAbstractionForFiles/.openapi-generator/FILES
index 9078c63e26ab..0cc5234c597b 100644
--- a/samples/client/others/java/restclient-useAbstractionForFiles/.openapi-generator/FILES
+++ b/samples/client/others/java/restclient-useAbstractionForFiles/.openapi-generator/FILES
@@ -16,6 +16,7 @@ pom.xml
settings.gradle
src/main/AndroidManifest.xml
src/main/java/org/openapitools/client/ApiClient.java
+src/main/java/org/openapitools/client/ExceptionProvider.java
src/main/java/org/openapitools/client/JavaTimeFormatter.java
src/main/java/org/openapitools/client/RFC3339DateFormat.java
src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java
diff --git a/samples/client/others/java/restclient-useAbstractionForFiles/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/others/java/restclient-useAbstractionForFiles/src/main/java/org/openapitools/client/ApiClient.java
index 24004f99b7f7..379106f2da15 100644
--- a/samples/client/others/java/restclient-useAbstractionForFiles/src/main/java/org/openapitools/client/ApiClient.java
+++ b/samples/client/others/java/restclient-useAbstractionForFiles/src/main/java/org/openapitools/client/ApiClient.java
@@ -97,6 +97,13 @@ protected String collectionToString(Collection> collection) {
protected final ObjectMapper mapper;
protected Map{@code
+ * apiClient.setExceptionProvider(new ExceptionProvider() {
+ * public RuntimeException bearerAuthException() {
+ * return new MyAuthException("No Bearer authentication configured!");
+ * }
+ * });
+ * }
+ */
+public interface ExceptionProvider {
+
+ /** Returns an exception indicating that no Bearer authentication is configured. */
+ default RuntimeException bearerAuthException() {
+ return new RuntimeException("No Bearer authentication configured!");
+ }
+
+ /** Returns an exception indicating that no HTTP basic authentication is configured. */
+ default RuntimeException httpBasicAuthException() {
+ return new RuntimeException("No HTTP basic authentication configured!");
+ }
+
+ /** Returns an exception indicating that no API key authentication is configured. */
+ default RuntimeException apiKeyAuthException() {
+ return new RuntimeException("No API key authentication configured!");
+ }
+
+ /** Returns an exception indicating that no OAuth2 authentication is configured. */
+ default RuntimeException oAuth2Exception() {
+ return new RuntimeException("No OAuth2 authentication configured!");
+ }
+
+ /** Wraps a date/time parse exception. */
+ default RuntimeException dateTimeException(ParseException e) {
+ return new RuntimeException(e);
+ }
+
+ /** Wraps a Jackson serialization/deserialization exception. */
+ default RuntimeException jacksonException(Exception e) {
+ return new RuntimeException(e);
+ }
+
+ /**
+ * Returns an exception indicating that the requested authentication scheme is not configured.
+ *
+ * @param authName the name of the authentication scheme that could not be found
+ * @return a {@link RestClientException} describing the missing authentication
+ */
+ default RestClientException undefinedAuthenticationException(String authName) {
+ return new RestClientException("Authentication undefined: " + authName);
+ }
+
+ /** The default {@link ExceptionProvider} instance. */
+ ExceptionProvider DEFAULT = new ExceptionProvider() {};
+
+}
\ No newline at end of file
diff --git a/samples/client/others/java/webclient-sealedInterface/.openapi-generator/FILES b/samples/client/others/java/webclient-sealedInterface/.openapi-generator/FILES
index 79e1f1f075fa..d11eb14c0d55 100644
--- a/samples/client/others/java/webclient-sealedInterface/.openapi-generator/FILES
+++ b/samples/client/others/java/webclient-sealedInterface/.openapi-generator/FILES
@@ -38,6 +38,7 @@ pom.xml
settings.gradle
src/main/AndroidManifest.xml
src/main/java/org/openapitools/client/ApiClient.java
+src/main/java/org/openapitools/client/ExceptionProvider.java
src/main/java/org/openapitools/client/JavaTimeFormatter.java
src/main/java/org/openapitools/client/RFC3339DateFormat.java
src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java
diff --git a/samples/client/others/java/webclient-sealedInterface/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/others/java/webclient-sealedInterface/src/main/java/org/openapitools/client/ApiClient.java
index 425d78b6670f..04c559f1ee7b 100644
--- a/samples/client/others/java/webclient-sealedInterface/src/main/java/org/openapitools/client/ApiClient.java
+++ b/samples/client/others/java/webclient-sealedInterface/src/main/java/org/openapitools/client/ApiClient.java
@@ -109,6 +109,13 @@ protected String collectionToString(Collection> collection) {
protected Map{@code
+ * apiClient.setExceptionProvider(new ExceptionProvider() {
+ * public RuntimeException bearerAuthException() {
+ * return new MyAuthException("No Bearer authentication configured!");
+ * }
+ * });
+ * }
+ */
+public interface ExceptionProvider {
+
+ /** Returns an exception indicating that no Bearer authentication is configured. */
+ default RuntimeException bearerAuthException() {
+ return new RuntimeException("No Bearer authentication configured!");
+ }
+
+ /** Returns an exception indicating that no HTTP basic authentication is configured. */
+ default RuntimeException httpBasicAuthException() {
+ return new RuntimeException("No HTTP basic authentication configured!");
+ }
+
+ /** Returns an exception indicating that no API key authentication is configured. */
+ default RuntimeException apiKeyAuthException() {
+ return new RuntimeException("No API key authentication configured!");
+ }
+
+ /** Returns an exception indicating that no OAuth2 authentication is configured. */
+ default RuntimeException oAuth2Exception() {
+ return new RuntimeException("No OAuth2 authentication configured!");
+ }
+
+ /** Wraps a date/time parse exception. */
+ default RuntimeException dateTimeException(ParseException e) {
+ return new RuntimeException(e);
+ }
+
+ /** Wraps a Jackson serialization/deserialization exception. */
+ default RuntimeException jacksonException(Exception e) {
+ return new RuntimeException(e);
+ }
+
+ /**
+ * Returns an exception indicating that the requested authentication scheme is not configured.
+ *
+ * @param authName the name of the authentication scheme that could not be found
+ * @return a {@link RestClientException} describing the missing authentication
+ */
+ default RestClientException undefinedAuthenticationException(String authName) {
+ return new RestClientException("Authentication undefined: " + authName);
+ }
+
+ /** The default {@link ExceptionProvider} instance. */
+ ExceptionProvider DEFAULT = new ExceptionProvider() {};
+
+}
\ No newline at end of file
diff --git a/samples/client/others/java/webclient-sealedInterface_3_1/.openapi-generator/FILES b/samples/client/others/java/webclient-sealedInterface_3_1/.openapi-generator/FILES
index 79e1f1f075fa..d11eb14c0d55 100644
--- a/samples/client/others/java/webclient-sealedInterface_3_1/.openapi-generator/FILES
+++ b/samples/client/others/java/webclient-sealedInterface_3_1/.openapi-generator/FILES
@@ -38,6 +38,7 @@ pom.xml
settings.gradle
src/main/AndroidManifest.xml
src/main/java/org/openapitools/client/ApiClient.java
+src/main/java/org/openapitools/client/ExceptionProvider.java
src/main/java/org/openapitools/client/JavaTimeFormatter.java
src/main/java/org/openapitools/client/RFC3339DateFormat.java
src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java
diff --git a/samples/client/others/java/webclient-sealedInterface_3_1/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/others/java/webclient-sealedInterface_3_1/src/main/java/org/openapitools/client/ApiClient.java
index 425d78b6670f..04c559f1ee7b 100644
--- a/samples/client/others/java/webclient-sealedInterface_3_1/src/main/java/org/openapitools/client/ApiClient.java
+++ b/samples/client/others/java/webclient-sealedInterface_3_1/src/main/java/org/openapitools/client/ApiClient.java
@@ -109,6 +109,13 @@ protected String collectionToString(Collection> collection) {
protected Map{@code
+ * apiClient.setExceptionProvider(new ExceptionProvider() {
+ * public RuntimeException bearerAuthException() {
+ * return new MyAuthException("No Bearer authentication configured!");
+ * }
+ * });
+ * }
+ */
+public interface ExceptionProvider {
+
+ /** Returns an exception indicating that no Bearer authentication is configured. */
+ default RuntimeException bearerAuthException() {
+ return new RuntimeException("No Bearer authentication configured!");
+ }
+
+ /** Returns an exception indicating that no HTTP basic authentication is configured. */
+ default RuntimeException httpBasicAuthException() {
+ return new RuntimeException("No HTTP basic authentication configured!");
+ }
+
+ /** Returns an exception indicating that no API key authentication is configured. */
+ default RuntimeException apiKeyAuthException() {
+ return new RuntimeException("No API key authentication configured!");
+ }
+
+ /** Returns an exception indicating that no OAuth2 authentication is configured. */
+ default RuntimeException oAuth2Exception() {
+ return new RuntimeException("No OAuth2 authentication configured!");
+ }
+
+ /** Wraps a date/time parse exception. */
+ default RuntimeException dateTimeException(ParseException e) {
+ return new RuntimeException(e);
+ }
+
+ /** Wraps a Jackson serialization/deserialization exception. */
+ default RuntimeException jacksonException(Exception e) {
+ return new RuntimeException(e);
+ }
+
+ /**
+ * Returns an exception indicating that the requested authentication scheme is not configured.
+ *
+ * @param authName the name of the authentication scheme that could not be found
+ * @return a {@link RestClientException} describing the missing authentication
+ */
+ default RestClientException undefinedAuthenticationException(String authName) {
+ return new RestClientException("Authentication undefined: " + authName);
+ }
+
+ /** The default {@link ExceptionProvider} instance. */
+ ExceptionProvider DEFAULT = new ExceptionProvider() {};
+
+}
\ No newline at end of file
diff --git a/samples/client/others/java/webclient-useAbstractionForFiles/.openapi-generator/FILES b/samples/client/others/java/webclient-useAbstractionForFiles/.openapi-generator/FILES
index 9078c63e26ab..0cc5234c597b 100644
--- a/samples/client/others/java/webclient-useAbstractionForFiles/.openapi-generator/FILES
+++ b/samples/client/others/java/webclient-useAbstractionForFiles/.openapi-generator/FILES
@@ -16,6 +16,7 @@ pom.xml
settings.gradle
src/main/AndroidManifest.xml
src/main/java/org/openapitools/client/ApiClient.java
+src/main/java/org/openapitools/client/ExceptionProvider.java
src/main/java/org/openapitools/client/JavaTimeFormatter.java
src/main/java/org/openapitools/client/RFC3339DateFormat.java
src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java
diff --git a/samples/client/others/java/webclient-useAbstractionForFiles/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/others/java/webclient-useAbstractionForFiles/src/main/java/org/openapitools/client/ApiClient.java
index 1fde9de1cf79..bb6d06a0a2f9 100644
--- a/samples/client/others/java/webclient-useAbstractionForFiles/src/main/java/org/openapitools/client/ApiClient.java
+++ b/samples/client/others/java/webclient-useAbstractionForFiles/src/main/java/org/openapitools/client/ApiClient.java
@@ -109,6 +109,13 @@ protected String collectionToString(Collection> collection) {
protected Map{@code
+ * apiClient.setExceptionProvider(new ExceptionProvider() {
+ * public RuntimeException bearerAuthException() {
+ * return new MyAuthException("No Bearer authentication configured!");
+ * }
+ * });
+ * }
+ */
+public interface ExceptionProvider {
+
+ /** Returns an exception indicating that no Bearer authentication is configured. */
+ default RuntimeException bearerAuthException() {
+ return new RuntimeException("No Bearer authentication configured!");
+ }
+
+ /** Returns an exception indicating that no HTTP basic authentication is configured. */
+ default RuntimeException httpBasicAuthException() {
+ return new RuntimeException("No HTTP basic authentication configured!");
+ }
+
+ /** Returns an exception indicating that no API key authentication is configured. */
+ default RuntimeException apiKeyAuthException() {
+ return new RuntimeException("No API key authentication configured!");
+ }
+
+ /** Returns an exception indicating that no OAuth2 authentication is configured. */
+ default RuntimeException oAuth2Exception() {
+ return new RuntimeException("No OAuth2 authentication configured!");
+ }
+
+ /** Wraps a date/time parse exception. */
+ default RuntimeException dateTimeException(ParseException e) {
+ return new RuntimeException(e);
+ }
+
+ /** Wraps a Jackson serialization/deserialization exception. */
+ default RuntimeException jacksonException(Exception e) {
+ return new RuntimeException(e);
+ }
+
+ /**
+ * Returns an exception indicating that the requested authentication scheme is not configured.
+ *
+ * @param authName the name of the authentication scheme that could not be found
+ * @return a {@link RestClientException} describing the missing authentication
+ */
+ default RestClientException undefinedAuthenticationException(String authName) {
+ return new RestClientException("Authentication undefined: " + authName);
+ }
+
+ /** The default {@link ExceptionProvider} instance. */
+ ExceptionProvider DEFAULT = new ExceptionProvider() {};
+
+}
\ No newline at end of file
diff --git a/samples/client/petstore/java/restclient-nullable-arrays/.openapi-generator/FILES b/samples/client/petstore/java/restclient-nullable-arrays/.openapi-generator/FILES
index eedafa945afd..1466503e3b79 100644
--- a/samples/client/petstore/java/restclient-nullable-arrays/.openapi-generator/FILES
+++ b/samples/client/petstore/java/restclient-nullable-arrays/.openapi-generator/FILES
@@ -17,6 +17,7 @@ pom.xml
settings.gradle
src/main/AndroidManifest.xml
src/main/java/org/openapitools/client/ApiClient.java
+src/main/java/org/openapitools/client/ExceptionProvider.java
src/main/java/org/openapitools/client/JavaTimeFormatter.java
src/main/java/org/openapitools/client/RFC3339DateFormat.java
src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java
diff --git a/samples/client/petstore/java/restclient-nullable-arrays/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/restclient-nullable-arrays/src/main/java/org/openapitools/client/ApiClient.java
index f70c16ca989a..ac65442c5556 100644
--- a/samples/client/petstore/java/restclient-nullable-arrays/src/main/java/org/openapitools/client/ApiClient.java
+++ b/samples/client/petstore/java/restclient-nullable-arrays/src/main/java/org/openapitools/client/ApiClient.java
@@ -97,6 +97,13 @@ protected String collectionToString(Collection> collection) {
protected final ObjectMapper mapper;
protected Map{@code
+ * apiClient.setExceptionProvider(new ExceptionProvider() {
+ * public RuntimeException bearerAuthException() {
+ * return new MyAuthException("No Bearer authentication configured!");
+ * }
+ * });
+ * }
+ */
+public interface ExceptionProvider {
+
+ /** Returns an exception indicating that no Bearer authentication is configured. */
+ default RuntimeException bearerAuthException() {
+ return new RuntimeException("No Bearer authentication configured!");
+ }
+
+ /** Returns an exception indicating that no HTTP basic authentication is configured. */
+ default RuntimeException httpBasicAuthException() {
+ return new RuntimeException("No HTTP basic authentication configured!");
+ }
+
+ /** Returns an exception indicating that no API key authentication is configured. */
+ default RuntimeException apiKeyAuthException() {
+ return new RuntimeException("No API key authentication configured!");
+ }
+
+ /** Returns an exception indicating that no OAuth2 authentication is configured. */
+ default RuntimeException oAuth2Exception() {
+ return new RuntimeException("No OAuth2 authentication configured!");
+ }
+
+ /** Wraps a date/time parse exception. */
+ default RuntimeException dateTimeException(ParseException e) {
+ return new RuntimeException(e);
+ }
+
+ /** Wraps a Jackson serialization/deserialization exception. */
+ default RuntimeException jacksonException(Exception e) {
+ return new RuntimeException(e);
+ }
+
+ /**
+ * Returns an exception indicating that the requested authentication scheme is not configured.
+ *
+ * @param authName the name of the authentication scheme that could not be found
+ * @return a {@link RestClientException} describing the missing authentication
+ */
+ default RestClientException undefinedAuthenticationException(String authName) {
+ return new RestClientException("Authentication undefined: " + authName);
+ }
+
+ /** The default {@link ExceptionProvider} instance. */
+ ExceptionProvider DEFAULT = new ExceptionProvider() {};
+
+}
\ No newline at end of file
diff --git a/samples/client/petstore/java/restclient-springBoot4-jackson2/.openapi-generator/FILES b/samples/client/petstore/java/restclient-springBoot4-jackson2/.openapi-generator/FILES
index 345da529f8a1..94cc6f4676ac 100644
--- a/samples/client/petstore/java/restclient-springBoot4-jackson2/.openapi-generator/FILES
+++ b/samples/client/petstore/java/restclient-springBoot4-jackson2/.openapi-generator/FILES
@@ -19,6 +19,7 @@ pom.xml
settings.gradle
src/main/AndroidManifest.xml
src/main/java/org/openapitools/client/ApiClient.java
+src/main/java/org/openapitools/client/ExceptionProvider.java
src/main/java/org/openapitools/client/JavaTimeFormatter.java
src/main/java/org/openapitools/client/RFC3339DateFormat.java
src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java
diff --git a/samples/client/petstore/java/restclient-springBoot4-jackson2/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/restclient-springBoot4-jackson2/src/main/java/org/openapitools/client/ApiClient.java
index ee5a0f33e77d..da6ffdc29d6b 100644
--- a/samples/client/petstore/java/restclient-springBoot4-jackson2/src/main/java/org/openapitools/client/ApiClient.java
+++ b/samples/client/petstore/java/restclient-springBoot4-jackson2/src/main/java/org/openapitools/client/ApiClient.java
@@ -98,6 +98,13 @@ protected String collectionToString(Collection> collection) {
protected final ObjectMapper mapper;
protected Map{@code
+ * apiClient.setExceptionProvider(new ExceptionProvider() {
+ * public RuntimeException bearerAuthException() {
+ * return new MyAuthException("No Bearer authentication configured!");
+ * }
+ * });
+ * }
+ */
+public interface ExceptionProvider {
+
+ /** Returns an exception indicating that no Bearer authentication is configured. */
+ default RuntimeException bearerAuthException() {
+ return new RuntimeException("No Bearer authentication configured!");
+ }
+
+ /** Returns an exception indicating that no HTTP basic authentication is configured. */
+ default RuntimeException httpBasicAuthException() {
+ return new RuntimeException("No HTTP basic authentication configured!");
+ }
+
+ /** Returns an exception indicating that no API key authentication is configured. */
+ default RuntimeException apiKeyAuthException() {
+ return new RuntimeException("No API key authentication configured!");
+ }
+
+ /** Returns an exception indicating that no OAuth2 authentication is configured. */
+ default RuntimeException oAuth2Exception() {
+ return new RuntimeException("No OAuth2 authentication configured!");
+ }
+
+ /** Wraps a date/time parse exception. */
+ default RuntimeException dateTimeException(ParseException e) {
+ return new RuntimeException(e);
+ }
+
+ /** Wraps a Jackson serialization/deserialization exception. */
+ default RuntimeException jacksonException(Exception e) {
+ return new RuntimeException(e);
+ }
+
+ /**
+ * Returns an exception indicating that the requested authentication scheme is not configured.
+ *
+ * @param authName the name of the authentication scheme that could not be found
+ * @return a {@link RestClientException} describing the missing authentication
+ */
+ default RestClientException undefinedAuthenticationException(String authName) {
+ return new RestClientException("Authentication undefined: " + authName);
+ }
+
+ /** The default {@link ExceptionProvider} instance. */
+ ExceptionProvider DEFAULT = new ExceptionProvider() {};
+
+}
\ No newline at end of file
diff --git a/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/.openapi-generator/FILES b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/.openapi-generator/FILES
index 399326b1defb..0360f20c7340 100644
--- a/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/.openapi-generator/FILES
+++ b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/.openapi-generator/FILES
@@ -17,6 +17,7 @@ pom.xml
settings.gradle
src/main/AndroidManifest.xml
src/main/java/org/openapitools/client/ApiClient.java
+src/main/java/org/openapitools/client/ExceptionProvider.java
src/main/java/org/openapitools/client/JavaTimeFormatter.java
src/main/java/org/openapitools/client/RFC3339DateFormat.java
src/main/java/org/openapitools/client/ServerConfiguration.java
diff --git a/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/ApiClient.java
index 4ca008ddb39b..b746bc9ca3e8 100644
--- a/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/ApiClient.java
+++ b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/ApiClient.java
@@ -96,6 +96,13 @@ protected String collectionToString(Collection> collection) {
protected final JsonMapper mapper;
protected Map{@code
+ * apiClient.setExceptionProvider(new ExceptionProvider() {
+ * public RuntimeException bearerAuthException() {
+ * return new MyAuthException("No Bearer authentication configured!");
+ * }
+ * });
+ * }
+ */
+public interface ExceptionProvider {
+
+ /** Returns an exception indicating that no Bearer authentication is configured. */
+ default RuntimeException bearerAuthException() {
+ return new RuntimeException("No Bearer authentication configured!");
+ }
+
+ /** Returns an exception indicating that no HTTP basic authentication is configured. */
+ default RuntimeException httpBasicAuthException() {
+ return new RuntimeException("No HTTP basic authentication configured!");
+ }
+
+ /** Returns an exception indicating that no API key authentication is configured. */
+ default RuntimeException apiKeyAuthException() {
+ return new RuntimeException("No API key authentication configured!");
+ }
+
+ /** Returns an exception indicating that no OAuth2 authentication is configured. */
+ default RuntimeException oAuth2Exception() {
+ return new RuntimeException("No OAuth2 authentication configured!");
+ }
+
+ /** Wraps a date/time parse exception. */
+ default RuntimeException dateTimeException(ParseException e) {
+ return new RuntimeException(e);
+ }
+
+ /** Wraps a Jackson serialization/deserialization exception. */
+ default RuntimeException jacksonException(Exception e) {
+ return new RuntimeException(e);
+ }
+
+ /**
+ * Returns an exception indicating that the requested authentication scheme is not configured.
+ *
+ * @param authName the name of the authentication scheme that could not be found
+ * @return a {@link RestClientException} describing the missing authentication
+ */
+ default RestClientException undefinedAuthenticationException(String authName) {
+ return new RestClientException("Authentication undefined: " + authName);
+ }
+
+ /** The default {@link ExceptionProvider} instance. */
+ ExceptionProvider DEFAULT = new ExceptionProvider() {};
+
+}
\ No newline at end of file
diff --git a/samples/client/petstore/java/restclient-springBoot4-jackson3/.openapi-generator/FILES b/samples/client/petstore/java/restclient-springBoot4-jackson3/.openapi-generator/FILES
index 389fe62eaae9..9676ccd030da 100644
--- a/samples/client/petstore/java/restclient-springBoot4-jackson3/.openapi-generator/FILES
+++ b/samples/client/petstore/java/restclient-springBoot4-jackson3/.openapi-generator/FILES
@@ -19,6 +19,7 @@ pom.xml
settings.gradle
src/main/AndroidManifest.xml
src/main/java/org/openapitools/client/ApiClient.java
+src/main/java/org/openapitools/client/ExceptionProvider.java
src/main/java/org/openapitools/client/JavaTimeFormatter.java
src/main/java/org/openapitools/client/RFC3339DateFormat.java
src/main/java/org/openapitools/client/ServerConfiguration.java
diff --git a/samples/client/petstore/java/restclient-springBoot4-jackson3/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/restclient-springBoot4-jackson3/src/main/java/org/openapitools/client/ApiClient.java
index b521b16abd32..ff214cba8b61 100644
--- a/samples/client/petstore/java/restclient-springBoot4-jackson3/src/main/java/org/openapitools/client/ApiClient.java
+++ b/samples/client/petstore/java/restclient-springBoot4-jackson3/src/main/java/org/openapitools/client/ApiClient.java
@@ -97,6 +97,13 @@ protected String collectionToString(Collection> collection) {
protected final JsonMapper mapper;
protected Map{@code
+ * apiClient.setExceptionProvider(new ExceptionProvider() {
+ * public RuntimeException bearerAuthException() {
+ * return new MyAuthException("No Bearer authentication configured!");
+ * }
+ * });
+ * }
+ */
+public interface ExceptionProvider {
+
+ /** Returns an exception indicating that no Bearer authentication is configured. */
+ default RuntimeException bearerAuthException() {
+ return new RuntimeException("No Bearer authentication configured!");
+ }
+
+ /** Returns an exception indicating that no HTTP basic authentication is configured. */
+ default RuntimeException httpBasicAuthException() {
+ return new RuntimeException("No HTTP basic authentication configured!");
+ }
+
+ /** Returns an exception indicating that no API key authentication is configured. */
+ default RuntimeException apiKeyAuthException() {
+ return new RuntimeException("No API key authentication configured!");
+ }
+
+ /** Returns an exception indicating that no OAuth2 authentication is configured. */
+ default RuntimeException oAuth2Exception() {
+ return new RuntimeException("No OAuth2 authentication configured!");
+ }
+
+ /** Wraps a date/time parse exception. */
+ default RuntimeException dateTimeException(ParseException e) {
+ return new RuntimeException(e);
+ }
+
+ /** Wraps a Jackson serialization/deserialization exception. */
+ default RuntimeException jacksonException(Exception e) {
+ return new RuntimeException(e);
+ }
+
+ /**
+ * Returns an exception indicating that the requested authentication scheme is not configured.
+ *
+ * @param authName the name of the authentication scheme that could not be found
+ * @return a {@link RestClientException} describing the missing authentication
+ */
+ default RestClientException undefinedAuthenticationException(String authName) {
+ return new RestClientException("Authentication undefined: " + authName);
+ }
+
+ /** The default {@link ExceptionProvider} instance. */
+ ExceptionProvider DEFAULT = new ExceptionProvider() {};
+
+}
\ No newline at end of file
diff --git a/samples/client/petstore/java/restclient-swagger2/.openapi-generator/FILES b/samples/client/petstore/java/restclient-swagger2/.openapi-generator/FILES
index 555600856098..d7a6d76bf38f 100644
--- a/samples/client/petstore/java/restclient-swagger2/.openapi-generator/FILES
+++ b/samples/client/petstore/java/restclient-swagger2/.openapi-generator/FILES
@@ -72,6 +72,7 @@ pom.xml
settings.gradle
src/main/AndroidManifest.xml
src/main/java/org/openapitools/client/ApiClient.java
+src/main/java/org/openapitools/client/ExceptionProvider.java
src/main/java/org/openapitools/client/JavaTimeFormatter.java
src/main/java/org/openapitools/client/RFC3339DateFormat.java
src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java
diff --git a/samples/client/petstore/java/restclient-swagger2/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/restclient-swagger2/src/main/java/org/openapitools/client/ApiClient.java
index f773ee249976..ba9fc446b26a 100644
--- a/samples/client/petstore/java/restclient-swagger2/src/main/java/org/openapitools/client/ApiClient.java
+++ b/samples/client/petstore/java/restclient-swagger2/src/main/java/org/openapitools/client/ApiClient.java
@@ -141,6 +141,13 @@ protected String collectionToString(Collection> collection) {
protected final ObjectMapper mapper;
protected Map{@code
+ * apiClient.setExceptionProvider(new ExceptionProvider() {
+ * public RuntimeException bearerAuthException() {
+ * return new MyAuthException("No Bearer authentication configured!");
+ * }
+ * });
+ * }
+ */
+public interface ExceptionProvider {
+
+ /** Returns an exception indicating that no Bearer authentication is configured. */
+ default RuntimeException bearerAuthException() {
+ return new RuntimeException("No Bearer authentication configured!");
+ }
+
+ /** Returns an exception indicating that no HTTP basic authentication is configured. */
+ default RuntimeException httpBasicAuthException() {
+ return new RuntimeException("No HTTP basic authentication configured!");
+ }
+
+ /** Returns an exception indicating that no API key authentication is configured. */
+ default RuntimeException apiKeyAuthException() {
+ return new RuntimeException("No API key authentication configured!");
+ }
+
+ /** Returns an exception indicating that no OAuth2 authentication is configured. */
+ default RuntimeException oAuth2Exception() {
+ return new RuntimeException("No OAuth2 authentication configured!");
+ }
+
+ /** Wraps a date/time parse exception. */
+ default RuntimeException dateTimeException(ParseException e) {
+ return new RuntimeException(e);
+ }
+
+ /** Wraps a Jackson serialization/deserialization exception. */
+ default RuntimeException jacksonException(Exception e) {
+ return new RuntimeException(e);
+ }
+
+ /**
+ * Returns an exception indicating that the requested authentication scheme is not configured.
+ *
+ * @param authName the name of the authentication scheme that could not be found
+ * @return a {@link RestClientException} describing the missing authentication
+ */
+ default RestClientException undefinedAuthenticationException(String authName) {
+ return new RestClientException("Authentication undefined: " + authName);
+ }
+
+ /** The default {@link ExceptionProvider} instance. */
+ ExceptionProvider DEFAULT = new ExceptionProvider() {};
+
+}
\ No newline at end of file
diff --git a/samples/client/petstore/java/restclient-useSingleRequestParameter-static/.openapi-generator/FILES b/samples/client/petstore/java/restclient-useSingleRequestParameter-static/.openapi-generator/FILES
index 555600856098..d7a6d76bf38f 100644
--- a/samples/client/petstore/java/restclient-useSingleRequestParameter-static/.openapi-generator/FILES
+++ b/samples/client/petstore/java/restclient-useSingleRequestParameter-static/.openapi-generator/FILES
@@ -72,6 +72,7 @@ pom.xml
settings.gradle
src/main/AndroidManifest.xml
src/main/java/org/openapitools/client/ApiClient.java
+src/main/java/org/openapitools/client/ExceptionProvider.java
src/main/java/org/openapitools/client/JavaTimeFormatter.java
src/main/java/org/openapitools/client/RFC3339DateFormat.java
src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java
diff --git a/samples/client/petstore/java/restclient-useSingleRequestParameter-static/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/restclient-useSingleRequestParameter-static/src/main/java/org/openapitools/client/ApiClient.java
index f773ee249976..ba9fc446b26a 100644
--- a/samples/client/petstore/java/restclient-useSingleRequestParameter-static/src/main/java/org/openapitools/client/ApiClient.java
+++ b/samples/client/petstore/java/restclient-useSingleRequestParameter-static/src/main/java/org/openapitools/client/ApiClient.java
@@ -141,6 +141,13 @@ protected String collectionToString(Collection> collection) {
protected final ObjectMapper mapper;
protected Map{@code
+ * apiClient.setExceptionProvider(new ExceptionProvider() {
+ * public RuntimeException bearerAuthException() {
+ * return new MyAuthException("No Bearer authentication configured!");
+ * }
+ * });
+ * }
+ */
+public interface ExceptionProvider {
+
+ /** Returns an exception indicating that no Bearer authentication is configured. */
+ default RuntimeException bearerAuthException() {
+ return new RuntimeException("No Bearer authentication configured!");
+ }
+
+ /** Returns an exception indicating that no HTTP basic authentication is configured. */
+ default RuntimeException httpBasicAuthException() {
+ return new RuntimeException("No HTTP basic authentication configured!");
+ }
+
+ /** Returns an exception indicating that no API key authentication is configured. */
+ default RuntimeException apiKeyAuthException() {
+ return new RuntimeException("No API key authentication configured!");
+ }
+
+ /** Returns an exception indicating that no OAuth2 authentication is configured. */
+ default RuntimeException oAuth2Exception() {
+ return new RuntimeException("No OAuth2 authentication configured!");
+ }
+
+ /** Wraps a date/time parse exception. */
+ default RuntimeException dateTimeException(ParseException e) {
+ return new RuntimeException(e);
+ }
+
+ /** Wraps a Jackson serialization/deserialization exception. */
+ default RuntimeException jacksonException(Exception e) {
+ return new RuntimeException(e);
+ }
+
+ /**
+ * Returns an exception indicating that the requested authentication scheme is not configured.
+ *
+ * @param authName the name of the authentication scheme that could not be found
+ * @return a {@link RestClientException} describing the missing authentication
+ */
+ default RestClientException undefinedAuthenticationException(String authName) {
+ return new RestClientException("Authentication undefined: " + authName);
+ }
+
+ /** The default {@link ExceptionProvider} instance. */
+ ExceptionProvider DEFAULT = new ExceptionProvider() {};
+
+}
\ No newline at end of file
diff --git a/samples/client/petstore/java/restclient-useSingleRequestParameter/.openapi-generator/FILES b/samples/client/petstore/java/restclient-useSingleRequestParameter/.openapi-generator/FILES
index 555600856098..d7a6d76bf38f 100644
--- a/samples/client/petstore/java/restclient-useSingleRequestParameter/.openapi-generator/FILES
+++ b/samples/client/petstore/java/restclient-useSingleRequestParameter/.openapi-generator/FILES
@@ -72,6 +72,7 @@ pom.xml
settings.gradle
src/main/AndroidManifest.xml
src/main/java/org/openapitools/client/ApiClient.java
+src/main/java/org/openapitools/client/ExceptionProvider.java
src/main/java/org/openapitools/client/JavaTimeFormatter.java
src/main/java/org/openapitools/client/RFC3339DateFormat.java
src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java
diff --git a/samples/client/petstore/java/restclient-useSingleRequestParameter/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/restclient-useSingleRequestParameter/src/main/java/org/openapitools/client/ApiClient.java
index f773ee249976..ba9fc446b26a 100644
--- a/samples/client/petstore/java/restclient-useSingleRequestParameter/src/main/java/org/openapitools/client/ApiClient.java
+++ b/samples/client/petstore/java/restclient-useSingleRequestParameter/src/main/java/org/openapitools/client/ApiClient.java
@@ -141,6 +141,13 @@ protected String collectionToString(Collection> collection) {
protected final ObjectMapper mapper;
protected Map{@code
+ * apiClient.setExceptionProvider(new ExceptionProvider() {
+ * public RuntimeException bearerAuthException() {
+ * return new MyAuthException("No Bearer authentication configured!");
+ * }
+ * });
+ * }
+ */
+public interface ExceptionProvider {
+
+ /** Returns an exception indicating that no Bearer authentication is configured. */
+ default RuntimeException bearerAuthException() {
+ return new RuntimeException("No Bearer authentication configured!");
+ }
+
+ /** Returns an exception indicating that no HTTP basic authentication is configured. */
+ default RuntimeException httpBasicAuthException() {
+ return new RuntimeException("No HTTP basic authentication configured!");
+ }
+
+ /** Returns an exception indicating that no API key authentication is configured. */
+ default RuntimeException apiKeyAuthException() {
+ return new RuntimeException("No API key authentication configured!");
+ }
+
+ /** Returns an exception indicating that no OAuth2 authentication is configured. */
+ default RuntimeException oAuth2Exception() {
+ return new RuntimeException("No OAuth2 authentication configured!");
+ }
+
+ /** Wraps a date/time parse exception. */
+ default RuntimeException dateTimeException(ParseException e) {
+ return new RuntimeException(e);
+ }
+
+ /** Wraps a Jackson serialization/deserialization exception. */
+ default RuntimeException jacksonException(Exception e) {
+ return new RuntimeException(e);
+ }
+
+ /**
+ * Returns an exception indicating that the requested authentication scheme is not configured.
+ *
+ * @param authName the name of the authentication scheme that could not be found
+ * @return a {@link RestClientException} describing the missing authentication
+ */
+ default RestClientException undefinedAuthenticationException(String authName) {
+ return new RestClientException("Authentication undefined: " + authName);
+ }
+
+ /** The default {@link ExceptionProvider} instance. */
+ ExceptionProvider DEFAULT = new ExceptionProvider() {};
+
+}
\ No newline at end of file
diff --git a/samples/client/petstore/java/restclient/.openapi-generator/FILES b/samples/client/petstore/java/restclient/.openapi-generator/FILES
index 555600856098..d7a6d76bf38f 100644
--- a/samples/client/petstore/java/restclient/.openapi-generator/FILES
+++ b/samples/client/petstore/java/restclient/.openapi-generator/FILES
@@ -72,6 +72,7 @@ pom.xml
settings.gradle
src/main/AndroidManifest.xml
src/main/java/org/openapitools/client/ApiClient.java
+src/main/java/org/openapitools/client/ExceptionProvider.java
src/main/java/org/openapitools/client/JavaTimeFormatter.java
src/main/java/org/openapitools/client/RFC3339DateFormat.java
src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java
diff --git a/samples/client/petstore/java/restclient/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/restclient/src/main/java/org/openapitools/client/ApiClient.java
index f773ee249976..ba9fc446b26a 100644
--- a/samples/client/petstore/java/restclient/src/main/java/org/openapitools/client/ApiClient.java
+++ b/samples/client/petstore/java/restclient/src/main/java/org/openapitools/client/ApiClient.java
@@ -141,6 +141,13 @@ protected String collectionToString(Collection> collection) {
protected final ObjectMapper mapper;
protected Map{@code
+ * apiClient.setExceptionProvider(new ExceptionProvider() {
+ * public RuntimeException bearerAuthException() {
+ * return new MyAuthException("No Bearer authentication configured!");
+ * }
+ * });
+ * }
+ */
+public interface ExceptionProvider {
+
+ /** Returns an exception indicating that no Bearer authentication is configured. */
+ default RuntimeException bearerAuthException() {
+ return new RuntimeException("No Bearer authentication configured!");
+ }
+
+ /** Returns an exception indicating that no HTTP basic authentication is configured. */
+ default RuntimeException httpBasicAuthException() {
+ return new RuntimeException("No HTTP basic authentication configured!");
+ }
+
+ /** Returns an exception indicating that no API key authentication is configured. */
+ default RuntimeException apiKeyAuthException() {
+ return new RuntimeException("No API key authentication configured!");
+ }
+
+ /** Returns an exception indicating that no OAuth2 authentication is configured. */
+ default RuntimeException oAuth2Exception() {
+ return new RuntimeException("No OAuth2 authentication configured!");
+ }
+
+ /** Wraps a date/time parse exception. */
+ default RuntimeException dateTimeException(ParseException e) {
+ return new RuntimeException(e);
+ }
+
+ /** Wraps a Jackson serialization/deserialization exception. */
+ default RuntimeException jacksonException(Exception e) {
+ return new RuntimeException(e);
+ }
+
+ /**
+ * Returns an exception indicating that the requested authentication scheme is not configured.
+ *
+ * @param authName the name of the authentication scheme that could not be found
+ * @return a {@link RestClientException} describing the missing authentication
+ */
+ default RestClientException undefinedAuthenticationException(String authName) {
+ return new RestClientException("Authentication undefined: " + authName);
+ }
+
+ /** The default {@link ExceptionProvider} instance. */
+ ExceptionProvider DEFAULT = new ExceptionProvider() {};
+
+}
\ No newline at end of file
diff --git a/samples/client/petstore/java/webclient-jakarta/.openapi-generator/FILES b/samples/client/petstore/java/webclient-jakarta/.openapi-generator/FILES
index 555600856098..d7a6d76bf38f 100644
--- a/samples/client/petstore/java/webclient-jakarta/.openapi-generator/FILES
+++ b/samples/client/petstore/java/webclient-jakarta/.openapi-generator/FILES
@@ -72,6 +72,7 @@ pom.xml
settings.gradle
src/main/AndroidManifest.xml
src/main/java/org/openapitools/client/ApiClient.java
+src/main/java/org/openapitools/client/ExceptionProvider.java
src/main/java/org/openapitools/client/JavaTimeFormatter.java
src/main/java/org/openapitools/client/RFC3339DateFormat.java
src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java
diff --git a/samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/ApiClient.java
index 9490dcf43075..ed3bfb7bc562 100644
--- a/samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/ApiClient.java
+++ b/samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/ApiClient.java
@@ -110,6 +110,13 @@ protected String collectionToString(Collection> collection) {
protected Map{@code
+ * apiClient.setExceptionProvider(new ExceptionProvider() {
+ * public RuntimeException bearerAuthException() {
+ * return new MyAuthException("No Bearer authentication configured!");
+ * }
+ * });
+ * }
+ */
+public interface ExceptionProvider {
+
+ /** Returns an exception indicating that no Bearer authentication is configured. */
+ default RuntimeException bearerAuthException() {
+ return new RuntimeException("No Bearer authentication configured!");
+ }
+
+ /** Returns an exception indicating that no HTTP basic authentication is configured. */
+ default RuntimeException httpBasicAuthException() {
+ return new RuntimeException("No HTTP basic authentication configured!");
+ }
+
+ /** Returns an exception indicating that no API key authentication is configured. */
+ default RuntimeException apiKeyAuthException() {
+ return new RuntimeException("No API key authentication configured!");
+ }
+
+ /** Returns an exception indicating that no OAuth2 authentication is configured. */
+ default RuntimeException oAuth2Exception() {
+ return new RuntimeException("No OAuth2 authentication configured!");
+ }
+
+ /** Wraps a date/time parse exception. */
+ default RuntimeException dateTimeException(ParseException e) {
+ return new RuntimeException(e);
+ }
+
+ /** Wraps a Jackson serialization/deserialization exception. */
+ default RuntimeException jacksonException(Exception e) {
+ return new RuntimeException(e);
+ }
+
+ /**
+ * Returns an exception indicating that the requested authentication scheme is not configured.
+ *
+ * @param authName the name of the authentication scheme that could not be found
+ * @return a {@link RestClientException} describing the missing authentication
+ */
+ default RestClientException undefinedAuthenticationException(String authName) {
+ return new RestClientException("Authentication undefined: " + authName);
+ }
+
+ /** The default {@link ExceptionProvider} instance. */
+ ExceptionProvider DEFAULT = new ExceptionProvider() {};
+
+}
\ No newline at end of file
diff --git a/samples/client/petstore/java/webclient-nullable-arrays/.openapi-generator/FILES b/samples/client/petstore/java/webclient-nullable-arrays/.openapi-generator/FILES
index eedafa945afd..1466503e3b79 100644
--- a/samples/client/petstore/java/webclient-nullable-arrays/.openapi-generator/FILES
+++ b/samples/client/petstore/java/webclient-nullable-arrays/.openapi-generator/FILES
@@ -17,6 +17,7 @@ pom.xml
settings.gradle
src/main/AndroidManifest.xml
src/main/java/org/openapitools/client/ApiClient.java
+src/main/java/org/openapitools/client/ExceptionProvider.java
src/main/java/org/openapitools/client/JavaTimeFormatter.java
src/main/java/org/openapitools/client/RFC3339DateFormat.java
src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java
diff --git a/samples/client/petstore/java/webclient-nullable-arrays/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/webclient-nullable-arrays/src/main/java/org/openapitools/client/ApiClient.java
index 41bcc01749e7..2e3977a90497 100644
--- a/samples/client/petstore/java/webclient-nullable-arrays/src/main/java/org/openapitools/client/ApiClient.java
+++ b/samples/client/petstore/java/webclient-nullable-arrays/src/main/java/org/openapitools/client/ApiClient.java
@@ -109,6 +109,13 @@ protected String collectionToString(Collection> collection) {
protected Map{@code
+ * apiClient.setExceptionProvider(new ExceptionProvider() {
+ * public RuntimeException bearerAuthException() {
+ * return new MyAuthException("No Bearer authentication configured!");
+ * }
+ * });
+ * }
+ */
+public interface ExceptionProvider {
+
+ /** Returns an exception indicating that no Bearer authentication is configured. */
+ default RuntimeException bearerAuthException() {
+ return new RuntimeException("No Bearer authentication configured!");
+ }
+
+ /** Returns an exception indicating that no HTTP basic authentication is configured. */
+ default RuntimeException httpBasicAuthException() {
+ return new RuntimeException("No HTTP basic authentication configured!");
+ }
+
+ /** Returns an exception indicating that no API key authentication is configured. */
+ default RuntimeException apiKeyAuthException() {
+ return new RuntimeException("No API key authentication configured!");
+ }
+
+ /** Returns an exception indicating that no OAuth2 authentication is configured. */
+ default RuntimeException oAuth2Exception() {
+ return new RuntimeException("No OAuth2 authentication configured!");
+ }
+
+ /** Wraps a date/time parse exception. */
+ default RuntimeException dateTimeException(ParseException e) {
+ return new RuntimeException(e);
+ }
+
+ /** Wraps a Jackson serialization/deserialization exception. */
+ default RuntimeException jacksonException(Exception e) {
+ return new RuntimeException(e);
+ }
+
+ /**
+ * Returns an exception indicating that the requested authentication scheme is not configured.
+ *
+ * @param authName the name of the authentication scheme that could not be found
+ * @return a {@link RestClientException} describing the missing authentication
+ */
+ default RestClientException undefinedAuthenticationException(String authName) {
+ return new RestClientException("Authentication undefined: " + authName);
+ }
+
+ /** The default {@link ExceptionProvider} instance. */
+ ExceptionProvider DEFAULT = new ExceptionProvider() {};
+
+}
\ No newline at end of file
diff --git a/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/.openapi-generator/FILES b/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/.openapi-generator/FILES
index d59cb3fdbb35..fa0830b314a4 100644
--- a/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/.openapi-generator/FILES
+++ b/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/.openapi-generator/FILES
@@ -17,6 +17,7 @@ pom.xml
settings.gradle
src/main/AndroidManifest.xml
src/main/java/org/openapitools/client/ApiClient.java
+src/main/java/org/openapitools/client/ExceptionProvider.java
src/main/java/org/openapitools/client/JavaTimeFormatter.java
src/main/java/org/openapitools/client/RFC3339DateFormat.java
src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java
diff --git a/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/ApiClient.java
index de847d3ee896..b30e50883e2f 100644
--- a/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/ApiClient.java
+++ b/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/ApiClient.java
@@ -107,6 +107,13 @@ protected String collectionToString(Collection> collection) {
protected Map{@code
+ * apiClient.setExceptionProvider(new ExceptionProvider() {
+ * public RuntimeException bearerAuthException() {
+ * return new MyAuthException("No Bearer authentication configured!");
+ * }
+ * });
+ * }
+ */
+public interface ExceptionProvider {
+
+ /** Returns an exception indicating that no Bearer authentication is configured. */
+ default RuntimeException bearerAuthException() {
+ return new RuntimeException("No Bearer authentication configured!");
+ }
+
+ /** Returns an exception indicating that no HTTP basic authentication is configured. */
+ default RuntimeException httpBasicAuthException() {
+ return new RuntimeException("No HTTP basic authentication configured!");
+ }
+
+ /** Returns an exception indicating that no API key authentication is configured. */
+ default RuntimeException apiKeyAuthException() {
+ return new RuntimeException("No API key authentication configured!");
+ }
+
+ /** Returns an exception indicating that no OAuth2 authentication is configured. */
+ default RuntimeException oAuth2Exception() {
+ return new RuntimeException("No OAuth2 authentication configured!");
+ }
+
+ /** Wraps a date/time parse exception. */
+ default RuntimeException dateTimeException(ParseException e) {
+ return new RuntimeException(e);
+ }
+
+ /** Wraps a Jackson serialization/deserialization exception. */
+ default RuntimeException jacksonException(Exception e) {
+ return new RuntimeException(e);
+ }
+
+ /**
+ * Returns an exception indicating that the requested authentication scheme is not configured.
+ *
+ * @param authName the name of the authentication scheme that could not be found
+ * @return a {@link RestClientException} describing the missing authentication
+ */
+ default RestClientException undefinedAuthenticationException(String authName) {
+ return new RestClientException("Authentication undefined: " + authName);
+ }
+
+ /** The default {@link ExceptionProvider} instance. */
+ ExceptionProvider DEFAULT = new ExceptionProvider() {};
+
+}
\ No newline at end of file
diff --git a/samples/client/petstore/java/webclient-springBoot4-jackson3/.openapi-generator/FILES b/samples/client/petstore/java/webclient-springBoot4-jackson3/.openapi-generator/FILES
index 345da529f8a1..94cc6f4676ac 100644
--- a/samples/client/petstore/java/webclient-springBoot4-jackson3/.openapi-generator/FILES
+++ b/samples/client/petstore/java/webclient-springBoot4-jackson3/.openapi-generator/FILES
@@ -19,6 +19,7 @@ pom.xml
settings.gradle
src/main/AndroidManifest.xml
src/main/java/org/openapitools/client/ApiClient.java
+src/main/java/org/openapitools/client/ExceptionProvider.java
src/main/java/org/openapitools/client/JavaTimeFormatter.java
src/main/java/org/openapitools/client/RFC3339DateFormat.java
src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java
diff --git a/samples/client/petstore/java/webclient-springBoot4-jackson3/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/webclient-springBoot4-jackson3/src/main/java/org/openapitools/client/ApiClient.java
index 2d4f52eae16b..dbda70badc9d 100644
--- a/samples/client/petstore/java/webclient-springBoot4-jackson3/src/main/java/org/openapitools/client/ApiClient.java
+++ b/samples/client/petstore/java/webclient-springBoot4-jackson3/src/main/java/org/openapitools/client/ApiClient.java
@@ -108,6 +108,13 @@ protected String collectionToString(Collection> collection) {
protected Map{@code
+ * apiClient.setExceptionProvider(new ExceptionProvider() {
+ * public RuntimeException bearerAuthException() {
+ * return new MyAuthException("No Bearer authentication configured!");
+ * }
+ * });
+ * }
+ */
+public interface ExceptionProvider {
+
+ /** Returns an exception indicating that no Bearer authentication is configured. */
+ default RuntimeException bearerAuthException() {
+ return new RuntimeException("No Bearer authentication configured!");
+ }
+
+ /** Returns an exception indicating that no HTTP basic authentication is configured. */
+ default RuntimeException httpBasicAuthException() {
+ return new RuntimeException("No HTTP basic authentication configured!");
+ }
+
+ /** Returns an exception indicating that no API key authentication is configured. */
+ default RuntimeException apiKeyAuthException() {
+ return new RuntimeException("No API key authentication configured!");
+ }
+
+ /** Returns an exception indicating that no OAuth2 authentication is configured. */
+ default RuntimeException oAuth2Exception() {
+ return new RuntimeException("No OAuth2 authentication configured!");
+ }
+
+ /** Wraps a date/time parse exception. */
+ default RuntimeException dateTimeException(ParseException e) {
+ return new RuntimeException(e);
+ }
+
+ /** Wraps a Jackson serialization/deserialization exception. */
+ default RuntimeException jacksonException(Exception e) {
+ return new RuntimeException(e);
+ }
+
+ /**
+ * Returns an exception indicating that the requested authentication scheme is not configured.
+ *
+ * @param authName the name of the authentication scheme that could not be found
+ * @return a {@link RestClientException} describing the missing authentication
+ */
+ default RestClientException undefinedAuthenticationException(String authName) {
+ return new RestClientException("Authentication undefined: " + authName);
+ }
+
+ /** The default {@link ExceptionProvider} instance. */
+ ExceptionProvider DEFAULT = new ExceptionProvider() {};
+
+}
\ No newline at end of file
diff --git a/samples/client/petstore/java/webclient-swagger2/.openapi-generator/FILES b/samples/client/petstore/java/webclient-swagger2/.openapi-generator/FILES
index 555600856098..d7a6d76bf38f 100644
--- a/samples/client/petstore/java/webclient-swagger2/.openapi-generator/FILES
+++ b/samples/client/petstore/java/webclient-swagger2/.openapi-generator/FILES
@@ -72,6 +72,7 @@ pom.xml
settings.gradle
src/main/AndroidManifest.xml
src/main/java/org/openapitools/client/ApiClient.java
+src/main/java/org/openapitools/client/ExceptionProvider.java
src/main/java/org/openapitools/client/JavaTimeFormatter.java
src/main/java/org/openapitools/client/RFC3339DateFormat.java
src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java
diff --git a/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/ApiClient.java
index f7f65e1c23d4..d81de1a1b88d 100644
--- a/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/ApiClient.java
+++ b/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/ApiClient.java
@@ -110,6 +110,13 @@ protected String collectionToString(Collection> collection) {
protected Map{@code
+ * apiClient.setExceptionProvider(new ExceptionProvider() {
+ * public RuntimeException bearerAuthException() {
+ * return new MyAuthException("No Bearer authentication configured!");
+ * }
+ * });
+ * }
+ */
+public interface ExceptionProvider {
+
+ /** Returns an exception indicating that no Bearer authentication is configured. */
+ default RuntimeException bearerAuthException() {
+ return new RuntimeException("No Bearer authentication configured!");
+ }
+
+ /** Returns an exception indicating that no HTTP basic authentication is configured. */
+ default RuntimeException httpBasicAuthException() {
+ return new RuntimeException("No HTTP basic authentication configured!");
+ }
+
+ /** Returns an exception indicating that no API key authentication is configured. */
+ default RuntimeException apiKeyAuthException() {
+ return new RuntimeException("No API key authentication configured!");
+ }
+
+ /** Returns an exception indicating that no OAuth2 authentication is configured. */
+ default RuntimeException oAuth2Exception() {
+ return new RuntimeException("No OAuth2 authentication configured!");
+ }
+
+ /** Wraps a date/time parse exception. */
+ default RuntimeException dateTimeException(ParseException e) {
+ return new RuntimeException(e);
+ }
+
+ /** Wraps a Jackson serialization/deserialization exception. */
+ default RuntimeException jacksonException(Exception e) {
+ return new RuntimeException(e);
+ }
+
+ /**
+ * Returns an exception indicating that the requested authentication scheme is not configured.
+ *
+ * @param authName the name of the authentication scheme that could not be found
+ * @return a {@link RestClientException} describing the missing authentication
+ */
+ default RestClientException undefinedAuthenticationException(String authName) {
+ return new RestClientException("Authentication undefined: " + authName);
+ }
+
+ /** The default {@link ExceptionProvider} instance. */
+ ExceptionProvider DEFAULT = new ExceptionProvider() {};
+
+}
\ No newline at end of file
diff --git a/samples/client/petstore/java/webclient-useSingleRequestParameter/.openapi-generator/FILES b/samples/client/petstore/java/webclient-useSingleRequestParameter/.openapi-generator/FILES
index 555600856098..d7a6d76bf38f 100644
--- a/samples/client/petstore/java/webclient-useSingleRequestParameter/.openapi-generator/FILES
+++ b/samples/client/petstore/java/webclient-useSingleRequestParameter/.openapi-generator/FILES
@@ -72,6 +72,7 @@ pom.xml
settings.gradle
src/main/AndroidManifest.xml
src/main/java/org/openapitools/client/ApiClient.java
+src/main/java/org/openapitools/client/ExceptionProvider.java
src/main/java/org/openapitools/client/JavaTimeFormatter.java
src/main/java/org/openapitools/client/RFC3339DateFormat.java
src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java
diff --git a/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/ApiClient.java
index f7f65e1c23d4..d81de1a1b88d 100644
--- a/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/ApiClient.java
+++ b/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/ApiClient.java
@@ -110,6 +110,13 @@ protected String collectionToString(Collection> collection) {
protected Map{@code
+ * apiClient.setExceptionProvider(new ExceptionProvider() {
+ * public RuntimeException bearerAuthException() {
+ * return new MyAuthException("No Bearer authentication configured!");
+ * }
+ * });
+ * }
+ */
+public interface ExceptionProvider {
+
+ /** Returns an exception indicating that no Bearer authentication is configured. */
+ default RuntimeException bearerAuthException() {
+ return new RuntimeException("No Bearer authentication configured!");
+ }
+
+ /** Returns an exception indicating that no HTTP basic authentication is configured. */
+ default RuntimeException httpBasicAuthException() {
+ return new RuntimeException("No HTTP basic authentication configured!");
+ }
+
+ /** Returns an exception indicating that no API key authentication is configured. */
+ default RuntimeException apiKeyAuthException() {
+ return new RuntimeException("No API key authentication configured!");
+ }
+
+ /** Returns an exception indicating that no OAuth2 authentication is configured. */
+ default RuntimeException oAuth2Exception() {
+ return new RuntimeException("No OAuth2 authentication configured!");
+ }
+
+ /** Wraps a date/time parse exception. */
+ default RuntimeException dateTimeException(ParseException e) {
+ return new RuntimeException(e);
+ }
+
+ /** Wraps a Jackson serialization/deserialization exception. */
+ default RuntimeException jacksonException(Exception e) {
+ return new RuntimeException(e);
+ }
+
+ /**
+ * Returns an exception indicating that the requested authentication scheme is not configured.
+ *
+ * @param authName the name of the authentication scheme that could not be found
+ * @return a {@link RestClientException} describing the missing authentication
+ */
+ default RestClientException undefinedAuthenticationException(String authName) {
+ return new RestClientException("Authentication undefined: " + authName);
+ }
+
+ /** The default {@link ExceptionProvider} instance. */
+ ExceptionProvider DEFAULT = new ExceptionProvider() {};
+
+}
\ No newline at end of file
diff --git a/samples/client/petstore/java/webclient/.openapi-generator/FILES b/samples/client/petstore/java/webclient/.openapi-generator/FILES
index 555600856098..d7a6d76bf38f 100644
--- a/samples/client/petstore/java/webclient/.openapi-generator/FILES
+++ b/samples/client/petstore/java/webclient/.openapi-generator/FILES
@@ -72,6 +72,7 @@ pom.xml
settings.gradle
src/main/AndroidManifest.xml
src/main/java/org/openapitools/client/ApiClient.java
+src/main/java/org/openapitools/client/ExceptionProvider.java
src/main/java/org/openapitools/client/JavaTimeFormatter.java
src/main/java/org/openapitools/client/RFC3339DateFormat.java
src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java
diff --git a/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/ApiClient.java
index f7f65e1c23d4..d81de1a1b88d 100644
--- a/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/ApiClient.java
+++ b/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/ApiClient.java
@@ -110,6 +110,13 @@ protected String collectionToString(Collection> collection) {
protected Map{@code
+ * apiClient.setExceptionProvider(new ExceptionProvider() {
+ * public RuntimeException bearerAuthException() {
+ * return new MyAuthException("No Bearer authentication configured!");
+ * }
+ * });
+ * }
+ */
+public interface ExceptionProvider {
+
+ /** Returns an exception indicating that no Bearer authentication is configured. */
+ default RuntimeException bearerAuthException() {
+ return new RuntimeException("No Bearer authentication configured!");
+ }
+
+ /** Returns an exception indicating that no HTTP basic authentication is configured. */
+ default RuntimeException httpBasicAuthException() {
+ return new RuntimeException("No HTTP basic authentication configured!");
+ }
+
+ /** Returns an exception indicating that no API key authentication is configured. */
+ default RuntimeException apiKeyAuthException() {
+ return new RuntimeException("No API key authentication configured!");
+ }
+
+ /** Returns an exception indicating that no OAuth2 authentication is configured. */
+ default RuntimeException oAuth2Exception() {
+ return new RuntimeException("No OAuth2 authentication configured!");
+ }
+
+ /** Wraps a date/time parse exception. */
+ default RuntimeException dateTimeException(ParseException e) {
+ return new RuntimeException(e);
+ }
+
+ /** Wraps a Jackson serialization/deserialization exception. */
+ default RuntimeException jacksonException(Exception e) {
+ return new RuntimeException(e);
+ }
+
+ /**
+ * Returns an exception indicating that the requested authentication scheme is not configured.
+ *
+ * @param authName the name of the authentication scheme that could not be found
+ * @return a {@link RestClientException} describing the missing authentication
+ */
+ default RestClientException undefinedAuthenticationException(String authName) {
+ return new RestClientException("Authentication undefined: " + authName);
+ }
+
+ /** The default {@link ExceptionProvider} instance. */
+ ExceptionProvider DEFAULT = new ExceptionProvider() {};
+
+}
\ No newline at end of file