camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [camel] branch master updated: CAMEL-12038: Deprecate RestSwaggerServlet as people should not use that.
Date Mon, 18 Dec 2017 12:22:36 GMT
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 e1aaaa2  CAMEL-12038: Deprecate RestSwaggerServlet as people should not use that.
e1aaaa2 is described below

commit e1aaaa26605ab940e9ed507ddbe3f5dda00023fc
Author: Claus Ibsen <claus.ibsen@gmail.com>
AuthorDate: Mon Dec 18 13:22:24 2017 +0100

    CAMEL-12038: Deprecate RestSwaggerServlet as people should not use that.
---
 .../src/main/docs/swagger-java.adoc                | 132 +++------------------
 .../swagger/servlet/RestSwaggerCorsFilter.java     |   3 +
 .../camel/swagger/servlet/RestSwaggerServlet.java  |   2 +-
 .../servlet/ServletRestApiResponseAdapter.java     |   1 +
 4 files changed, 19 insertions(+), 119 deletions(-)

diff --git a/components/camel-swagger-java/src/main/docs/swagger-java.adoc b/components/camel-swagger-java/src/main/docs/swagger-java.adoc
index b647a0b..61cb883 100644
--- a/components/camel-swagger-java/src/main/docs/swagger-java.adoc
+++ b/components/camel-swagger-java/src/main/docs/swagger-java.adoc
@@ -1,6 +1,4 @@
-[[SwaggerJava-SwaggerJavaComponent]]
-Swagger Java Component
-~~~~~~~~~~~~~~~~~~~~~~
+== Swagger Java Component
 
 *Available as of Camel 2.16*
 
@@ -14,79 +12,30 @@ their `pom.xml` for this component:
 From *Camel 2.16* onwards the swagger component is purely Java based,
 and its 
 
-[source,java]
-------------------------------------------------------------
+[source,xml]
+----
 <dependency>
     <groupId>org.apache.camel</groupId>
     <artifactId>camel-swagger-java</artifactId>
     <version>x.x.x</version>
     <!-- use the same version as your Camel core version -->
 </dependency>
-------------------------------------------------------------
+----
 
-The camel-swagger-java module can be used as a Servlet or directly from
+The camel-swagger-java module can be used from
 the REST components (without the need for servlet)
 
 For an example see the `camel-example-swagger-cdi` in the examples
 directory of the Apache Camel distribution.
 
-[[SwaggerJava-UsingSwaggerasaServlet]]
-Using Swagger as a Servlet
-^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-You configure the swagger in the web.xml as shown below:
 
-[source,java]
-------------------------------------------------------------------------------------------------------------------------
-  <servlet>
- 
-    <servlet-name>SwaggerServlet</servlet-name>
-    <servlet-class>org.apache.camel.swagger.servlet.RestSwaggerServlet</servlet-class>
-
-    <init-param>
-      <!-- we specify the base.path using relative notation, that means the actual path
will be calculated at runtime as
-           http://server:port/contextpath/rest -->
-      <param-name>base.path</param-name>
-      <param-value>rest</param-value>
-    </init-param>
-    <init-param>
-      <!-- we specify the api.path using relative notation, that means the actual path
will be calculated at runtime as
-           http://server:port/contextpath/api-docs -->
-      <param-name>api.path</param-name>
-      <param-value>api-docs</param-value>
-    </init-param>
-
-    <init-param>
-      <param-name>api.version</param-name>
-      <param-value>1.2.3</param-value>
-    </init-param>
-    <init-param>
-      <param-name>api.title</param-name>
-      <param-value>User Services</param-value>
-    </init-param>
-    <init-param>
-      <param-name>api.description</param-name>
-      <param-value>Camel Rest Example with Swagger that provides an User REST service</param-value>
-    </init-param>
-    <load-on-startup>1</load-on-startup>
-  </servlet>
-
-  <!-- swagger api -->
-  <servlet-mapping>
-    <servlet-name>SwaggerServlet</servlet-name>
-    <url-pattern>/api-docs/*</url-pattern>
-  </servlet-mapping>
-------------------------------------------------------------------------------------------------------------------------
-
-[[SwaggerJava-UsingSwaggerinrest-dsl]]
-Using Swagger in rest-dsl
-^^^^^^^^^^^^^^^^^^^^^^^^^
+=== Using Swagger in rest-dsl
 
 You can enable the swagger api from the rest-dsl by configuring the
 `apiContextPath` dsl as shown below:
 
 [source,java]
-------------------------------------------------------------------------------------------------------------------
+----
 public class UserRouteBuilder extends RouteBuilder {
     @Override
     public void configure() throws Exception {
@@ -116,13 +65,10 @@ public class UserRouteBuilder extends RouteBuilder {
                 .to("bean:userService?method=listUsers");
     }
 }
-------------------------------------------------------------------------------------------------------------------
-
+----
  
 
-[[SwaggerJava-Options]]
-Options
-^^^^^^^
+=== Options
 
 The swagger module can be configured using the following options. To
 configure using a servlet you use the init-param as shown above. When
@@ -131,7 +77,7 @@ such as `enableCORS`, `host,contextPath`, dsl. The options
 with `api.xxx` is configured using `apiProperty` dsl.
 
 [width="100%",cols="10%,10%,80%",options="header",]
-|=======================================================================
+|===
 |Option |Type |Description
 
 |cors |Boolean |Whether to enable CORS. Notice this only enables CORS for the api
@@ -190,56 +136,10 @@ false.
 context listing. The pattern is using regular expression and * as
 wildcard. Its the same pattern matching as used by
 link:intercept.html[Intercept]
-|=======================================================================
-
-[[SwaggerJava-CorsFilter]]
-CorsFilter
-^^^^^^^^^^
+|===
 
-If you use the swagger ui to view the REST api then you likely need to
-enable support for CORS. This is needed if the swagger ui is hosted and
-running on another hostname/port than the actual REST apis. When doing
-this the swagger ui needs to be allowed to access the REST resources
-across the origin (CORS). The CorsFilter adds the necessary HTTP headers
-to enable CORS.
 
-To use CORS adds the following filter
-`org.apache.camel.swagger.servlet.RestSwaggerCorsFilter` to your
-web.xml.
-
-[source,java]
---------------------------------------------------------------------------------------
-  <!-- enable CORS filter so people can use swagger ui to browse and test the apis -->
-  <filter>
-    <filter-name>RestSwaggerCorsFilter</filter-name>
-    <filter-class>org.apache.camel.swagger.servlet.RestSwaggerCorsFilter</filter-class>
-  </filter>
-
-
-  <filter-mapping>
-    <filter-name>RestSwaggerCorsFilter</filter-name>
-    <url-pattern>/api-docs/*</url-pattern>
-    <url-pattern>/rest/*</url-pattern>
-  </filter-mapping>
---------------------------------------------------------------------------------------
-
-The CorsFilter sets the following headers for all requests
-
-* Access-Control-Allow-Origin = *
-* Access-Control-Allow-Methods = GET, HEAD, POST, PUT, DELETE, TRACE,
-OPTIONS, CONNECT, PATCH
-* Access-Control-Max-Age = 3600
-* Access-Control-Allow-Headers = Origin, Accept, X-Requested-With,
-Content-Type, Access-Control-Request-Method,
-Access-Control-Request-Headers
-
-Notice this is a very simple CORS filter. You may need to use a more
-sophisticated filter to set the header values differently for a given
-client. Or block certain clients etc.
-
-[[SwaggerJava-ContextIdListingenabled]]
-ContextIdListing enabled
-^^^^^^^^^^^^^^^^^^^^^^^^
+=== ContextIdListing enabled
 
 When contextIdListing is enabled then its detecting all the running
 CamelContexts in the same JVM. These contexts are listed in the root
@@ -248,9 +148,7 @@ the swagger documentation then the context-path must be appended with
 the Camel context id, such as `api-docs/myCamel`. The
 option apiContextIdPattern can be used to filter the names in this list.
 
-[[SwaggerJava-JSonorYaml]]
-JSon or Yaml
-^^^^^^^^^^^^
+=== JSon or Yaml
 
 *Available as of Camel 2.17*
 
@@ -261,9 +159,7 @@ the HTTP Accept header is used to detect if json or yaml can be
 accepted. If either both is accepted or none was set as accepted then
 json is returned as the default format.
 
-[[SwaggerJava-Examples]]
-Examples
-^^^^^^^^
+=== Examples
 
 In the Apache Camel distribution we ship
 the `camel-example-swagger-cdi` and `camel-example-swagger-java` which
diff --git a/components/camel-swagger-java/src/main/java/org/apache/camel/swagger/servlet/RestSwaggerCorsFilter.java
b/components/camel-swagger-java/src/main/java/org/apache/camel/swagger/servlet/RestSwaggerCorsFilter.java
index d29d76a..69e073c 100644
--- a/components/camel-swagger-java/src/main/java/org/apache/camel/swagger/servlet/RestSwaggerCorsFilter.java
+++ b/components/camel-swagger-java/src/main/java/org/apache/camel/swagger/servlet/RestSwaggerCorsFilter.java
@@ -48,7 +48,10 @@ import org.apache.camel.spi.RestConfiguration;
  *     <li>{@link RestConfiguration#CORS_ACCESS_CONTROL_ALLOW_HEADERS}</li>
  *     <li>{@link RestConfiguration#CORS_ACCESS_CONTROL_MAX_AGE}</li>
  * </ul>
+ *
+ * @deprecated do not use this directly but use rest-dsl the regular way with rest-dsl configuration.
  */
+@Deprecated
 public class RestSwaggerCorsFilter implements Filter {
 
     private final Map<String, String> corsHeaders = new HashMap<String, String>();
diff --git a/components/camel-swagger-java/src/main/java/org/apache/camel/swagger/servlet/RestSwaggerServlet.java
b/components/camel-swagger-java/src/main/java/org/apache/camel/swagger/servlet/RestSwaggerServlet.java
index d0c6a3f..51ca3d2 100644
--- a/components/camel-swagger-java/src/main/java/org/apache/camel/swagger/servlet/RestSwaggerServlet.java
+++ b/components/camel-swagger-java/src/main/java/org/apache/camel/swagger/servlet/RestSwaggerServlet.java
@@ -48,7 +48,7 @@ import static org.apache.camel.swagger.SwaggerHelper.buildUrl;
  * <p/>
  * This requires Camel version 2.15 or better at runtime (and JMX to be enabled).
  *
- * @deprecated do not use this servlet directly but use rest-dsl the regular way with rest-dsl
configuration.
+ * @deprecated do not use this directly but use rest-dsl the regular way with rest-dsl configuration.
  */
 @Deprecated
 public class RestSwaggerServlet extends HttpServlet {
diff --git a/components/camel-swagger-java/src/main/java/org/apache/camel/swagger/servlet/ServletRestApiResponseAdapter.java
b/components/camel-swagger-java/src/main/java/org/apache/camel/swagger/servlet/ServletRestApiResponseAdapter.java
index 8ec490d..e5507df 100644
--- a/components/camel-swagger-java/src/main/java/org/apache/camel/swagger/servlet/ServletRestApiResponseAdapter.java
+++ b/components/camel-swagger-java/src/main/java/org/apache/camel/swagger/servlet/ServletRestApiResponseAdapter.java
@@ -21,6 +21,7 @@ import javax.servlet.http.HttpServletResponse;
 
 import org.apache.camel.swagger.RestApiResponseAdapter;
 
+@Deprecated
 public class ServletRestApiResponseAdapter implements RestApiResponseAdapter {
 
     private final HttpServletResponse response;

-- 
To stop receiving notification emails like this one, please contact
['"commits@camel.apache.org" <commits@camel.apache.org>'].

Mime
View raw message