This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch openapi3 in repository https://gitbox.apache.org/repos/asf/camel.git
commit 493c1e5d4babc0c172c796559257ce664a6b93fe Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Thu Feb 29 10:19:26 2024 +0100 CAMEL-20488: Drop support for old swagger v2 spec (openapi v2) --- .../org/apache/camel/catalog/components/rest-openapi.json | 2 +- .../src/main/java/org/apache/camel/openapi/BeanConfig.java | 2 +- .../apache/camel/component/rest/openapi/rest-openapi.json | 2 +- .../camel/component/rest/openapi/RestOpenApiEndpoint.java | 9 ++++----- .../camel/component/rest/openapi/RestOpenApiProducer.java | 14 ++++++++++---- .../camel/builder/component/ComponentsBuilderFactory.java | 3 +-- .../component/dsl/RestOpenapiComponentBuilderFactory.java | 6 ++---- .../src/generated/resources/metadata.json | 2 +- .../endpoint/dsl/RestOpenApiEndpointBuilderFactory.java | 2 +- 9 files changed, 22 insertions(+), 20 deletions(-) diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/rest-openapi.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/rest-openapi.json index ef8b4fcc110..3393cc929be 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/rest-openapi.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/rest-openapi.json @@ -39,7 +39,7 @@ "properties": { "specificationUri": { "index": 0, "kind": "path", "displayName": "Specification Uri", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.net.URI", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "openapi.json", "description": "Path to the OpenApi specification file. The scheme, host base path are taken from this specification, but these can be overridden with properties on the component or endpoint level. If not [...] "operationId": { "index": 1, "kind": "path", "displayName": "Operation Id", "group": "producer", "label": "producer", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "ID of the operation from the OpenApi specification." }, - "basePath": { "index": 2, "kind": "parameter", "displayName": "Base Path", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "API basePath, for example \/v2. Default is unset, if set overrides the value present in OpenApi specification and in the component configuration." }, + "basePath": { "index": 2, "kind": "parameter", "displayName": "Base Path", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "API basePath, for example \/v3. Default is unset, if set overrides the value present in OpenApi specification and in the component configuration." }, "componentName": { "index": 3, "kind": "parameter", "displayName": "Component Name", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Name of the Camel component that will perform the requests. The component must be present in Camel registry and it must implement RestProducerFactory service provider interface. If not set CLASSPATH is searched for sin [...] "consumes": { "index": 4, "kind": "parameter", "displayName": "Consumes", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "What payload type this component capable of consuming. Could be one type, like application\/json or multiple types as application\/json, application\/xml; q=0.5 according to the RFC7231. This equates to the value of Accept HTTP h [...] "host": { "index": 5, "kind": "parameter", "displayName": "Host", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Scheme hostname and port to direct the HTTP requests to in the form of https:\/\/hostname:port. Can be configured at the endpoint, component or in the corresponding REST configuration in the Camel Context. If you give this component a na [...] diff --git a/components/camel-openapi-java/src/main/java/org/apache/camel/openapi/BeanConfig.java b/components/camel-openapi-java/src/main/java/org/apache/camel/openapi/BeanConfig.java index be00b572c8b..2198c683e43 100644 --- a/components/camel-openapi-java/src/main/java/org/apache/camel/openapi/BeanConfig.java +++ b/components/camel-openapi-java/src/main/java/org/apache/camel/openapi/BeanConfig.java @@ -32,7 +32,7 @@ public class BeanConfig { String[] schemes; String title; - Version version = new Version("3.0.1"); + Version version = OPENAPI_VERSION_30; String licenseUrl; String license; diff --git a/components/camel-rest-openapi/src/generated/resources/META-INF/org/apache/camel/component/rest/openapi/rest-openapi.json b/components/camel-rest-openapi/src/generated/resources/META-INF/org/apache/camel/component/rest/openapi/rest-openapi.json index ef8b4fcc110..3393cc929be 100644 --- a/components/camel-rest-openapi/src/generated/resources/META-INF/org/apache/camel/component/rest/openapi/rest-openapi.json +++ b/components/camel-rest-openapi/src/generated/resources/META-INF/org/apache/camel/component/rest/openapi/rest-openapi.json @@ -39,7 +39,7 @@ "properties": { "specificationUri": { "index": 0, "kind": "path", "displayName": "Specification Uri", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.net.URI", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "openapi.json", "description": "Path to the OpenApi specification file. The scheme, host base path are taken from this specification, but these can be overridden with properties on the component or endpoint level. If not [...] "operationId": { "index": 1, "kind": "path", "displayName": "Operation Id", "group": "producer", "label": "producer", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "ID of the operation from the OpenApi specification." }, - "basePath": { "index": 2, "kind": "parameter", "displayName": "Base Path", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "API basePath, for example \/v2. Default is unset, if set overrides the value present in OpenApi specification and in the component configuration." }, + "basePath": { "index": 2, "kind": "parameter", "displayName": "Base Path", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "API basePath, for example \/v3. Default is unset, if set overrides the value present in OpenApi specification and in the component configuration." }, "componentName": { "index": 3, "kind": "parameter", "displayName": "Component Name", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Name of the Camel component that will perform the requests. The component must be present in Camel registry and it must implement RestProducerFactory service provider interface. If not set CLASSPATH is searched for sin [...] "consumes": { "index": 4, "kind": "parameter", "displayName": "Consumes", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "What payload type this component capable of consuming. Could be one type, like application\/json or multiple types as application\/json, application\/xml; q=0.5 according to the RFC7231. This equates to the value of Accept HTTP h [...] "host": { "index": 5, "kind": "parameter", "displayName": "Host", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Scheme hostname and port to direct the HTTP requests to in the form of https:\/\/hostname:port. Can be configured at the endpoint, component or in the corresponding REST configuration in the Camel Context. If you give this component a na [...] diff --git a/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiEndpoint.java b/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiEndpoint.java index b121f6712d5..f7916a278d5 100644 --- a/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiEndpoint.java +++ b/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiEndpoint.java @@ -72,6 +72,7 @@ import org.apache.camel.spi.UriPath; import org.apache.camel.support.CamelContextHelper; import org.apache.camel.support.DefaultEndpoint; import org.apache.camel.support.ResourceHelper; +import org.apache.camel.util.FileUtil; import org.apache.camel.util.ObjectHelper; import org.apache.camel.util.StringHelper; import org.apache.camel.util.UnsafeUriCharactersEncoder; @@ -100,8 +101,7 @@ public final class RestOpenApiEndpoint extends DefaultEndpoint { */ Map<String, Object> parameters = Collections.emptyMap(); - @UriParam( - description = "API basePath, for example \"`/v2`\". Default is unset, if set overrides the value present in" + @UriParam(description = "API basePath, for example \"`/v3`\". Default is unset, if set overrides the value present in" + " OpenApi specification and in the component configuration.", defaultValue = "", label = "producer") private String basePath; @@ -113,8 +113,7 @@ public final class RestOpenApiEndpoint extends DefaultEndpoint { label = "producer") private String componentName; - @UriParam( - description = "What payload type this component capable of consuming. Could be one type, like `application/json`" + @UriParam(description = "What payload type this component capable of consuming. Could be one type, like `application/json`" + " or multiple types as `application/json, application/xml; q=0.5` according to the RFC7231. This equates" + " to the value of `Accept` HTTP header. If set overrides any value found in the OpenApi specification and." + " in the component configuration", @@ -828,7 +827,7 @@ public final class RestOpenApiEndpoint extends DefaultEndpoint { "The given OpenApi specification could not be loaded from `" + uri + "`.", e); } finally { if (tmpFileToDelete != null) { - tmpFileToDelete.delete(); + FileUtil.deleteFile(tmpFileToDelete); } } diff --git a/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiProducer.java b/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiProducer.java index 40d6e7208d4..647cd5986f5 100644 --- a/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiProducer.java +++ b/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiProducer.java @@ -46,10 +46,16 @@ public class RestOpenApiProducer extends DelegateAsyncProcessor implements Async } if (requestValidator != null) { - Set<String> validationErrors = requestValidator.validate(exchange); - if (!validationErrors.isEmpty()) { - RestOpenApiValidationException exception = new RestOpenApiValidationException(validationErrors); - exchange.setException(exception); + try { + Set<String> validationErrors = requestValidator.validate(exchange); + if (!validationErrors.isEmpty()) { + RestOpenApiValidationException exception = new RestOpenApiValidationException(validationErrors); + exchange.setException(exception); + callback.done(true); + return true; + } + } catch (Exception e) { + exchange.setException(e); callback.done(true); return true; } diff --git a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/ComponentsBuilderFactory.java b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/ComponentsBuilderFactory.java index a5ad77f680d..cdb54a68559 100644 --- a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/ComponentsBuilderFactory.java +++ b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/ComponentsBuilderFactory.java @@ -3497,8 +3497,7 @@ public interface ComponentsBuilderFactory { } /** * REST OpenApi (camel-rest-openapi) - * Configure REST producers based on an OpenAPI specification document - * delegating to a component implementing the RestProducerFactory interface. + * To call REST services using OpenAPI specification as contract. * * Category: rest,api * Since: 3.1 diff --git a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/RestOpenapiComponentBuilderFactory.java b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/RestOpenapiComponentBuilderFactory.java index bba0bf4e7b9..710861be507 100644 --- a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/RestOpenapiComponentBuilderFactory.java +++ b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/RestOpenapiComponentBuilderFactory.java @@ -23,8 +23,7 @@ import org.apache.camel.builder.component.ComponentBuilder; import org.apache.camel.component.rest.openapi.RestOpenApiComponent; /** - * Configure REST producers based on an OpenAPI specification document - * delegating to a component implementing the RestProducerFactory interface. + * To call REST services using OpenAPI specification as contract. * * Generated by camel-package-maven-plugin - do not edit this file! */ @@ -33,8 +32,7 @@ public interface RestOpenapiComponentBuilderFactory { /** * REST OpenApi (camel-rest-openapi) - * Configure REST producers based on an OpenAPI specification document - * delegating to a component implementing the RestProducerFactory interface. + * To call REST services using OpenAPI specification as contract. * * Category: rest,api * Since: 3.1 diff --git a/dsl/camel-componentdsl/src/generated/resources/metadata.json b/dsl/camel-componentdsl/src/generated/resources/metadata.json index 1c04c4eef87..b49d9f0b998 100644 --- a/dsl/camel-componentdsl/src/generated/resources/metadata.json +++ b/dsl/camel-componentdsl/src/generated/resources/metadata.json @@ -6016,7 +6016,7 @@ "kind": "component", "name": "rest-openapi", "title": "REST OpenApi", - "description": "Configure REST producers based on an OpenAPI specification document delegating to a component implementing the RestProducerFactory interface.", + "description": "To call REST services using OpenAPI specification as contract.", "deprecated": false, "firstVersion": "3.1.0", "label": "rest,api", diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/RestOpenApiEndpointBuilderFactory.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/RestOpenApiEndpointBuilderFactory.java index d3568ea1644..4a64b8a2b84 100644 --- a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/RestOpenApiEndpointBuilderFactory.java +++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/RestOpenApiEndpointBuilderFactory.java @@ -45,7 +45,7 @@ public interface RestOpenApiEndpointBuilderFactory { return (AdvancedRestOpenApiEndpointBuilder) this; } /** - * API basePath, for example /v2. Default is unset, if set overrides the + * API basePath, for example /v3. Default is unset, if set overrides the * value present in OpenApi specification and in the component * configuration. *