diff --git a/README.md b/README.md index a549adec5b5..e619b5948fb 100644 --- a/README.md +++ b/README.md @@ -582,6 +582,33 @@ and specify the `classname` when running the generator: Your subclass will now be loaded and overrides the `PREFIX` value in the superclass. +### Java Bean Validation support + +Java Bean Validation annotations are supported: + +Annotation | Swagger-API | Description +---------- | ----------- | ----------- +@DecimalMax (max for BigDecimal) | maxLength | not yet supported, see #2549 +@DecimalMin (min for BigDecimal) | minLength | not yet supported, see #2549 +@Max | maximum | The value of the field or property must be an integer value lower than or equal to the number in the value element. +@Min | minimum | The value of the field or property must be an integer value greater than or equal to the number in the value element. +@NotNull | required=true | The value of the field or property must not be null. +@Pattern | pattern | The value of the field or property must match the regular expression defined in the regexp element. +@Size | minLength/maxLength | The size of the field or property is evaluated and must match the specified boundaries. + +See http://docs.oracle.com/javaee/6/tutorial/doc/gircz.html for the full list of annotations. + +The following annotations currently don't have an equivalent in the Swagger-API spec: +* @AssertFalse +* @AssertTrue +* @Digits +* @Future +* @Null +* @Past + +Languages with Bean Validation support: Java, JAX-RS CXF + + ### Bringing your own models Sometimes you don't want a model generated. In this case, you can simply specify an import mapping to tell diff --git a/modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/CodeGenMojo.java b/modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/CodeGenMojo.java index 261d539e2e5..d786ad5b192 100644 --- a/modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/CodeGenMojo.java +++ b/modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/CodeGenMojo.java @@ -1,5 +1,23 @@ package io.swagger.codegen.plugin; +import static io.swagger.codegen.config.CodegenConfiguratorUtils.applyAdditionalPropertiesKvp; +import static io.swagger.codegen.config.CodegenConfiguratorUtils.applyImportMappingsKvp; +import static io.swagger.codegen.config.CodegenConfiguratorUtils.applyInstantiationTypesKvp; +import static io.swagger.codegen.config.CodegenConfiguratorUtils.applyLanguageSpecificPrimitivesCsv; +import static io.swagger.codegen.config.CodegenConfiguratorUtils.applyTypeMappingsKvp; +import static org.apache.commons.lang3.StringUtils.isNotEmpty; + +import java.io.File; +import java.util.HashMap; +import java.util.Map; + +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.project.MavenProject; + /* * Copyright 2001-2005 The Apache Software Foundation. * @@ -19,25 +37,9 @@ import io.swagger.codegen.CliOption; import io.swagger.codegen.ClientOptInput; import io.swagger.codegen.CodegenConfig; +import io.swagger.codegen.CodegenConstants; import io.swagger.codegen.DefaultGenerator; import io.swagger.codegen.config.CodegenConfigurator; -import io.swagger.models.Swagger; -import io.swagger.parser.SwaggerParser; -import org.apache.maven.plugin.AbstractMojo; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugins.annotations.LifecyclePhase; -import org.apache.maven.plugins.annotations.Mojo; -import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.project.MavenProject; - -import java.io.File; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import static io.swagger.codegen.config.CodegenConfiguratorUtils.*; -import static org.apache.commons.lang3.StringUtils.isNotEmpty; /** * Goal which generates client/server code from a swagger json/yaml definition. @@ -288,7 +290,8 @@ public void execute() throws MojoExecutionException { } if (addCompileSourceRoot) { - project.addCompileSourceRoot(output.toString()); + String sourceJavaFolder = output.toString() + "/" + configOptions.get(CodegenConstants.SOURCE_FOLDER); + project.addCompileSourceRoot(sourceJavaFolder); } } } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaCXFServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaCXFServerCodegen.java index c9d558d51ab..5ccb88459e3 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaCXFServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaCXFServerCodegen.java @@ -8,18 +8,33 @@ import io.swagger.codegen.CodegenModel; import io.swagger.codegen.CodegenOperation; import io.swagger.codegen.CodegenProperty; +import io.swagger.codegen.SupportingFile; import io.swagger.models.Operation; +/** + * TODO #2017: + * - reuse bean-validation-annotations in Java? + * - pom.xml: maybe add cxf-version property + * - api_test.mustache: add switch for using gzip in test cases? + * + * + * + */ public class JavaCXFServerCodegen extends AbstractJavaJAXRSServerCodegen -{ - public JavaCXFServerCodegen() - { +{ + public JavaCXFServerCodegen() + { super(); + supportsInheritance = true; + + artifactId = "swagger-cxf-server"; + sourceFolder = "gen" + File.separator + "java"; outputFolder = "generated-code/JavaJaxRS-CXF"; - apiTestTemplateFiles.clear(); // TODO: add test template - + + apiTemplateFiles.put("apiServiceImpl.mustache", ".java"); + // clear model and api doc template as this codegen // does not support auto-generated markdown doc at the moment //TODO: add doc templates @@ -34,14 +49,34 @@ public JavaCXFServerCodegen() embeddedTemplateDir = templateDir = JAXRS_TEMPLATE_DIRECTORY_NAME + File.separator + "cxf"; - } + } - @Override - public String getName() - { - return "jaxrs-cxf"; - } + @Override + public void processOpts() + { + super.processOpts(); + + supportingFiles.clear(); // Don't need extra files provided by AbstractJAX-RS & Java Codegen + + writeOptional(outputFolder, new SupportingFile("pom.mustache", "", "pom.xml")); + + writeOptional(outputFolder, new SupportingFile("readme.md", "", "readme.md")); + + writeOptional(outputFolder, new SupportingFile("web.mustache", + ("src/main/webapp/WEB-INF"), "web.xml")); + writeOptional(outputFolder, new SupportingFile("context.xml.mustache", + ("src/main/webapp/WEB-INF"), "context.xml")); + writeOptional(outputFolder, new SupportingFile("jboss-web.xml.mustache", + ("src/main/webapp/WEB-INF"), "jboss-web.xml")); + + } + + @Override + public String getName() + { + return "jaxrs-cxf"; + } @Override public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co, Map> operations) { diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java index 27e95190648..85cd8e519ef 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java @@ -9,6 +9,13 @@ import java.io.File; import java.util.*; +/** + * TODO #2549: + * - add switch for bean-validation-annotations? + * + * + * + */ public class JavaClientCodegen extends AbstractJavaCodegen { @SuppressWarnings("hiding") private static final Logger LOGGER = LoggerFactory.getLogger(JavaClientCodegen.class); @@ -164,7 +171,7 @@ public Map postProcessOperations(Map objs) { operation.returnType = "Void"; } if (usesRetrofit2Library() && StringUtils.isNotEmpty(operation.path) && operation.path.startsWith("/")) - operation.path = operation.path.substring(1); + operation.path = operation.path.substring(1); } } } diff --git a/modules/swagger-codegen/src/main/resources/Java/model.mustache b/modules/swagger-codegen/src/main/resources/Java/model.mustache index 1143fc413df..1d72c3a4efe 100644 --- a/modules/swagger-codegen/src/main/resources/Java/model.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/model.mustache @@ -6,6 +6,7 @@ import java.util.Objects; {{#imports}} import {{import}}; {{/imports}} +import javax.validation.constraints.*; {{#serializableModel}}import java.io.Serializable;{{/serializableModel}} {{#models}} diff --git a/modules/swagger-codegen/src/main/resources/Java/pojo.mustache b/modules/swagger-codegen/src/main/resources/Java/pojo.mustache index 4cebdb967ab..385fddfc036 100644 --- a/modules/swagger-codegen/src/main/resources/Java/pojo.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/pojo.mustache @@ -49,10 +49,37 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali {{/maximum}} * @return {{name}} **/ - {{#vendorExtensions.extraAnnotation}} - {{vendorExtensions.extraAnnotation}} - {{/vendorExtensions.extraAnnotation}} +{{#required}} + @NotNull +{{/required}} +{{#pattern}} + @Pattern(regexp="{{pattern}}") +{{/pattern}} +{{#minLength}} +{{#maxLength}} + @Size(min={{minLength}},max={{maxLength}}) +{{/maxLength}} +{{/minLength}} +{{#minLength}} +{{^maxLength}} + @Size(min={{minLength}}) +{{/maxLength}} +{{/minLength}} +{{^minLength}} +{{#maxLength}} + @Size(max={{maxLength}}) + {{/maxLength}} + {{/minLength}} +{{#minimum}} + //@Min({{minimum}}) +{{/minimum}} +{{#maximum}} + //@Max({{maximum}}) +{{/maximum}} @ApiModelProperty({{#example}}example = "{{example}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}") +{{#vendorExtensions.extraAnnotation}} + {{vendorExtensions.extraAnnotation}} +{{/vendorExtensions.extraAnnotation}} public {{{datatypeWithEnum}}} {{getter}}() { return {{name}}; } diff --git a/modules/swagger-codegen/src/main/resources/Java/pom.mustache b/modules/swagger-codegen/src/main/resources/Java/pom.mustache index 3a8c440eaee..66e6aeb2517 100644 --- a/modules/swagger-codegen/src/main/resources/Java/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/pom.mustache @@ -175,6 +175,14 @@ migbase64 2.2 + + + + javax.validation + validation-api + 1.1.0.Final + provided + diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/api.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/api.mustache index 7d57616610d..c949f117f8d 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/api.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/api.mustache @@ -12,7 +12,11 @@ import javax.ws.rs.core.Response; import org.apache.cxf.jaxrs.ext.multipart.*; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; + @Path("/") +@Api(value = "/", description = "{{description}}") public interface {{classname}} { {{#operations}} {{#operation}} @@ -20,7 +24,10 @@ public interface {{classname}} { {{#subresourceOperation}}@Path("{{path}}"){{/subresourceOperation}} {{#hasConsumes}}@Consumes({ {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}} {{#hasProduces}}@Produces({ {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}} - public Response {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/allParams}}); +{{#summary}} +@ApiOperation(value = "{{summary}}") +{{/summary}} + public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}} {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/allParams}}); {{/operation}} } {{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/apiServiceImpl.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/apiServiceImpl.mustache new file mode 100644 index 00000000000..dde547f91c6 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/apiServiceImpl.mustache @@ -0,0 +1,44 @@ +package {{package}}.impl; + +import {{package}}.*; +{{#imports}}import {{import}}; +{{/imports}} + +import java.io.InputStream; +import java.io.OutputStream; +import java.util.List; +import java.util.Map; +import javax.ws.rs.*; +import javax.ws.rs.core.Response; +import org.apache.cxf.jaxrs.model.wadl.Description; +import org.apache.cxf.jaxrs.model.wadl.DocTarget; + +import org.apache.cxf.jaxrs.ext.multipart.*; + +import io.swagger.annotations.Api; + +@Path("/") +{{#description}} +@Api(value = "/", description = "{{description}}") +{{/description}} +public class {{classname}}ServiceImpl implements {{classname}} { +{{#operations}} +{{#operation}} + @{{httpMethod}} + {{#subresourceOperation}}@Path("{{path}}"){{/subresourceOperation}} + {{#hasConsumes}}@Consumes({ {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}} + {{#hasProduces}}@Produces({ {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}} + {{! add description for CXF WADL (must be added to implementation class }} +{{#summary}} + @Description(value = "{{summary}}", target = DocTarget.METHOD) +{{/summary}} + public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}} {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/allParams}}) { + // TODO: Implement... + + {{#returnType}}return null;{{/returnType}} + } + +{{/operation}} +} +{{/operations}} + diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/api_test.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/api_test.mustache new file mode 100644 index 00000000000..7d275deb8c2 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/api_test.mustache @@ -0,0 +1,73 @@ +{{>licenseInfo}} + +package {{package}}; + +{{#imports}}import {{import}}; +{{/imports}} +import org.junit.Test; +import org.junit.Before; + +import javax.ws.rs.core.Response; +import org.apache.cxf.jaxrs.client.JAXRSClientFactory; +import org.apache.cxf.jaxrs.client.ClientConfiguration; +import org.apache.cxf.jaxrs.client.WebClient; +import org.apache.cxf.transport.common.gzip.GZIPInInterceptor; +import org.apache.cxf.transport.common.gzip.GZIPOutInterceptor; +import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; + +{{^fullJavaUtil}} +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +{{/fullJavaUtil}} + +/** + * API tests for {{classname}} + */ +public class {{classname}}Test { + + private {{classname}} api; + + @Before + public void setup() { + JacksonJsonProvider provider = new JacksonJsonProvider(); + List providers = new ArrayList(); + providers.add(provider); + + api = JAXRSClientFactory.create("{{basePath}}", {{classname}}.class, providers); + + org.apache.cxf.jaxrs.client.Client client = WebClient.client(api); + + ClientConfiguration config = WebClient.getConfig(client); + + // Example for using Gzipping + GZIPOutInterceptor gzipOutInterceptor = new GZIPOutInterceptor(); + // use Gzipping for first request sent to server + //gzipOutInterceptor.setForce(true); + config.getOutInterceptors().add(gzipOutInterceptor); + + config.getInInterceptors().add(new GZIPInInterceptor()); + + } + + {{#operations}}{{#operation}} + /** + * {{summary}} + * + * {{notes}} + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void {{operationId}}Test() { + {{#allParams}} + {{{dataType}}} {{paramName}} = new {{{dataType}}}(); + {{/allParams}} + {{#returnType}}{{{returnType}}} response = {{/returnType}}api.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); + + // TODO: test validations + } + {{/operation}}{{/operations}} +} diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/context.xml.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/context.xml.mustache new file mode 100644 index 00000000000..1c7aeb4d64d --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/context.xml.mustache @@ -0,0 +1,71 @@ + + + + + + + + + + + + +{{#apiInfo}} +{{#apis}} + +{{/apis}} +{{/apiInfo}} + + + + + + + + + + + + + + + + + + + + +{{#apiInfo}} +{{#apis}} + +{{/apis}} +{{/apiInfo}} + + + + + + + + + + + + diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/jboss-web.xml.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/jboss-web.xml.mustache new file mode 100644 index 00000000000..ef688c10e91 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/jboss-web.xml.mustache @@ -0,0 +1,7 @@ + + + + + swagger-cxf-server + + diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/licenseInfo.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/licenseInfo.mustache new file mode 100644 index 00000000000..861d97234cf --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/licenseInfo.mustache @@ -0,0 +1,23 @@ +/** + * {{{appName}}} + * {{{appDescription}}} + * + * {{#version}}OpenAPI spec version: {{{version}}}{{/version}} + * {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}} + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/model.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/model.mustache index 2c383a41a28..5a16499d15b 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/model.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/model.mustache @@ -2,6 +2,7 @@ package {{package}}; {{#imports}}import {{import}}; {{/imports}} +import javax.validation.constraints.*; {{#models}} {{#model}}{{#description}} diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/pojo.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/pojo.mustache index c214ae2ae84..af565cdbf35 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/pojo.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/pojo.mustache @@ -1,3 +1,4 @@ +import io.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlAccessType; @@ -7,10 +8,13 @@ import javax.xml.bind.annotation.XmlEnum; @XmlAccessorType(XmlAccessType.FIELD) {{#hasVars}} @XmlType(name = "{{classname}}", propOrder = - { {{#vars}}"{{name}}"{{^-last}}, {{/-last}}{{/vars}} + { {{#vars}}"{{name}}"{{^-last}}, {{/-last}}{{/vars}} }){{/hasVars}} {{^hasVars}}@XmlType(name = "{{classname}}"){{/hasVars}} {{^parent}}@XmlRootElement(name="{{classname}}"){{/parent}} +{{#description}} +@ApiModel(description="{{{description}}}") +{{/description}} public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} { {{#vars}}{{#isEnum}} @@ -19,15 +23,55 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} { {{>enumClass}}{{/items}}{{/items.isEnum}} @XmlElement(name="{{baseName}}") +{{#required}} + @NotNull +{{/required}} +{{#pattern}} + @Pattern(regexp="{{pattern}}") +{{/pattern}} +{{#minLength}} +{{#maxLength}} + @Size(min={{minLength}},max={{maxLength}}) +{{/maxLength}} +{{/minLength}} +{{#minLength}} +{{^maxLength}} + @Size(min={{minLength}}) +{{/maxLength}} +{{/minLength}} +{{^minLength}} +{{#maxLength}} + @Size(max={{maxLength}}) + {{/maxLength}} + {{/minLength}} +{{#minimum}} + //@Min({{minimum}}) +{{/minimum}} +{{#maximum}} + //@Max({{maximum}}) +{{/maximum}} + @ApiModelProperty({{#example}}example = "{{example}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}") private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};{{/vars}} {{#vars}} - /**{{#description}} - * {{{description}}}{{/description}}{{#minimum}} - * minimum: {{minimum}}{{/minimum}}{{#maximum}} - * maximum: {{maximum}}{{/maximum}} - **/ - {{#vendorExtensions.extraAnnotation}}{{vendorExtensions.extraAnnotation}}{{/vendorExtensions.extraAnnotation}} + /** + {{#description}} + * {{{description}}} + {{/description}} + {{^description}} + * Get {{name}} + {{/description}} + {{#minimum}} + * minimum: {{minimum}} + {{/minimum}} + {{#maximum}} + * maximum: {{maximum}} + {{/maximum}} + * @return {{name}} + **/ +{{#vendorExtensions.extraAnnotation}} + {{vendorExtensions.extraAnnotation}} +{{/vendorExtensions.extraAnnotation}} public {{{datatypeWithEnum}}} {{getter}}() { return {{name}}; } diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/pom.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/pom.mustache new file mode 100644 index 00000000000..40a6135e636 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/pom.mustache @@ -0,0 +1,195 @@ + + 4.0.0 + {{groupId}} + {{artifactId}} + war + {{artifactId}} + {{artifactVersion}} + + src/main/java + + + org.apache.maven.plugins + maven-war-plugin + 2.1.1 + + + maven-failsafe-plugin + 2.6 + + + + integration-test + verify + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.9.1 + + + add-source + generate-sources + + add-source + + + + gen/java + + + + + + + + + maven-war-plugin + + true + + + + + + + io.swagger + swagger-jaxrs + compile + ${swagger-core-version} + + + ch.qos.logback + logback-classic + ${logback-version} + compile + + + ch.qos.logback + logback-core + ${logback-version} + compile + + + junit + junit + ${junit-version} + test + + + + javax.validation + validation-api + ${beanvalidation-version} + provided + + + + org.apache.cxf + cxf-rt-rs-client + ${cxf-version} + test + + + + + org.apache.cxf + cxf-rt-frontend-jaxrs + ${cxf-version} + compile + + + org.apache.cxf + cxf-rt-rs-service-description + ${cxf-version} + compile + + + org.apache.cxf + cxf-rt-ws-policy + ${cxf-version} + compile + + + org.apache.cxf + cxf-rt-wsdl + ${cxf-version} + compile + + + + org.springframework + spring-context + ${spring-version} + + + org.springframework + spring-web + ${spring-version} + + + + + sonatype-snapshots + https://oss.sonatype.org/content/repositories/snapshots + + true + + + + + {{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}} + ${java.version} + ${java.version} + 1.5.9 + 9.2.9.v20150224 + 2.22.2 + 4.12 + 1.1.7 + 2.5 + 1.1.0.Final + 4.2.5.RELEASE + 3.1.6 + UTF-8 + + diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/readme.md b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/readme.md new file mode 100644 index 00000000000..27925cedf44 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/readme.md @@ -0,0 +1,23 @@ + +# JAX-RS CXF 3 server application + +## Supported features +* Bean-Validation-API support +* Spring-configuration of Swagger, WADL and Endpoints +* Swagger-API is accessible (CXF3 Swagger2Feature) +* WADL is accessible (CXF WADL-Generator) +* Unit-tests include Gzip-Interceptors for demonstration + + +## Urls to access the REST API + +* Available services listing +http://localhost:8080/swagger-cxf-server/rest/services/ + +* Swagger API + http://localhost:8080/swagger-cxf-server/rest/services/swagger.json + +* CXF WADL + http://localhost:8080/swagger-cxf-server/rest/services?_wadl + + diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/web.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/web.mustache new file mode 100644 index 00000000000..9d905ae076b --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/web.mustache @@ -0,0 +1,23 @@ + + + + + contextConfigLocation + WEB-INF/context.xml + + + org.springframework.web.context.ContextLoaderListener + + + CXF Service Servlet + CXFServiceServlet + org.apache.cxf.transport.servlet.CXFServlet + 1 + + + CXFServiceServlet + /rest/* + + +