forked from swagger-api/swagger-codegen
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add complete WAR to cxf-server swagger-api#2017
- Loading branch information
Showing
8 changed files
with
229 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/apiServiceImpl.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/context.xml.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<beans xmlns="http://www.springframework.org/schema/beans" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:cxf="http://cxf.apache.org/core" | ||
xmlns:jaxrs="http://cxf.apache.org/jaxrs" | ||
xmlns:jee="http://www.springframework.org/schema/jee" | ||
xmlns:context="http://www.springframework.org/schema/context" | ||
xsi:schemaLocation="http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd | ||
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.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://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd"> | ||
|
||
|
||
|
||
<import resource="classpath:META-INF/cxf/cxf.xml" /> | ||
|
||
<!-- JAXRS providers --> | ||
<bean id="jsonProvider" class="com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider" /> | ||
<bean id="multipartProvider" class="org.apache.cxf.jaxrs.provider.MultipartProvider" /> | ||
|
||
<!-- Controller --> | ||
{{#apiInfo}} | ||
{{#apis}} | ||
<bean id="{{classname}}" class="{{package}}.impl.{{classname}}ServiceImpl" /> | ||
{{/apis}} | ||
{{/apiInfo}} | ||
|
||
<!-- CXF Swagger2Feature --> | ||
<bean id="swagger2Feature" class="org.apache.cxf.jaxrs.swagger.Swagger2Feature"> | ||
<!--property name="basePath" value="/"/> | ||
<property name="contact" value="${swagger.contact}" /> | ||
<property name="title" value="${swagger.title}" /> | ||
<property name="version" value="${swagger.version}" /> | ||
<property name="description" value="${swagger.description}" /> | ||
<property name="license" value="${swagger.license}" /> | ||
<property name="licenseUrl" value="${swagger.licenseUrl}" /--> | ||
</bean> | ||
|
||
<cxf:bus> | ||
<cxf:features> | ||
<cxf:logging /> | ||
</cxf:features> | ||
</cxf:bus> | ||
|
||
|
||
<bean id="wadlGenerator" | ||
class="org.apache.cxf.jaxrs.model.wadl.WadlGenerator"> | ||
<property name="linkJsonToXmlSchema" value="true" /> | ||
</bean> | ||
|
||
<!-- REST server --> | ||
<jaxrs:server id="restServer" address="/services"> | ||
<jaxrs:serviceBeans> | ||
{{#apiInfo}} | ||
{{#apis}} | ||
<ref bean="{{classname}}" /> | ||
{{/apis}} | ||
{{/apiInfo}} | ||
</jaxrs:serviceBeans> | ||
<jaxrs:providers> | ||
<ref bean="jsonProvider" /> | ||
<ref bean="multipartProvider" /> | ||
<ref bean="wadlGenerator" /> | ||
</jaxrs:providers> | ||
<jaxrs:features> | ||
<ref bean="swagger2Feature" /> | ||
</jaxrs:features> | ||
</jaxrs:server> | ||
|
||
</beans> |
7 changes: 7 additions & 0 deletions
7
modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/jboss-web.xml.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 2.3//EN" "http://www.jboss.org/j2ee/dtd/jboss-web_3_2.dtd"> | ||
<jboss-web> | ||
|
||
<context-root>swagger-cxf-server</context-root> | ||
|
||
</jboss-web> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/web.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="ISO-8859-1"?> | ||
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" version="3.0" | ||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> | ||
|
||
<context-param> | ||
<param-name>contextConfigLocation</param-name> | ||
<param-value>WEB-INF/context.xml</param-value> | ||
</context-param> | ||
<listener> | ||
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> | ||
</listener> | ||
<servlet> | ||
<display-name>CXF Service Servlet</display-name> | ||
<servlet-name>CXFServiceServlet</servlet-name> | ||
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class> | ||
<load-on-startup>1</load-on-startup> | ||
</servlet> | ||
<servlet-mapping> | ||
<servlet-name>CXFServiceServlet</servlet-name> | ||
<url-pattern>/rest/*</url-pattern> | ||
</servlet-mapping> | ||
|
||
</web-app> |