replace tab with 4-space in spring templates (#5389)

This commit is contained in:
wing328 2017-04-13 19:03:34 +08:00 committed by GitHub
parent c637157f9e
commit 4e6a342c13
38 changed files with 665 additions and 665 deletions

View File

@ -2,9 +2,9 @@ package {{apiPackage}};
{{>generatedAnnotation}} {{>generatedAnnotation}}
public class ApiException extends Exception{ public class ApiException extends Exception{
private int code; private int code;
public ApiException (int code, String msg) { public ApiException (int code, String msg) {
super(msg); super(msg);
this.code = code; this.code = code;
} }
} }

View File

@ -7,21 +7,21 @@ import javax.servlet.http.HttpServletResponse;
{{>generatedAnnotation}} {{>generatedAnnotation}}
public class ApiOriginFilter implements javax.servlet.Filter { public class ApiOriginFilter implements javax.servlet.Filter {
@Override @Override
public void doFilter(ServletRequest request, ServletResponse response, public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException { FilterChain chain) throws IOException, ServletException {
HttpServletResponse res = (HttpServletResponse) response; HttpServletResponse res = (HttpServletResponse) response;
res.addHeader("Access-Control-Allow-Origin", "*"); res.addHeader("Access-Control-Allow-Origin", "*");
res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT"); res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
res.addHeader("Access-Control-Allow-Headers", "Content-Type"); res.addHeader("Access-Control-Allow-Headers", "Content-Type");
chain.doFilter(request, response); chain.doFilter(request, response);
} }
@Override @Override
public void destroy() { public void destroy() {
} }
@Override @Override
public void init(FilterConfig filterConfig) throws ServletException { public void init(FilterConfig filterConfig) throws ServletException {
} }
} }

View File

@ -5,65 +5,65 @@ import javax.xml.bind.annotation.XmlTransient;
{{>generatedAnnotation}} {{>generatedAnnotation}}
@javax.xml.bind.annotation.XmlRootElement @javax.xml.bind.annotation.XmlRootElement
public class ApiResponseMessage { public class ApiResponseMessage {
public static final int ERROR = 1; public static final int ERROR = 1;
public static final int WARNING = 2; public static final int WARNING = 2;
public static final int INFO = 3; public static final int INFO = 3;
public static final int OK = 4; public static final int OK = 4;
public static final int TOO_BUSY = 5; public static final int TOO_BUSY = 5;
int code; int code;
String type; String type;
String message; String message;
public ApiResponseMessage(){} public ApiResponseMessage(){}
public ApiResponseMessage(int code, String message){ public ApiResponseMessage(int code, String message){
this.code = code; this.code = code;
switch(code){ switch(code){
case ERROR: case ERROR:
setType("error"); setType("error");
break; break;
case WARNING: case WARNING:
setType("warning"); setType("warning");
break; break;
case INFO: case INFO:
setType("info"); setType("info");
break; break;
case OK: case OK:
setType("ok"); setType("ok");
break; break;
case TOO_BUSY: case TOO_BUSY:
setType("too busy"); setType("too busy");
break; break;
default: default:
setType("unknown"); setType("unknown");
break; break;
} }
this.message = message; this.message = message;
} }
@XmlTransient @XmlTransient
public int getCode() { public int getCode() {
return code; return code;
} }
public void setCode(int code) { public void setCode(int code) {
this.code = code; this.code = code;
} }
public String getType() { public String getType() {
return type; return type;
} }
public void setType(String type) { public void setType(String type) {
this.type = type; this.type = type;
} }
public String getMessage() { public String getMessage() {
return message; return message;
} }
public void setMessage(String message) { public void setMessage(String message) {
this.message = message; this.message = message;
} }
} }

View File

@ -8,9 +8,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
*/ */
@Controller @Controller
public class HomeController { public class HomeController {
@RequestMapping(value = "/") @RequestMapping(value = "/")
public String index() { public String index() {
System.out.println("swagger-ui.html"); System.out.println("swagger-ui.html");
return "redirect:swagger-ui.html"; return "redirect:swagger-ui.html";
} }
} }

View File

@ -13,24 +13,24 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
@ComponentScan(basePackages = "{{basePackage}}") @ComponentScan(basePackages = "{{basePackage}}")
public class Swagger2SpringBoot implements CommandLineRunner { public class Swagger2SpringBoot implements CommandLineRunner {
@Override @Override
public void run(String... arg0) throws Exception { public void run(String... arg0) throws Exception {
if (arg0.length > 0 && arg0[0].equals("exitcode")) { if (arg0.length > 0 && arg0[0].equals("exitcode")) {
throw new ExitException(); throw new ExitException();
} }
} }
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
new SpringApplication(Swagger2SpringBoot.class).run(args); new SpringApplication(Swagger2SpringBoot.class).run(args);
} }
class ExitException extends RuntimeException implements ExitCodeGenerator { class ExitException extends RuntimeException implements ExitCodeGenerator {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Override @Override
public int getExitCode() { public int getExitCode() {
return 10; return 10;
} }
} }
} }

View File

@ -2,9 +2,9 @@ package {{apiPackage}};
{{>generatedAnnotation}} {{>generatedAnnotation}}
public class NotFoundException extends ApiException { public class NotFoundException extends ApiException {
private int code; private int code;
public NotFoundException (int code, String msg) { public NotFoundException (int code, String msg) {
super(code, msg); super(code, msg);
this.code = code; this.code = code;
} }
} }

View File

@ -2,9 +2,9 @@ package io.swagger.api;
public class ApiException extends Exception{ public class ApiException extends Exception{
private int code; private int code;
public ApiException (int code, String msg) { public ApiException (int code, String msg) {
super(msg); super(msg);
this.code = code; this.code = code;
} }
} }

View File

@ -7,21 +7,21 @@ import javax.servlet.http.HttpServletResponse;
public class ApiOriginFilter implements javax.servlet.Filter { public class ApiOriginFilter implements javax.servlet.Filter {
@Override @Override
public void doFilter(ServletRequest request, ServletResponse response, public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException { FilterChain chain) throws IOException, ServletException {
HttpServletResponse res = (HttpServletResponse) response; HttpServletResponse res = (HttpServletResponse) response;
res.addHeader("Access-Control-Allow-Origin", "*"); res.addHeader("Access-Control-Allow-Origin", "*");
res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT"); res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
res.addHeader("Access-Control-Allow-Headers", "Content-Type"); res.addHeader("Access-Control-Allow-Headers", "Content-Type");
chain.doFilter(request, response); chain.doFilter(request, response);
} }
@Override @Override
public void destroy() { public void destroy() {
} }
@Override @Override
public void init(FilterConfig filterConfig) throws ServletException { public void init(FilterConfig filterConfig) throws ServletException {
} }
} }

View File

@ -5,65 +5,65 @@ import javax.xml.bind.annotation.XmlTransient;
@javax.xml.bind.annotation.XmlRootElement @javax.xml.bind.annotation.XmlRootElement
public class ApiResponseMessage { public class ApiResponseMessage {
public static final int ERROR = 1; public static final int ERROR = 1;
public static final int WARNING = 2; public static final int WARNING = 2;
public static final int INFO = 3; public static final int INFO = 3;
public static final int OK = 4; public static final int OK = 4;
public static final int TOO_BUSY = 5; public static final int TOO_BUSY = 5;
int code; int code;
String type; String type;
String message; String message;
public ApiResponseMessage(){} public ApiResponseMessage(){}
public ApiResponseMessage(int code, String message){ public ApiResponseMessage(int code, String message){
this.code = code; this.code = code;
switch(code){ switch(code){
case ERROR: case ERROR:
setType("error"); setType("error");
break; break;
case WARNING: case WARNING:
setType("warning"); setType("warning");
break; break;
case INFO: case INFO:
setType("info"); setType("info");
break; break;
case OK: case OK:
setType("ok"); setType("ok");
break; break;
case TOO_BUSY: case TOO_BUSY:
setType("too busy"); setType("too busy");
break; break;
default: default:
setType("unknown"); setType("unknown");
break; break;
} }
this.message = message; this.message = message;
} }
@XmlTransient @XmlTransient
public int getCode() { public int getCode() {
return code; return code;
} }
public void setCode(int code) { public void setCode(int code) {
this.code = code; this.code = code;
} }
public String getType() { public String getType() {
return type; return type;
} }
public void setType(String type) { public void setType(String type) {
this.type = type; this.type = type;
} }
public String getMessage() { public String getMessage() {
return message; return message;
} }
public void setMessage(String message) { public void setMessage(String message) {
this.message = message; this.message = message;
} }
} }

View File

@ -2,9 +2,9 @@ package io.swagger.api;
public class NotFoundException extends ApiException { public class NotFoundException extends ApiException {
private int code; private int code;
public NotFoundException (int code, String msg) { public NotFoundException (int code, String msg) {
super(code, msg); super(code, msg);
this.code = code; this.code = code;
} }
} }

View File

@ -2,9 +2,9 @@ package io.swagger.api;
public class ApiException extends Exception{ public class ApiException extends Exception{
private int code; private int code;
public ApiException (int code, String msg) { public ApiException (int code, String msg) {
super(msg); super(msg);
this.code = code; this.code = code;
} }
} }

View File

@ -7,21 +7,21 @@ import javax.servlet.http.HttpServletResponse;
public class ApiOriginFilter implements javax.servlet.Filter { public class ApiOriginFilter implements javax.servlet.Filter {
@Override @Override
public void doFilter(ServletRequest request, ServletResponse response, public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException { FilterChain chain) throws IOException, ServletException {
HttpServletResponse res = (HttpServletResponse) response; HttpServletResponse res = (HttpServletResponse) response;
res.addHeader("Access-Control-Allow-Origin", "*"); res.addHeader("Access-Control-Allow-Origin", "*");
res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT"); res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
res.addHeader("Access-Control-Allow-Headers", "Content-Type"); res.addHeader("Access-Control-Allow-Headers", "Content-Type");
chain.doFilter(request, response); chain.doFilter(request, response);
} }
@Override @Override
public void destroy() { public void destroy() {
} }
@Override @Override
public void init(FilterConfig filterConfig) throws ServletException { public void init(FilterConfig filterConfig) throws ServletException {
} }
} }

View File

@ -5,65 +5,65 @@ import javax.xml.bind.annotation.XmlTransient;
@javax.xml.bind.annotation.XmlRootElement @javax.xml.bind.annotation.XmlRootElement
public class ApiResponseMessage { public class ApiResponseMessage {
public static final int ERROR = 1; public static final int ERROR = 1;
public static final int WARNING = 2; public static final int WARNING = 2;
public static final int INFO = 3; public static final int INFO = 3;
public static final int OK = 4; public static final int OK = 4;
public static final int TOO_BUSY = 5; public static final int TOO_BUSY = 5;
int code; int code;
String type; String type;
String message; String message;
public ApiResponseMessage(){} public ApiResponseMessage(){}
public ApiResponseMessage(int code, String message){ public ApiResponseMessage(int code, String message){
this.code = code; this.code = code;
switch(code){ switch(code){
case ERROR: case ERROR:
setType("error"); setType("error");
break; break;
case WARNING: case WARNING:
setType("warning"); setType("warning");
break; break;
case INFO: case INFO:
setType("info"); setType("info");
break; break;
case OK: case OK:
setType("ok"); setType("ok");
break; break;
case TOO_BUSY: case TOO_BUSY:
setType("too busy"); setType("too busy");
break; break;
default: default:
setType("unknown"); setType("unknown");
break; break;
} }
this.message = message; this.message = message;
} }
@XmlTransient @XmlTransient
public int getCode() { public int getCode() {
return code; return code;
} }
public void setCode(int code) { public void setCode(int code) {
this.code = code; this.code = code;
} }
public String getType() { public String getType() {
return type; return type;
} }
public void setType(String type) { public void setType(String type) {
this.type = type; this.type = type;
} }
public String getMessage() { public String getMessage() {
return message; return message;
} }
public void setMessage(String message) { public void setMessage(String message) {
this.message = message; this.message = message;
} }
} }

View File

@ -2,9 +2,9 @@ package io.swagger.api;
public class NotFoundException extends ApiException { public class NotFoundException extends ApiException {
private int code; private int code;
public NotFoundException (int code, String msg) { public NotFoundException (int code, String msg) {
super(code, msg); super(code, msg);
this.code = code; this.code = code;
} }
} }

View File

@ -13,24 +13,24 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
@ComponentScan(basePackages = "io.swagger") @ComponentScan(basePackages = "io.swagger")
public class Swagger2SpringBoot implements CommandLineRunner { public class Swagger2SpringBoot implements CommandLineRunner {
@Override @Override
public void run(String... arg0) throws Exception { public void run(String... arg0) throws Exception {
if (arg0.length > 0 && arg0[0].equals("exitcode")) { if (arg0.length > 0 && arg0[0].equals("exitcode")) {
throw new ExitException(); throw new ExitException();
} }
} }
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
new SpringApplication(Swagger2SpringBoot.class).run(args); new SpringApplication(Swagger2SpringBoot.class).run(args);
} }
class ExitException extends RuntimeException implements ExitCodeGenerator { class ExitException extends RuntimeException implements ExitCodeGenerator {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Override @Override
public int getExitCode() { public int getExitCode() {
return 10; return 10;
} }
} }
} }

View File

@ -2,9 +2,9 @@ package io.swagger.api;
public class ApiException extends Exception{ public class ApiException extends Exception{
private int code; private int code;
public ApiException (int code, String msg) { public ApiException (int code, String msg) {
super(msg); super(msg);
this.code = code; this.code = code;
} }
} }

View File

@ -7,21 +7,21 @@ import javax.servlet.http.HttpServletResponse;
public class ApiOriginFilter implements javax.servlet.Filter { public class ApiOriginFilter implements javax.servlet.Filter {
@Override @Override
public void doFilter(ServletRequest request, ServletResponse response, public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException { FilterChain chain) throws IOException, ServletException {
HttpServletResponse res = (HttpServletResponse) response; HttpServletResponse res = (HttpServletResponse) response;
res.addHeader("Access-Control-Allow-Origin", "*"); res.addHeader("Access-Control-Allow-Origin", "*");
res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT"); res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
res.addHeader("Access-Control-Allow-Headers", "Content-Type"); res.addHeader("Access-Control-Allow-Headers", "Content-Type");
chain.doFilter(request, response); chain.doFilter(request, response);
} }
@Override @Override
public void destroy() { public void destroy() {
} }
@Override @Override
public void init(FilterConfig filterConfig) throws ServletException { public void init(FilterConfig filterConfig) throws ServletException {
} }
} }

View File

@ -5,65 +5,65 @@ import javax.xml.bind.annotation.XmlTransient;
@javax.xml.bind.annotation.XmlRootElement @javax.xml.bind.annotation.XmlRootElement
public class ApiResponseMessage { public class ApiResponseMessage {
public static final int ERROR = 1; public static final int ERROR = 1;
public static final int WARNING = 2; public static final int WARNING = 2;
public static final int INFO = 3; public static final int INFO = 3;
public static final int OK = 4; public static final int OK = 4;
public static final int TOO_BUSY = 5; public static final int TOO_BUSY = 5;
int code; int code;
String type; String type;
String message; String message;
public ApiResponseMessage(){} public ApiResponseMessage(){}
public ApiResponseMessage(int code, String message){ public ApiResponseMessage(int code, String message){
this.code = code; this.code = code;
switch(code){ switch(code){
case ERROR: case ERROR:
setType("error"); setType("error");
break; break;
case WARNING: case WARNING:
setType("warning"); setType("warning");
break; break;
case INFO: case INFO:
setType("info"); setType("info");
break; break;
case OK: case OK:
setType("ok"); setType("ok");
break; break;
case TOO_BUSY: case TOO_BUSY:
setType("too busy"); setType("too busy");
break; break;
default: default:
setType("unknown"); setType("unknown");
break; break;
} }
this.message = message; this.message = message;
} }
@XmlTransient @XmlTransient
public int getCode() { public int getCode() {
return code; return code;
} }
public void setCode(int code) { public void setCode(int code) {
this.code = code; this.code = code;
} }
public String getType() { public String getType() {
return type; return type;
} }
public void setType(String type) { public void setType(String type) {
this.type = type; this.type = type;
} }
public String getMessage() { public String getMessage() {
return message; return message;
} }
public void setMessage(String message) { public void setMessage(String message) {
this.message = message; this.message = message;
} }
} }

View File

@ -2,9 +2,9 @@ package io.swagger.api;
public class NotFoundException extends ApiException { public class NotFoundException extends ApiException {
private int code; private int code;
public NotFoundException (int code, String msg) { public NotFoundException (int code, String msg) {
super(code, msg); super(code, msg);
this.code = code; this.code = code;
} }
} }

View File

@ -8,9 +8,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
*/ */
@Controller @Controller
public class HomeController { public class HomeController {
@RequestMapping(value = "/") @RequestMapping(value = "/")
public String index() { public String index() {
System.out.println("swagger-ui.html"); System.out.println("swagger-ui.html");
return "redirect:swagger-ui.html"; return "redirect:swagger-ui.html";
} }
} }

View File

@ -13,24 +13,24 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
@ComponentScan(basePackages = "io.swagger") @ComponentScan(basePackages = "io.swagger")
public class Swagger2SpringBoot implements CommandLineRunner { public class Swagger2SpringBoot implements CommandLineRunner {
@Override @Override
public void run(String... arg0) throws Exception { public void run(String... arg0) throws Exception {
if (arg0.length > 0 && arg0[0].equals("exitcode")) { if (arg0.length > 0 && arg0[0].equals("exitcode")) {
throw new ExitException(); throw new ExitException();
} }
} }
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
new SpringApplication(Swagger2SpringBoot.class).run(args); new SpringApplication(Swagger2SpringBoot.class).run(args);
} }
class ExitException extends RuntimeException implements ExitCodeGenerator { class ExitException extends RuntimeException implements ExitCodeGenerator {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Override @Override
public int getExitCode() { public int getExitCode() {
return 10; return 10;
} }
} }
} }

View File

@ -2,9 +2,9 @@ package io.swagger.api;
public class ApiException extends Exception{ public class ApiException extends Exception{
private int code; private int code;
public ApiException (int code, String msg) { public ApiException (int code, String msg) {
super(msg); super(msg);
this.code = code; this.code = code;
} }
} }

View File

@ -7,21 +7,21 @@ import javax.servlet.http.HttpServletResponse;
public class ApiOriginFilter implements javax.servlet.Filter { public class ApiOriginFilter implements javax.servlet.Filter {
@Override @Override
public void doFilter(ServletRequest request, ServletResponse response, public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException { FilterChain chain) throws IOException, ServletException {
HttpServletResponse res = (HttpServletResponse) response; HttpServletResponse res = (HttpServletResponse) response;
res.addHeader("Access-Control-Allow-Origin", "*"); res.addHeader("Access-Control-Allow-Origin", "*");
res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT"); res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
res.addHeader("Access-Control-Allow-Headers", "Content-Type"); res.addHeader("Access-Control-Allow-Headers", "Content-Type");
chain.doFilter(request, response); chain.doFilter(request, response);
} }
@Override @Override
public void destroy() { public void destroy() {
} }
@Override @Override
public void init(FilterConfig filterConfig) throws ServletException { public void init(FilterConfig filterConfig) throws ServletException {
} }
} }

View File

@ -5,65 +5,65 @@ import javax.xml.bind.annotation.XmlTransient;
@javax.xml.bind.annotation.XmlRootElement @javax.xml.bind.annotation.XmlRootElement
public class ApiResponseMessage { public class ApiResponseMessage {
public static final int ERROR = 1; public static final int ERROR = 1;
public static final int WARNING = 2; public static final int WARNING = 2;
public static final int INFO = 3; public static final int INFO = 3;
public static final int OK = 4; public static final int OK = 4;
public static final int TOO_BUSY = 5; public static final int TOO_BUSY = 5;
int code; int code;
String type; String type;
String message; String message;
public ApiResponseMessage(){} public ApiResponseMessage(){}
public ApiResponseMessage(int code, String message){ public ApiResponseMessage(int code, String message){
this.code = code; this.code = code;
switch(code){ switch(code){
case ERROR: case ERROR:
setType("error"); setType("error");
break; break;
case WARNING: case WARNING:
setType("warning"); setType("warning");
break; break;
case INFO: case INFO:
setType("info"); setType("info");
break; break;
case OK: case OK:
setType("ok"); setType("ok");
break; break;
case TOO_BUSY: case TOO_BUSY:
setType("too busy"); setType("too busy");
break; break;
default: default:
setType("unknown"); setType("unknown");
break; break;
} }
this.message = message; this.message = message;
} }
@XmlTransient @XmlTransient
public int getCode() { public int getCode() {
return code; return code;
} }
public void setCode(int code) { public void setCode(int code) {
this.code = code; this.code = code;
} }
public String getType() { public String getType() {
return type; return type;
} }
public void setType(String type) { public void setType(String type) {
this.type = type; this.type = type;
} }
public String getMessage() { public String getMessage() {
return message; return message;
} }
public void setMessage(String message) { public void setMessage(String message) {
this.message = message; this.message = message;
} }
} }

View File

@ -2,9 +2,9 @@ package io.swagger.api;
public class NotFoundException extends ApiException { public class NotFoundException extends ApiException {
private int code; private int code;
public NotFoundException (int code, String msg) { public NotFoundException (int code, String msg) {
super(code, msg); super(code, msg);
this.code = code; this.code = code;
} }
} }

View File

@ -8,9 +8,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
*/ */
@Controller @Controller
public class HomeController { public class HomeController {
@RequestMapping(value = "/") @RequestMapping(value = "/")
public String index() { public String index() {
System.out.println("swagger-ui.html"); System.out.println("swagger-ui.html");
return "redirect:swagger-ui.html"; return "redirect:swagger-ui.html";
} }
} }

View File

@ -13,24 +13,24 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
@ComponentScan(basePackages = "io.swagger") @ComponentScan(basePackages = "io.swagger")
public class Swagger2SpringBoot implements CommandLineRunner { public class Swagger2SpringBoot implements CommandLineRunner {
@Override @Override
public void run(String... arg0) throws Exception { public void run(String... arg0) throws Exception {
if (arg0.length > 0 && arg0[0].equals("exitcode")) { if (arg0.length > 0 && arg0[0].equals("exitcode")) {
throw new ExitException(); throw new ExitException();
} }
} }
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
new SpringApplication(Swagger2SpringBoot.class).run(args); new SpringApplication(Swagger2SpringBoot.class).run(args);
} }
class ExitException extends RuntimeException implements ExitCodeGenerator { class ExitException extends RuntimeException implements ExitCodeGenerator {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Override @Override
public int getExitCode() { public int getExitCode() {
return 10; return 10;
} }
} }
} }

View File

@ -2,9 +2,9 @@ package io.swagger.api;
public class ApiException extends Exception{ public class ApiException extends Exception{
private int code; private int code;
public ApiException (int code, String msg) { public ApiException (int code, String msg) {
super(msg); super(msg);
this.code = code; this.code = code;
} }
} }

View File

@ -7,21 +7,21 @@ import javax.servlet.http.HttpServletResponse;
public class ApiOriginFilter implements javax.servlet.Filter { public class ApiOriginFilter implements javax.servlet.Filter {
@Override @Override
public void doFilter(ServletRequest request, ServletResponse response, public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException { FilterChain chain) throws IOException, ServletException {
HttpServletResponse res = (HttpServletResponse) response; HttpServletResponse res = (HttpServletResponse) response;
res.addHeader("Access-Control-Allow-Origin", "*"); res.addHeader("Access-Control-Allow-Origin", "*");
res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT"); res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
res.addHeader("Access-Control-Allow-Headers", "Content-Type"); res.addHeader("Access-Control-Allow-Headers", "Content-Type");
chain.doFilter(request, response); chain.doFilter(request, response);
} }
@Override @Override
public void destroy() { public void destroy() {
} }
@Override @Override
public void init(FilterConfig filterConfig) throws ServletException { public void init(FilterConfig filterConfig) throws ServletException {
} }
} }

View File

@ -5,65 +5,65 @@ import javax.xml.bind.annotation.XmlTransient;
@javax.xml.bind.annotation.XmlRootElement @javax.xml.bind.annotation.XmlRootElement
public class ApiResponseMessage { public class ApiResponseMessage {
public static final int ERROR = 1; public static final int ERROR = 1;
public static final int WARNING = 2; public static final int WARNING = 2;
public static final int INFO = 3; public static final int INFO = 3;
public static final int OK = 4; public static final int OK = 4;
public static final int TOO_BUSY = 5; public static final int TOO_BUSY = 5;
int code; int code;
String type; String type;
String message; String message;
public ApiResponseMessage(){} public ApiResponseMessage(){}
public ApiResponseMessage(int code, String message){ public ApiResponseMessage(int code, String message){
this.code = code; this.code = code;
switch(code){ switch(code){
case ERROR: case ERROR:
setType("error"); setType("error");
break; break;
case WARNING: case WARNING:
setType("warning"); setType("warning");
break; break;
case INFO: case INFO:
setType("info"); setType("info");
break; break;
case OK: case OK:
setType("ok"); setType("ok");
break; break;
case TOO_BUSY: case TOO_BUSY:
setType("too busy"); setType("too busy");
break; break;
default: default:
setType("unknown"); setType("unknown");
break; break;
} }
this.message = message; this.message = message;
} }
@XmlTransient @XmlTransient
public int getCode() { public int getCode() {
return code; return code;
} }
public void setCode(int code) { public void setCode(int code) {
this.code = code; this.code = code;
} }
public String getType() { public String getType() {
return type; return type;
} }
public void setType(String type) { public void setType(String type) {
this.type = type; this.type = type;
} }
public String getMessage() { public String getMessage() {
return message; return message;
} }
public void setMessage(String message) { public void setMessage(String message) {
this.message = message; this.message = message;
} }
} }

View File

@ -2,9 +2,9 @@ package io.swagger.api;
public class NotFoundException extends ApiException { public class NotFoundException extends ApiException {
private int code; private int code;
public NotFoundException (int code, String msg) { public NotFoundException (int code, String msg) {
super(code, msg); super(code, msg);
this.code = code; this.code = code;
} }
} }

View File

@ -8,9 +8,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
*/ */
@Controller @Controller
public class HomeController { public class HomeController {
@RequestMapping(value = "/") @RequestMapping(value = "/")
public String index() { public String index() {
System.out.println("swagger-ui.html"); System.out.println("swagger-ui.html");
return "redirect:swagger-ui.html"; return "redirect:swagger-ui.html";
} }
} }

View File

@ -13,24 +13,24 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
@ComponentScan(basePackages = "io.swagger") @ComponentScan(basePackages = "io.swagger")
public class Swagger2SpringBoot implements CommandLineRunner { public class Swagger2SpringBoot implements CommandLineRunner {
@Override @Override
public void run(String... arg0) throws Exception { public void run(String... arg0) throws Exception {
if (arg0.length > 0 && arg0[0].equals("exitcode")) { if (arg0.length > 0 && arg0[0].equals("exitcode")) {
throw new ExitException(); throw new ExitException();
} }
} }
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
new SpringApplication(Swagger2SpringBoot.class).run(args); new SpringApplication(Swagger2SpringBoot.class).run(args);
} }
class ExitException extends RuntimeException implements ExitCodeGenerator { class ExitException extends RuntimeException implements ExitCodeGenerator {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Override @Override
public int getExitCode() { public int getExitCode() {
return 10; return 10;
} }
} }
} }

View File

@ -2,9 +2,9 @@ package io.swagger.api;
public class ApiException extends Exception{ public class ApiException extends Exception{
private int code; private int code;
public ApiException (int code, String msg) { public ApiException (int code, String msg) {
super(msg); super(msg);
this.code = code; this.code = code;
} }
} }

View File

@ -7,21 +7,21 @@ import javax.servlet.http.HttpServletResponse;
public class ApiOriginFilter implements javax.servlet.Filter { public class ApiOriginFilter implements javax.servlet.Filter {
@Override @Override
public void doFilter(ServletRequest request, ServletResponse response, public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException { FilterChain chain) throws IOException, ServletException {
HttpServletResponse res = (HttpServletResponse) response; HttpServletResponse res = (HttpServletResponse) response;
res.addHeader("Access-Control-Allow-Origin", "*"); res.addHeader("Access-Control-Allow-Origin", "*");
res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT"); res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
res.addHeader("Access-Control-Allow-Headers", "Content-Type"); res.addHeader("Access-Control-Allow-Headers", "Content-Type");
chain.doFilter(request, response); chain.doFilter(request, response);
} }
@Override @Override
public void destroy() { public void destroy() {
} }
@Override @Override
public void init(FilterConfig filterConfig) throws ServletException { public void init(FilterConfig filterConfig) throws ServletException {
} }
} }

View File

@ -5,65 +5,65 @@ import javax.xml.bind.annotation.XmlTransient;
@javax.xml.bind.annotation.XmlRootElement @javax.xml.bind.annotation.XmlRootElement
public class ApiResponseMessage { public class ApiResponseMessage {
public static final int ERROR = 1; public static final int ERROR = 1;
public static final int WARNING = 2; public static final int WARNING = 2;
public static final int INFO = 3; public static final int INFO = 3;
public static final int OK = 4; public static final int OK = 4;
public static final int TOO_BUSY = 5; public static final int TOO_BUSY = 5;
int code; int code;
String type; String type;
String message; String message;
public ApiResponseMessage(){} public ApiResponseMessage(){}
public ApiResponseMessage(int code, String message){ public ApiResponseMessage(int code, String message){
this.code = code; this.code = code;
switch(code){ switch(code){
case ERROR: case ERROR:
setType("error"); setType("error");
break; break;
case WARNING: case WARNING:
setType("warning"); setType("warning");
break; break;
case INFO: case INFO:
setType("info"); setType("info");
break; break;
case OK: case OK:
setType("ok"); setType("ok");
break; break;
case TOO_BUSY: case TOO_BUSY:
setType("too busy"); setType("too busy");
break; break;
default: default:
setType("unknown"); setType("unknown");
break; break;
} }
this.message = message; this.message = message;
} }
@XmlTransient @XmlTransient
public int getCode() { public int getCode() {
return code; return code;
} }
public void setCode(int code) { public void setCode(int code) {
this.code = code; this.code = code;
} }
public String getType() { public String getType() {
return type; return type;
} }
public void setType(String type) { public void setType(String type) {
this.type = type; this.type = type;
} }
public String getMessage() { public String getMessage() {
return message; return message;
} }
public void setMessage(String message) { public void setMessage(String message) {
this.message = message; this.message = message;
} }
} }

View File

@ -2,9 +2,9 @@ package io.swagger.api;
public class NotFoundException extends ApiException { public class NotFoundException extends ApiException {
private int code; private int code;
public NotFoundException (int code, String msg) { public NotFoundException (int code, String msg) {
super(code, msg); super(code, msg);
this.code = code; this.code = code;
} }
} }

View File

@ -8,9 +8,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
*/ */
@Controller @Controller
public class HomeController { public class HomeController {
@RequestMapping(value = "/") @RequestMapping(value = "/")
public String index() { public String index() {
System.out.println("swagger-ui.html"); System.out.println("swagger-ui.html");
return "redirect:swagger-ui.html"; return "redirect:swagger-ui.html";
} }
} }