Skip to content

Commit 29c41ad

Browse files
committed
rollback java jxrs template
1 parent 180d48e commit 29c41ad

13 files changed

+359
-361
lines changed
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package {{apiPackage}};
22

33
public class ApiException extends Exception{
4-
private int code;
5-
public ApiException (int code, String msg) {
6-
super(msg);
7-
this.code = code;
8-
}
4+
private int code;
5+
public ApiException (int code, String msg) {
6+
super(msg);
7+
this.code = code;
8+
}
99
}

modules/swagger-codegen/src/main/resources/JavaJaxRS/ApiOriginFilter.mustache

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@ import javax.servlet.*;
66
import javax.servlet.http.HttpServletResponse;
77

88
public class ApiOriginFilter implements javax.servlet.Filter {
9-
@Override
10-
public void doFilter(ServletRequest request, ServletResponse response,
11-
FilterChain chain) throws IOException, ServletException {
12-
HttpServletResponse res = (HttpServletResponse) response;
13-
res.addHeader("Access-Control-Allow-Origin", "*");
14-
res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
15-
res.addHeader("Access-Control-Allow-Headers", "Content-Type");
16-
chain.doFilter(request, response);
17-
}
9+
@Override
10+
public void doFilter(ServletRequest request, ServletResponse response,
11+
FilterChain chain) throws IOException, ServletException {
12+
HttpServletResponse res = (HttpServletResponse) response;
13+
res.addHeader("Access-Control-Allow-Origin", "*");
14+
res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
15+
res.addHeader("Access-Control-Allow-Headers", "Content-Type");
16+
chain.doFilter(request, response);
17+
}
1818

19-
@Override
20-
public void destroy() {
21-
}
19+
@Override
20+
public void destroy() {
21+
}
2222

23-
@Override
24-
public void init(FilterConfig filterConfig) throws ServletException {
25-
}
23+
@Override
24+
public void init(FilterConfig filterConfig) throws ServletException {
25+
}
2626
}

modules/swagger-codegen/src/main/resources/JavaJaxRS/ApiResponseMessage.mustache

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -4,65 +4,65 @@ import javax.xml.bind.annotation.XmlTransient;
44

55
@javax.xml.bind.annotation.XmlRootElement
66
public class ApiResponseMessage {
7-
public static final int ERROR = 1;
8-
public static final int WARNING = 2;
9-
public static final int INFO = 3;
10-
public static final int OK = 4;
11-
public static final int TOO_BUSY = 5;
7+
public static final int ERROR = 1;
8+
public static final int WARNING = 2;
9+
public static final int INFO = 3;
10+
public static final int OK = 4;
11+
public static final int TOO_BUSY = 5;
1212
13-
int code;
14-
String type;
15-
String message;
13+
int code;
14+
String type;
15+
String message;
16+
17+
public ApiResponseMessage(){}
18+
19+
public ApiResponseMessage(int code, String message){
20+
this.code = code;
21+
switch(code){
22+
case ERROR:
23+
setType("error");
24+
break;
25+
case WARNING:
26+
setType("warning");
27+
break;
28+
case INFO:
29+
setType("info");
30+
break;
31+
case OK:
32+
setType("ok");
33+
break;
34+
case TOO_BUSY:
35+
setType("too busy");
36+
break;
37+
default:
38+
setType("unknown");
39+
break;
40+
}
41+
this.message = message;
42+
}
1643

17-
public ApiResponseMessage(){}
44+
@XmlTransient
45+
public int getCode() {
46+
return code;
47+
}
1848

19-
public ApiResponseMessage(int code, String message){
20-
this.code = code;
21-
switch(code){
22-
case ERROR:
23-
setType("error");
24-
break;
25-
case WARNING:
26-
setType("warning");
27-
break;
28-
case INFO:
29-
setType("info");
30-
break;
31-
case OK:
32-
setType("ok");
33-
break;
34-
case TOO_BUSY:
35-
setType("too busy");
36-
break;
37-
default:
38-
setType("unknown");
39-
break;
40-
}
41-
this.message = message;
42-
}
43-
44-
@XmlTransient
45-
public int getCode() {
46-
return code;
47-
}
48-
49-
public void setCode(int code) {
50-
this.code = code;
51-
}
49+
public void setCode(int code) {
50+
this.code = code;
51+
}
5252

53-
public String getType() {
54-
return type;
55-
}
53+
public String getType() {
54+
return type;
55+
}
5656

57-
public void setType(String type) {
58-
this.type = type;
59-
}
57+
public void setType(String type) {
58+
this.type = type;
59+
}
6060

61-
public String getMessage() {
62-
return message;
63-
}
61+
public String getMessage() {
62+
return message;
63+
}
6464

65-
public void setMessage(String message) {
66-
this.message = message;
67-
}
65+
public void setMessage(String message) {
66+
this.message = message;
67+
}
6868
}
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package {{apiPackage}};
22

33
public class NotFoundException extends ApiException {
4-
private int code;
5-
public NotFoundException (int code, String msg) {
6-
super(code, msg);
7-
this.code = code;
8-
}
4+
private int code;
5+
public NotFoundException (int code, String msg) {
6+
super(code, msg);
7+
this.code = code;
8+
}
99
}

modules/swagger-codegen/src/main/resources/JavaJaxRS/README.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Swagger generated server
22

33
## Overview
4-
This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the
4+
This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the
55
[swagger-spec](https://github.com/swagger-api/swagger-core/wiki) from a remote server, you can easily generate a server stub. This
66
is an example of building a swagger-enabled scalatra server.
77

modules/swagger-codegen/src/main/resources/JavaJaxRS/api.mustache

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,26 @@ import javax.ws.rs.*;
2727
{{#hasProduces}}@Produces({ {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
2828
@io.swagger.annotations.Api(value = "/{{baseName}}", description = "the {{baseName}} API")
2929
{{#operations}}
30-
public class {{classname}} {
31-
32-
private final {{classname}}Service delegate = {{classname}}ServiceFactory.get{{classname}}();
33-
34-
{{#operation}}
35-
@{{httpMethod}}
36-
{{#subresourceOperation}}@Path("{{path}}"){{/subresourceOperation}}
37-
{{#hasConsumes}}@Consumes({ {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
38-
{{#hasProduces}}@Produces({ {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
39-
@io.swagger.annotations.ApiOperation(value = "{{{summary}}}", notes = "{{{notes}}}", response = {{{returnType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}})
40-
@io.swagger.annotations.ApiResponses(value = { {{#responses}}
41-
@io.swagger.annotations.ApiResponse(code = {{{code}}}, message = "{{{message}}}"){{#hasMore}},
42-
{{/hasMore}}{{/responses}} })
43-
44-
public Response {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},
45-
{{/hasMore}}{{/allParams}})
46-
throws NotFoundException {
47-
return delegate.{{nickname}}({{#allParams}}{{#isFile}}fileDetail{{/isFile}}{{^isFile}}{{paramName}}{{/isFile}}{{#hasMore}},{{/hasMore}}{{/allParams}});
48-
}
49-
{{/operation}}
30+
public class {{classname}} {
31+
32+
private final {{classname}}Service delegate = {{classname}}ServiceFactory.get{{classname}}();
33+
34+
{{#operation}}
35+
@{{httpMethod}}
36+
{{#subresourceOperation}}@Path("{{path}}"){{/subresourceOperation}}
37+
{{#hasConsumes}}@Consumes({ {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
38+
{{#hasProduces}}@Produces({ {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
39+
@io.swagger.annotations.ApiOperation(value = "{{{summary}}}", notes = "{{{notes}}}", response = {{{returnType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}})
40+
@io.swagger.annotations.ApiResponses(value = { {{#responses}}
41+
@io.swagger.annotations.ApiResponse(code = {{{code}}}, message = "{{{message}}}"){{#hasMore}},
42+
{{/hasMore}}{{/responses}} })
43+
44+
public Response {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},
45+
{{/hasMore}}{{/allParams}})
46+
throws NotFoundException {
47+
return delegate.{{nickname}}({{#allParams}}{{#isFile}}fileDetail{{/isFile}}{{^isFile}}{{paramName}}{{/isFile}}{{#hasMore}},{{/hasMore}}{{/allParams}});
5048
}
49+
{{/operation}}
50+
}
5151
{{/operations}}
5252

modules/swagger-codegen/src/main/resources/JavaJaxRS/apiService.mustache

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ import com.sun.jersey.multipart.FormDataParam;
1919
import javax.ws.rs.core.Response;
2020

2121
{{#operations}}
22-
public abstract class {{classname}}Service {
23-
{{#operation}}
24-
public abstract Response {{nickname}}({{#allParams}}{{>serviceQueryParams}}{{>servicePathParams}}{{>serviceHeaderParams}}{{>serviceBodyParams}}{{>serviceFormParams}}{{#hasMore}},{{/hasMore}}{{/allParams}})
25-
throws NotFoundException;
26-
{{/operation}}
27-
}
22+
public abstract class {{classname}}Service {
23+
{{#operation}}
24+
public abstract Response {{nickname}}({{#allParams}}{{>serviceQueryParams}}{{>servicePathParams}}{{>serviceHeaderParams}}{{>serviceBodyParams}}{{>serviceFormParams}}{{#hasMore}},{{/hasMore}}{{/allParams}})
25+
throws NotFoundException;
26+
{{/operation}}
27+
}
2828
{{/operations}}

modules/swagger-codegen/src/main/resources/JavaJaxRS/apiServiceFactory.mustache

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import {{package}}.impl.{{classname}}ServiceImpl;
55

66
public class {{classname}}ServiceFactory {
77
8-
private final static {{classname}}Service service = new {{classname}}ServiceImpl();
8+
private final static {{classname}}Service service = new {{classname}}ServiceImpl();
99

10-
public static {{classname}}Service get{{classname}}()
11-
{
12-
return service;
13-
}
10+
public static {{classname}}Service get{{classname}}()
11+
{
12+
return service;
13+
}
1414
}

modules/swagger-codegen/src/main/resources/JavaJaxRS/apiServiceImpl.mustache

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ import com.sun.jersey.multipart.FormDataParam;
1919
import javax.ws.rs.core.Response;
2020

2121
{{#operations}}
22-
public class {{classname}}ServiceImpl extends {{classname}}Service {
23-
{{#operation}}
24-
@Override
25-
public Response {{nickname}}({{#allParams}}{{>serviceQueryParams}}{{>servicePathParams}}{{>serviceHeaderParams}}{{>serviceBodyParams}}{{>serviceFormParams}}{{#hasMore}},{{/hasMore}}{{/allParams}})
26-
throws NotFoundException {
27-
// do some magic!
28-
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
29-
}
30-
{{/operation}}
31-
}
22+
public class {{classname}}ServiceImpl extends {{classname}}Service {
23+
{{#operation}}
24+
@Override
25+
public Response {{nickname}}({{#allParams}}{{>serviceQueryParams}}{{>servicePathParams}}{{>serviceHeaderParams}}{{>serviceBodyParams}}{{>serviceFormParams}}{{#hasMore}},{{/hasMore}}{{/allParams}})
26+
throws NotFoundException {
27+
// do some magic!
28+
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
29+
}
30+
{{/operation}}
31+
}
3232
{{/operations}}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
{{#isFormParam}}{{#notFile}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}} {{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}})@FormParam("{{paramName}}") {{{dataType}}} {{paramName}}{{/notFile}}{{#isFile}}@ApiParam(value = "{{{description}}}") @FormDataParam("file") InputStream inputStream,
2-
@ApiParam(value = "file detail") @FormDataParam("file") FormDataContentDisposition fileDetail{{/isFile}}{{/isFormParam}}
2+
@ApiParam(value = "file detail") @FormDataParam("file") FormDataContentDisposition fileDetail{{/isFile}}{{/isFormParam}}

0 commit comments

Comments
 (0)