[camel] branch master updated: Improve docs a bit for camel-rest-swagger when loading swagger spec from https. Also fixed so cathcing wider exception will fallback to let swagger attempt to load.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[camel] branch master updated: Improve docs a bit for camel-rest-swagger when loading swagger spec from https. Also fixed so cathcing wider exception will fallback to let swagger attempt to load.

davsclaus-2
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new 9a0628c  Improve docs a bit for camel-rest-swagger when loading swagger spec from https. Also fixed so cathcing wider exception will fallback to let swagger attempt to load.
9a0628c is described below

commit 9a0628caf438ed5bd5f688392e97c8e3d8a9ed46
Author: Claus Ibsen <[hidden email]>
AuthorDate: Tue Feb 12 09:43:24 2019 +0100

    Improve docs a bit for camel-rest-swagger when loading swagger spec from https. Also fixed so cathcing wider exception will fallback to let swagger attempt to load.
---
 .../src/main/docs/rest-swagger-component.adoc            | 12 ++++++------
 .../component/rest/swagger/RestSwaggerComponent.java     | 12 ++++++------
 .../component/rest/swagger/RestSwaggerEndpoint.java      | 16 ++++++++++------
 .../camel/component/rest/swagger/RestSwaggerHelper.java  |  2 +-
 .../springboot/RestSwaggerComponentConfiguration.java    | 12 ++++++------
 5 files changed, 29 insertions(+), 25 deletions(-)

diff --git a/components/camel-rest-swagger/src/main/docs/rest-swagger-component.adoc b/components/camel-rest-swagger/src/main/docs/rest-swagger-component.adoc
index a467a3b..97144f0 100644
--- a/components/camel-rest-swagger/src/main/docs/rest-swagger-component.adoc
+++ b/components/camel-rest-swagger/src/main/docs/rest-swagger-component.adoc
@@ -92,11 +92,11 @@ The REST Swagger component supports 9 options, which are listed below.
 |===
 | Name | Description | Default | Type
 | *basePath* (producer) | API basePath, for example /v2. Default is unset, if set overrides the value present in Swagger specification. |  | String
-| *componentName* (producer) | Name of the Camel component that will perform the requests. The compnent must be present in Camel registry and it must implement RestProducerFactory service provider interface. If not set CLASSPATH is searched for single component that implements RestProducerFactory SPI. Can be overriden in endpoint configuration. |  | String
-| *consumes* (producer) | 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 Swagger specification. Can be overriden in endpoint configuration |  | String
-| *host* (producer) | Scheme hostname and port to direct the HTTP requests to in the form of <a href="https://hostname:port">https://hostname:port. Can be configured at the endpoint, component or in the correspoding REST configuration in the Camel Context. If you give this component a name (e.g. petstore) that REST configuration is consulted first, rest-swagger next, and global configuration last. If set overrides any value found in the Swagger specification, RestConfiguration. Can be overriden in endpoint configuratio [...]
-| *produces* (producer) | What payload type this component is producing. For example application/json according to the RFC7231. This equates to the value of Content-Type HTTP header. If set overrides any value present in the Swagger specification. Can be overriden in endpoint configuration. |  | String
-| *specificationUri* (producer) | Path to the Swagger specification file. The scheme, host base path are taken from this specification, but these can be overriden with properties on the component or endpoint level. If not given the component tries to load swagger.json resource. Note that the host defined on the component and endpoint of this Component should contain the scheme, hostname and optionally the port in the URI syntax (i.e. https://api.example.com:8080). Can be overriden in end [...]
+| *componentName* (producer) | 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 single component that implements RestProducerFactory SPI. Can be overridden in endpoint configuration. |  | String
+| *consumes* (producer) | 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 Swagger specification. Can be overridden in endpoint configuration |  | String
+| *host* (producer) | Scheme hostname and port to direct the HTTP requests to in the form of <a href="https://hostname:port">https://hostname:port. Can be configured at the endpoint, component or in the correspoding REST configuration in the Camel Context. If you give this component a name (e.g. petstore) that REST configuration is consulted first, rest-swagger next, and global configuration last. If set overrides any value found in the Swagger specification, RestConfiguration. Can be overridden in endpoint configurati [...]
+| *produces* (producer) | What payload type this component is producing. For example application/json according to the RFC7231. This equates to the value of Content-Type HTTP header. If set overrides any value present in the Swagger specification. Can be overridden in endpoint configuration. |  | String
+| *specificationUri* (producer) | Path to the Swagger specification file. The scheme, host base path are taken from this specification, but these can be overriden with properties on the component or endpoint level. If not given the component tries to load swagger.json resource. Note that the host defined on the component and endpoint of this Component should contain the scheme, hostname and optionally the port in the URI syntax (i.e. https://api.example.com:8080). Can be overridden in en [...]
 | *sslContextParameters* (security) | Customize TLS parameters used by the component. If not set defaults to the TLS parameters set in the Camel context |  | SSLContextParameters
 | *useGlobalSslContext Parameters* (security) | Enable usage of global SSL context parameters. | false | boolean
 | *resolveProperty Placeholders* (advanced) | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | boolean
@@ -118,7 +118,7 @@ with the following path and query parameters:
 [width="100%",cols="2,5,^1,2",options="header"]
 |===
 | Name | Description | Default | Type
-| *specificationUri* | Path to the Swagger specification file. The scheme, host base path are taken from this specification, but these can be overriden with properties on the component or endpoint level. If not given the component tries to load swagger.json resource. Note that the host defined on the component and endpoint of this Component should contain the scheme, hostname and optionally the port in the URI syntax (i.e. https://api.example.com:8080). Overrides component configuration. [...]
+| *specificationUri* | Path to the Swagger 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 given the component tries to load swagger.json resource from the classpath. Note that the host defined on the component and endpoint of this Component should contain the scheme, hostname and optionally the port in the URI syntax (i.e. http://api.example.com:8080). Overrides compo [...]
 | *operationId* | *Required* ID of the operation from the Swagger specification. |  | String
 |===
 
diff --git a/components/camel-rest-swagger/src/main/java/org/apache/camel/component/rest/swagger/RestSwaggerComponent.java b/components/camel-rest-swagger/src/main/java/org/apache/camel/component/rest/swagger/RestSwaggerComponent.java
index b5c366e..2e47f74 100644
--- a/components/camel-rest-swagger/src/main/java/org/apache/camel/component/rest/swagger/RestSwaggerComponent.java
+++ b/components/camel-rest-swagger/src/main/java/org/apache/camel/component/rest/swagger/RestSwaggerComponent.java
@@ -90,9 +90,9 @@ public final class RestSwaggerComponent extends DefaultComponent implements SSLC
         defaultValue = "", label = "producer", required = false)
     private String basePath = "";
 
-    @Metadata(description = "Name of the Camel component that will perform the requests. The compnent must be present"
+    @Metadata(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 single component that implements RestProducerFactory SPI. Can be overriden in"
+        + " CLASSPATH is searched for single component that implements RestProducerFactory SPI. Can be overridden in"
         + " endpoint configuration.", label = "producer", required = false)
     private String componentName;
 
@@ -100,7 +100,7 @@ public final class RestSwaggerComponent extends DefaultComponent implements SSLC
         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 Swagger specification."
-            + " Can be overriden in endpoint configuration",
+            + " Can be overridden in endpoint configuration",
         label = "producer", required = false)
     private String consumes;
 
@@ -108,14 +108,14 @@ public final class RestSwaggerComponent extends DefaultComponent implements SSLC
         + " `http[s]://hostname[:port]`. Can be configured at the endpoint, component or in the correspoding"
         + " REST configuration in the Camel Context. If you give this component a name (e.g. `petstore`) that"
         + " REST configuration is consulted first, `rest-swagger` next, and global configuration last. If set"
-        + " overrides any value found in the Swagger specification, RestConfiguration. Can be overriden in endpoint"
+        + " overrides any value found in the Swagger specification, RestConfiguration. Can be overridden in endpoint"
         + " configuration.", label = "producer", required = false)
     private String host;
 
     @Metadata(
         description = "What payload type this component is producing. For example `application/json`"
             + " according to the RFC7231. This equates to the value of `Content-Type` HTTP header. If set overrides"
-            + " any value present in the Swagger specification. Can be overriden in endpoint configuration.",
+            + " any value present in the Swagger specification. Can be overridden in endpoint configuration.",
         label = "producer", required = false)
     private String produces;
 
@@ -123,7 +123,7 @@ public final class RestSwaggerComponent extends DefaultComponent implements SSLC
         + " specification, but these can be overriden with properties on the component or endpoint level. If not"
         + " given the component tries to load `swagger.json` resource. Note that the `host` defined on the"
         + " component and endpoint of this Component should contain the scheme, hostname and optionally the"
-        + " port in the URI syntax (i.e. `https://api.example.com:8080`). Can be overriden in endpoint"
+        + " port in the URI syntax (i.e. `https://api.example.com:8080`). Can be overridden in endpoint"
         + " configuration.", defaultValue = DEFAULT_SPECIFICATION_URI_STR, label = "producer", required = false)
     private URI specificationUri;
 
diff --git a/components/camel-rest-swagger/src/main/java/org/apache/camel/component/rest/swagger/RestSwaggerEndpoint.java b/components/camel-rest-swagger/src/main/java/org/apache/camel/component/rest/swagger/RestSwaggerEndpoint.java
index a628669..1243fdb 100644
--- a/components/camel-rest-swagger/src/main/java/org/apache/camel/component/rest/swagger/RestSwaggerEndpoint.java
+++ b/components/camel-rest-swagger/src/main/java/org/apache/camel/component/rest/swagger/RestSwaggerEndpoint.java
@@ -124,10 +124,14 @@ public final class RestSwaggerEndpoint extends DefaultEndpoint {
 
     @UriPath(
         description = "Path to the Swagger specification file. The scheme, host base path are taken from this"
-            + " specification, but these can be overriden with properties on the component or endpoint level. If not"
-            + " given the component tries to load `swagger.json` resource. Note that the `host` defined on the"
+            + " specification, but these can be overridden with properties on the component or endpoint level. If not"
+            + " given the component tries to load `swagger.json` resource from the classpath. Note that the `host` defined on the"
             + " component and endpoint of this Component should contain the scheme, hostname and optionally the"
-            + " port in the URI syntax (i.e. `https://api.example.com:8080`). Overrides component configuration.",
+            + " port in the URI syntax (i.e. `http://api.example.com:8080`). Overrides component configuration."
+            + " The Swagger specification can be loaded from different sources by prefixing with file: classpath: http: https:."
+            + " Support for https is limited to using the JDK installed UrlHandler, and as such it can be cumbersome to setup"
+            + " TLS/SSL certificates for https (such as setting a number of javax.net.ssl JVM system properties)."
+            + " How to do that consult the JDK documentation for UrlHandler.",
         defaultValue = RestSwaggerComponent.DEFAULT_SPECIFICATION_URI_STR,
         defaultValueNote = "By default loads `swagger.json` file", label = "producer")
     private URI specificationUri = RestSwaggerComponent.DEFAULT_SPECIFICATION_URI;
@@ -428,7 +432,7 @@ public final class RestSwaggerEndpoint extends DefaultEndpoint {
 
         final boolean areTheSame = "rest-swagger".equals(assignedComponentName);
 
-        throw new IllegalStateException("Unable to determine destionation host for requests. The Swagger specification"
+        throw new IllegalStateException("Unable to determine destination host for requests. The Swagger specification"
             + " does not specify `scheme` and `host` parameters, the specification URI is not absolute with `http` or"
             + " `https` scheme, and no RestConfigurations configured with `scheme`, `host` and `port` were found for `"
             + (areTheSame ? "rest-swagger` component" : assignedComponentName + "` or `rest-swagger` components")
@@ -565,7 +569,7 @@ public final class RestSwaggerEndpoint extends DefaultEndpoint {
             final JsonNode node = mapper.readTree(stream);
 
             return swaggerParser.read(node);
-        } catch (final IOException e) {
+        } catch (Exception e) {
             // try Swaggers loader
             final Swagger swagger = swaggerParser.read(uriAsString);
 
@@ -576,7 +580,7 @@ public final class RestSwaggerEndpoint extends DefaultEndpoint {
             throw new IllegalArgumentException("The given Swagger specification could not be loaded from `" + uri
                 + "`. Tried loading using Camel's resource resolution and using Swagger's own resource resolution."
                 + " Swagger tends to swallow exceptions while parsing, try specifying Java system property `debugParser`"
-                + " (e.g. `-DdebugParser=true`), the exception that occured when loading using Camel's resource"
+                + " (e.g. `-DdebugParser=true`), the exception that occurred when loading using Camel's resource"
                 + " loader follows", e);
         }
     }
diff --git a/components/camel-rest-swagger/src/main/java/org/apache/camel/component/rest/swagger/RestSwaggerHelper.java b/components/camel-rest-swagger/src/main/java/org/apache/camel/component/rest/swagger/RestSwaggerHelper.java
index ca7e972..28285e8 100644
--- a/components/camel-rest-swagger/src/main/java/org/apache/camel/component/rest/swagger/RestSwaggerHelper.java
+++ b/components/camel-rest-swagger/src/main/java/org/apache/camel/component/rest/swagger/RestSwaggerHelper.java
@@ -42,7 +42,7 @@ final class RestSwaggerHelper {
 
         if (!matcher.matches()) {
             throw new IllegalArgumentException(
-                "host must be an apsolute URI (e.g. http://api.example.com), given: `" + hostUri + "`");
+                "host must be an absolute URI (e.g. http://api.example.com), given: `" + hostUri + "`");
         }
 
         return hostUri;
diff --git a/platforms/spring-boot/components-starter/camel-rest-swagger-starter/src/main/java/org/apache/camel/component/rest/swagger/springboot/RestSwaggerComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-rest-swagger-starter/src/main/java/org/apache/camel/component/rest/swagger/springboot/RestSwaggerComponentConfiguration.java
index ae287c3..560095a 100644
--- a/platforms/spring-boot/components-starter/camel-rest-swagger-starter/src/main/java/org/apache/camel/component/rest/swagger/springboot/RestSwaggerComponentConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-rest-swagger-starter/src/main/java/org/apache/camel/component/rest/swagger/springboot/RestSwaggerComponentConfiguration.java
@@ -43,11 +43,11 @@ public class RestSwaggerComponentConfiguration
      */
     private String basePath;
     /**
-     * Name of the Camel component that will perform the requests. The compnent
+     * 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 single component that implements RestProducerFactory SPI.
-     * Can be overriden in endpoint configuration.
+     * Can be overridden in endpoint configuration.
      */
     private String componentName;
     /**
@@ -55,7 +55,7 @@ public class RestSwaggerComponentConfiguration
      * 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
-     * Swagger specification. Can be overriden in endpoint configuration
+     * Swagger specification. Can be overridden in endpoint configuration
      */
     private String consumes;
     /**
@@ -65,14 +65,14 @@ public class RestSwaggerComponentConfiguration
      * this component a name (e.g. petstore) that REST configuration is
      * consulted first, rest-swagger next, and global configuration last. If set
      * overrides any value found in the Swagger specification,
-     * RestConfiguration. Can be overriden in endpoint configuration.
+     * RestConfiguration. Can be overridden in endpoint configuration.
      */
     private String host;
     /**
      * What payload type this component is producing. For example
      * application/json according to the RFC7231. This equates to the value of
      * Content-Type HTTP header. If set overrides any value present in the
-     * Swagger specification. Can be overriden in endpoint configuration.
+     * Swagger specification. Can be overridden in endpoint configuration.
      */
     private String produces;
     /**
@@ -82,7 +82,7 @@ public class RestSwaggerComponentConfiguration
      * load swagger.json resource. Note that the host defined on the component
      * and endpoint of this Component should contain the scheme, hostname and
      * optionally the port in the URI syntax (i.e.
-     * https://api.example.com:8080). Can be overriden in endpoint
+     * https://api.example.com:8080). Can be overridden in endpoint
      * configuration.
      */
     private URI specificationUri;