diff --git a/java/java-jaxrs-cxf/README.md b/java/java-jaxrs-cxf/README.md index 6e867757..e42b2a2a 100644 --- a/java/java-jaxrs-cxf/README.md +++ b/java/java-jaxrs-cxf/README.md @@ -9,14 +9,19 @@ to reflect over property packages to discover swagger-enabled resources. This was originally contributed by [chadhahn](https://github.com/chadhahn) and adapted by [rvullriede](https://github.com/rvullriede). Thank you for your contributions! +Please note that in the meantime Swagger has been integrated into CXF which simplifies the setup. +Take a look at the [CXF Documentation](http://cxf.apache.org/docs/swagger2feature.html) +or [one of the samples](https://github.com/apache/cxf/tree/master/distribution/src/main/release/samples/jax_rs/spring_boot) +to get more information. + ### To run (with Maven) To run the server, run this task: ``` -mvn package tomcat6:run +mvn package tomcat7:run ``` -This will start Tomcat 6 embedded on port 8002. +This will start Tomcat 7 embedded on port 8002. ### Testing the server Once started, you can navigate to http://localhost:8002/api/swagger.json to view the Swagger Resource Listing. diff --git a/java/java-jaxrs-cxf/pom.xml b/java/java-jaxrs-cxf/pom.xml index 71843463..07fd8ec8 100644 --- a/java/java-jaxrs-cxf/pom.xml +++ b/java/java-jaxrs-cxf/pom.xml @@ -11,15 +11,15 @@ swagger-java-cxf-sample war swagger-java-cxf-sample - 1.0.0 + 1.1.0-SNAPSHOT src/main/java org.apache.tomcat.maven - tomcat6-maven-plugin - 2.1 + tomcat7-maven-plugin + 2.2 target/${project.artifactId}-${project.version} 8002 @@ -40,7 +40,7 @@ maven-failsafe-plugin - 2.6 + 2.20 @@ -108,7 +108,7 @@ maven-resources-plugin - 2.6 + 3.0.2 copy-resources @@ -208,7 +208,7 @@ ch.qos.logback logback-classic - 1.0.9 + 1.2.3 runtime @@ -265,8 +265,8 @@ - 1.6 - 3.2.1.RELEASE - 2.7.15 + 1.7 + 4.3.9.RELEASE + 3.1.12 diff --git a/java/java-jaxrs-cxf/src/main/java/io/swagger/sample/resource/JavaRestResourceUtil.java b/java/java-jaxrs-cxf/src/main/java/io/swagger/sample/resource/JavaRestResourceUtil.java deleted file mode 100644 index 3fec5b44..00000000 --- a/java/java-jaxrs-cxf/src/main/java/io/swagger/sample/resource/JavaRestResourceUtil.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * Copyright 2016 SmartBear Software - * - * Licensed 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 io.swagger.sample.resource; - -import java.text.SimpleDateFormat; - -import java.util.Date; - -public class JavaRestResourceUtil { - public int getInt(int minVal, int maxVal, int defaultValue, String inputString) { - int output = defaultValue; - try { - output = Integer.parseInt(inputString); - } - catch (Exception e){ - output = defaultValue; - } - - if (output < minVal) output = minVal; - if (maxVal == -1) { - if (output < minVal) output = minVal; - } - else if (output > maxVal) output = maxVal; - return output; - } - - public long getLong(long minVal, long maxVal, long defaultValue, String inputString) { - long output = defaultValue; - try { - output = Long.parseLong(inputString); - } - catch (Exception e){ - output = defaultValue; - } - - if (output < minVal) output = minVal; - if (maxVal == -1) { if (output < minVal) output = minVal; } - else if (output > maxVal) output = maxVal; - return output; - } - - public double getDouble(double minVal, double maxVal, double defaultValue, String inputString) { - double output = defaultValue; - try { - output = Double.parseDouble(inputString); - } - catch (Exception e){ - output = defaultValue; - } - - if (output < minVal) output = minVal; - if (maxVal == -1) { - if (output < minVal) output = minVal; - } - else if (output > maxVal) output = maxVal; - return output; - } - - public boolean getBoolean(boolean defaultValue, String booleanString) { - boolean output = defaultValue; - if (booleanString == null) output = defaultValue; - - // treat "", "YES" as "true" - if ("".equals(booleanString)) output = true; - else if ("YES".equalsIgnoreCase(booleanString)) output = true; - else if ("NO".equalsIgnoreCase(booleanString)) output = false; - else { - try { - output = Boolean.parseBoolean(booleanString); - } - catch (Exception e){ - output = defaultValue; - } - } - return output; - } - - public Date getDate(Date defaultValue, String dateString){ - try { - return new SimpleDateFormat("yyyy-MM-dd").parse(dateString); - } - catch(Exception e) { - return defaultValue; - } - } -} \ No newline at end of file diff --git a/java/java-jaxrs-cxf/src/main/resources/applicationContext.xml b/java/java-jaxrs-cxf/src/main/resources/applicationContext.xml index 3099bf21..4febe4c0 100644 --- a/java/java-jaxrs-cxf/src/main/resources/applicationContext.xml +++ b/java/java-jaxrs-cxf/src/main/resources/applicationContext.xml @@ -4,10 +4,9 @@ xmlns:jaxrs="http://cxf.apache.org/jaxrs" xmlns:util="http://www.springframework.org/schema/util" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd - http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd - http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd - http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd - http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd"> + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd + http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">