This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch openapi2 in repository https://gitbox.apache.org/repos/asf/camel.git
commit 00b95c8a944b25fbcf0fe474aed57e2881c85064 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Sun Mar 24 13:45:49 2024 +0100 CAMEL-20557: Rest DSL to use openapi spec directly --- .../rest/openapi/RestOpenApiEndpoint.java | 11 ++------ .../rest/openapi/RestOpenApiProcessor.java | 33 ++++++++++++++++++++++ 2 files changed, 36 insertions(+), 8 deletions(-) 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 1fd6f314adc..4e54d21cd7f 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 @@ -195,14 +195,9 @@ public final class RestOpenApiEndpoint extends DefaultEndpoint { @Override public Consumer createConsumer(final Processor processor) throws Exception { - final CamelContext camelContext = getCamelContext(); - final OpenAPI openapiDoc = loadSpecificationFrom(camelContext, specificationUri); - String path = determineBasePath(openapiDoc); - - // TODO: processor should use OpenAPI to detect which operations exists, and map to direct:xx - // TODO: validate on|poff - - return createConsumerFor(path, processor); + OpenAPI doc = loadSpecificationFrom(getCamelContext(), specificationUri); + String path = determineBasePath(doc); + return createConsumerFor(path, new RestOpenApiProcessor(doc, path, processor)); } protected Consumer createConsumerFor(String basePath, Processor processor) throws Exception { diff --git a/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiProcessor.java b/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiProcessor.java new file mode 100644 index 00000000000..737f14c2643 --- /dev/null +++ b/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiProcessor.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.rest.openapi; + +import io.swagger.v3.oas.models.OpenAPI; +import org.apache.camel.Processor; +import org.apache.camel.support.processor.DelegateAsyncProcessor; + +public class RestOpenApiProcessor extends DelegateAsyncProcessor { + + private final OpenAPI openAPI; + private final String basePath; + + public RestOpenApiProcessor(OpenAPI openAPI, String basePath, Processor processor) { + super(processor); + this.basePath = basePath; + this.openAPI = openAPI; + } +}