CAMEL-10164: swagger component for making rest calls with swagger schema validation and facade to actual HTTP client in use
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/ec680ad7 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/ec680ad7 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/ec680ad7 Branch: refs/heads/master Commit: ec680ad73a73e918852a1a8e217eddd74a9f7791 Parents: 9e80df0 Author: Claus Ibsen <[email protected]> Authored: Thu Aug 25 12:17:27 2016 +0200 Committer: Claus Ibsen <[email protected]> Committed: Fri Aug 26 16:53:31 2016 +0200 ---------------------------------------------------------------------- camel-core/src/main/docs/rest-component.adoc | 5 ++++- .../camel/component/rest/RestApiEndpoint.java | 2 +- .../apache/camel/component/rest/RestEndpoint.java | 3 +++ .../springboot/RestComponentConfiguration.java | 4 ++-- .../services/org/apache/camel/rest/swagger | 18 ------------------ .../services/org/apache/camel/restapi/swagger | 18 ++++++++++++++++++ 6 files changed, 28 insertions(+), 22 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/ec680ad7/camel-core/src/main/docs/rest-component.adoc ---------------------------------------------------------------------- diff --git a/camel-core/src/main/docs/rest-component.adoc b/camel-core/src/main/docs/rest-component.adoc index adf5128..fca18a8 100644 --- a/camel-core/src/main/docs/rest-component.adoc +++ b/camel-core/src/main/docs/rest-component.adoc @@ -38,7 +38,7 @@ The REST component supports 3 options which are listed below. // component options: END // endpoint options: START -The REST component supports 14 endpoint options which are listed below: +The REST component supports 17 endpoint options which are listed below: {% raw %} [width="100%",cols="2,1,1m,1m,5",options="header"] @@ -56,6 +56,9 @@ The REST component supports 14 endpoint options which are listed below: | description | consumer | | String | Human description to document this REST service | routeId | consumer | | String | Name of the route this REST services creates | exceptionHandler | consumer (advanced) | | ExceptionHandler | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this options is not in use. By default the consumer will deal with exceptions that will be logged at WARN/ERROR level and ignored. +| apiDoc | producer | | String | The swagger api doc resource to use. The resource is loaded from classpath by default and must be in JSon format. +| host | producer | | String | Host and port of HTTP service to use (override host in swagger schema) +| queryParameters | producer | | String | Query parameters for the HTTP service to call | exchangePattern | advanced | InOnly | ExchangePattern | Sets the default exchange pattern when creating an exchange. | synchronous | advanced | false | boolean | Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported). |======================================================================= http://git-wip-us.apache.org/repos/asf/camel/blob/ec680ad7/camel-core/src/main/java/org/apache/camel/component/rest/RestApiEndpoint.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/component/rest/RestApiEndpoint.java b/camel-core/src/main/java/org/apache/camel/component/rest/RestApiEndpoint.java index 935bc25..d71414c 100644 --- a/camel-core/src/main/java/org/apache/camel/component/rest/RestApiEndpoint.java +++ b/camel-core/src/main/java/org/apache/camel/component/rest/RestApiEndpoint.java @@ -45,7 +45,7 @@ import org.apache.camel.util.ObjectHelper; public class RestApiEndpoint extends DefaultEndpoint { public static final String DEFAULT_API_COMPONENT_NAME = "swagger"; - public static final String RESOURCE_PATH = "META-INF/services/org/apache/camel/rest/"; + public static final String RESOURCE_PATH = "META-INF/services/org/apache/camel/restapi/"; @UriPath @Metadata(required = "true") http://git-wip-us.apache.org/repos/asf/camel/blob/ec680ad7/camel-core/src/main/java/org/apache/camel/component/rest/RestEndpoint.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/component/rest/RestEndpoint.java b/camel-core/src/main/java/org/apache/camel/component/rest/RestEndpoint.java index 911b8cb..00ed667 100644 --- a/camel-core/src/main/java/org/apache/camel/component/rest/RestEndpoint.java +++ b/camel-core/src/main/java/org/apache/camel/component/rest/RestEndpoint.java @@ -42,6 +42,9 @@ import org.apache.camel.util.ObjectHelper; @UriEndpoint(scheme = "rest", title = "REST", syntax = "rest:method:path:uriTemplate", label = "core,rest", lenientProperties = true) public class RestEndpoint extends DefaultEndpoint { + public static final String DEFAULT_API_COMPONENT_NAME = "swagger"; + public static final String RESOURCE_PATH = "META-INF/services/org/apache/camel/rest/"; + @UriPath(label = "common", enums = "get,post,put,delete,patch,head,trace,connect,options") @Metadata(required = "true") private String method; @UriPath(label = "common") @Metadata(required = "true") http://git-wip-us.apache.org/repos/asf/camel/blob/ec680ad7/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/rest/springboot/RestComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/rest/springboot/RestComponentConfiguration.java b/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/rest/springboot/RestComponentConfiguration.java index caf73cf..f7c37d1 100644 --- a/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/rest/springboot/RestComponentConfiguration.java +++ b/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/rest/springboot/RestComponentConfiguration.java @@ -19,8 +19,8 @@ package org.apache.camel.component.rest.springboot; import org.springframework.boot.context.properties.ConfigurationProperties; /** - * The rest component is used for hosting REST services which has been defined - * using the rest-dsl in Camel. + * The rest component is used for either hosting REST services (consumer) or + * calling external REST services (producer). * * Generated by camel-package-maven-plugin - do not edit this file! */ http://git-wip-us.apache.org/repos/asf/camel/blob/ec680ad7/components/camel-swagger-java/src/main/resources/META-INF/services/org/apache/camel/rest/swagger ---------------------------------------------------------------------- diff --git a/components/camel-swagger-java/src/main/resources/META-INF/services/org/apache/camel/rest/swagger b/components/camel-swagger-java/src/main/resources/META-INF/services/org/apache/camel/rest/swagger deleted file mode 100755 index 999809c..0000000 --- a/components/camel-swagger-java/src/main/resources/META-INF/services/org/apache/camel/rest/swagger +++ /dev/null @@ -1,18 +0,0 @@ -# -# 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. -# - -class=org.apache.camel.swagger.SwaggerRestApiProcessorFactory http://git-wip-us.apache.org/repos/asf/camel/blob/ec680ad7/components/camel-swagger-java/src/main/resources/META-INF/services/org/apache/camel/restapi/swagger ---------------------------------------------------------------------- diff --git a/components/camel-swagger-java/src/main/resources/META-INF/services/org/apache/camel/restapi/swagger b/components/camel-swagger-java/src/main/resources/META-INF/services/org/apache/camel/restapi/swagger new file mode 100755 index 0000000..999809c --- /dev/null +++ b/components/camel-swagger-java/src/main/resources/META-INF/services/org/apache/camel/restapi/swagger @@ -0,0 +1,18 @@ +# +# 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. +# + +class=org.apache.camel.swagger.SwaggerRestApiProcessorFactory
