forked from loafle/openapi-generator-original
Merge remote-tracking branch 'origin/master' into 2.3.0
This commit is contained in:
commit
c7ccb1a9a9
@ -796,6 +796,7 @@ Here are some companies/projects using Swagger Codegen in production. To add you
|
|||||||
- [Svenska Spel AB](https://www.svenskaspel.se/)
|
- [Svenska Spel AB](https://www.svenskaspel.se/)
|
||||||
- [TaskData](http://www.taskdata.com/)
|
- [TaskData](http://www.taskdata.com/)
|
||||||
- [ThoughtWorks](https://www.thoughtworks.com)
|
- [ThoughtWorks](https://www.thoughtworks.com)
|
||||||
|
- [Trexle](https://trexle.com/)
|
||||||
- [Upwork](http://upwork.com/)
|
- [Upwork](http://upwork.com/)
|
||||||
- [uShip](https://www.uship.com/)
|
- [uShip](https://www.uship.com/)
|
||||||
- [VMware](https://vmware.com/)
|
- [VMware](https://vmware.com/)
|
||||||
|
@ -91,6 +91,7 @@ public class CodegenParameter {
|
|||||||
output.dataFormat = this.dataFormat;
|
output.dataFormat = this.dataFormat;
|
||||||
output.collectionFormat = this.collectionFormat;
|
output.collectionFormat = this.collectionFormat;
|
||||||
output.isCollectionFormatMulti = this.isCollectionFormatMulti;
|
output.isCollectionFormatMulti = this.isCollectionFormatMulti;
|
||||||
|
output.isPrimitiveType = this.isPrimitiveType;
|
||||||
output.description = this.description;
|
output.description = this.description;
|
||||||
output.unescapedDescription = this.unescapedDescription;
|
output.unescapedDescription = this.unescapedDescription;
|
||||||
output.baseType = this.baseType;
|
output.baseType = this.baseType;
|
||||||
|
@ -1739,12 +1739,16 @@ public class DefaultCodegen {
|
|||||||
CodegenProperty cp = fromProperty(property.name, ap.getItems());
|
CodegenProperty cp = fromProperty(property.name, ap.getItems());
|
||||||
updatePropertyForArray(property, cp);
|
updatePropertyForArray(property, cp);
|
||||||
} else if (p instanceof MapProperty) {
|
} else if (p instanceof MapProperty) {
|
||||||
|
MapProperty ap = (MapProperty) p;
|
||||||
|
|
||||||
property.isContainer = true;
|
property.isContainer = true;
|
||||||
property.isMapContainer = true;
|
property.isMapContainer = true;
|
||||||
property.containerType = "map";
|
property.containerType = "map";
|
||||||
property.baseType = getSwaggerType(p);
|
property.baseType = getSwaggerType(p);
|
||||||
|
property.minItems = ap.getMinProperties();
|
||||||
|
property.maxItems = ap.getMaxProperties();
|
||||||
|
|
||||||
// handle inner property
|
// handle inner property
|
||||||
MapProperty ap = (MapProperty) p;
|
|
||||||
CodegenProperty cp = fromProperty("inner", ap.getAdditionalProperties());
|
CodegenProperty cp = fromProperty("inner", ap.getAdditionalProperties());
|
||||||
updatePropertyForMap(property, cp);
|
updatePropertyForMap(property, cp);
|
||||||
} else {
|
} else {
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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(int code, String message){
|
|
||||||
this.code = code;
|
|
||||||
switch(code){
|
|
||||||
case ERROR:
|
|
||||||
setType("error");
|
|
||||||
break;
|
|
||||||
case WARNING:
|
|
||||||
setType("warning");
|
|
||||||
break;
|
|
||||||
case INFO:
|
|
||||||
setType("info");
|
|
||||||
break;
|
|
||||||
case OK:
|
|
||||||
setType("ok");
|
|
||||||
break;
|
|
||||||
case TOO_BUSY:
|
|
||||||
setType("too busy");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
setType("unknown");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
@XmlTransient
|
public ApiResponseMessage(){}
|
||||||
public int getCode() {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCode(int code) {
|
public ApiResponseMessage(int code, String message){
|
||||||
this.code = code;
|
this.code = code;
|
||||||
}
|
switch(code){
|
||||||
|
case ERROR:
|
||||||
|
setType("error");
|
||||||
|
break;
|
||||||
|
case WARNING:
|
||||||
|
setType("warning");
|
||||||
|
break;
|
||||||
|
case INFO:
|
||||||
|
setType("info");
|
||||||
|
break;
|
||||||
|
case OK:
|
||||||
|
setType("ok");
|
||||||
|
break;
|
||||||
|
case TOO_BUSY:
|
||||||
|
setType("too busy");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
setType("unknown");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
public String getType() {
|
@XmlTransient
|
||||||
return type;
|
public int getCode() {
|
||||||
}
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
public void setType(String type) {
|
public void setCode(int code) {
|
||||||
this.type = type;
|
this.code = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMessage() {
|
public String getType() {
|
||||||
return message;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMessage(String message) {
|
public void setType(String type) {
|
||||||
this.message = message;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{{#apiInfo}}
|
{{#apiInfo}}
|
||||||
{{#apis}}
|
{{#apis}}
|
||||||
{{#operations}}
|
{{#operations}}
|
||||||
export * from './{{ classname }}';
|
export * from './{{ classFilename }}';
|
||||||
import { {{ classname }} } from './{{ classname }}';
|
import { {{ classname }} } from './{{ classFilename }}';
|
||||||
{{/operations}}
|
{{/operations}}
|
||||||
{{/apis}}
|
{{/apis}}
|
||||||
export const APIS = [ {{#apis}}{{#operations}}{{ classname }}, {{/operations}}{{/apis}}];
|
export const APIS = [{{#apis}}{{#operations}}{{ classname }}, {{/operations}}{{/apis}}];
|
||||||
{{/apiInfo}}
|
{{/apiInfo}}
|
@ -1,5 +1,5 @@
|
|||||||
{{#models}}
|
{{#models}}
|
||||||
{{#model}}
|
{{#model}}
|
||||||
export * from './{{{ classname }}}';
|
export * from './{{{ classFilename }}}';
|
||||||
{{/model}}
|
{{/model}}
|
||||||
{{/models}}
|
{{/models}}
|
||||||
|
13
pom.xml
13
pom.xml
@ -710,6 +710,18 @@
|
|||||||
<module>samples/server/petstore/spring-mvc</module>
|
<module>samples/server/petstore/spring-mvc</module>
|
||||||
</modules>
|
</modules>
|
||||||
</profile>
|
</profile>
|
||||||
|
<profile>
|
||||||
|
<id>springboot-beanvalidation</id>
|
||||||
|
<activation>
|
||||||
|
<property>
|
||||||
|
<name>env</name>
|
||||||
|
<value>java</value>
|
||||||
|
</property>
|
||||||
|
</activation>
|
||||||
|
<modules>
|
||||||
|
<module>samples/server/petstore/springboot-beanvalidation</module>
|
||||||
|
</modules>
|
||||||
|
</profile>
|
||||||
<profile>
|
<profile>
|
||||||
<id>springboot</id>
|
<id>springboot</id>
|
||||||
<activation>
|
<activation>
|
||||||
@ -820,6 +832,7 @@
|
|||||||
<module>samples/server/petstore/spring-mvc</module>
|
<module>samples/server/petstore/spring-mvc</module>
|
||||||
<module>samples/client/petstore/spring-cloud</module>
|
<module>samples/client/petstore/spring-cloud</module>
|
||||||
<module>samples/server/petstore/springboot</module>
|
<module>samples/server/petstore/springboot</module>
|
||||||
|
<module>samples/server/petstore/springboot-beanvalidation</module>
|
||||||
<module>samples/server/petstore/jaxrs-cxf</module>
|
<module>samples/server/petstore/jaxrs-cxf</module>
|
||||||
<module>samples/server/petstore/jaxrs-cxf-annotated-base-path</module>
|
<module>samples/server/petstore/jaxrs-cxf-annotated-base-path</module>
|
||||||
<module>samples/server/petstore/jaxrs-cxf-cdi</module>
|
<module>samples/server/petstore/jaxrs-cxf-cdi</module>
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
export * from './FakeApi';
|
export * from './FakeApi';
|
||||||
import { FakeApi } from './FakeApi';
|
import { FakeApi } from './FakeApi';
|
||||||
export const APIS = [ FakeApi, ];
|
export const APIS = [FakeApi, ];
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
export * from './PetApi';
|
export * from './PetApi';
|
||||||
import { PetApi } from './PetApi';
|
import { PetApi } from './PetApi';
|
||||||
export * from './StoreApi';
|
export * from './StoreApi';
|
||||||
import { StoreApi } from './StoreApi';
|
import { StoreApi } from './StoreApi';
|
||||||
export * from './UserApi';
|
export * from './UserApi';
|
||||||
import { UserApi } from './UserApi';
|
import { UserApi } from './UserApi';
|
||||||
export const APIS = [ PetApi, StoreApi, UserApi, ];
|
export const APIS = [PetApi, StoreApi, UserApi, ];
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
export * from './PetApi';
|
export * from './pet.service';
|
||||||
import { PetApi } from './PetApi';
|
import { PetService } from './pet.service';
|
||||||
export * from './StoreApi';
|
export * from './store.service';
|
||||||
import { StoreApi } from './StoreApi';
|
import { StoreService } from './store.service';
|
||||||
export * from './UserApi';
|
export * from './user.service';
|
||||||
import { UserApi } from './UserApi';
|
import { UserService } from './user.service';
|
||||||
export const APIS = [PetApi, StoreApi, UserApi];
|
export const APIS = [PetService, StoreService, UserService];
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
## @swagger/angular2-typescript-petstore@0.0.1-SNAPSHOT.201703271250
|
## @swagger/angular2-typescript-petstore@0.0.1-SNAPSHOT.201704172305
|
||||||
|
|
||||||
### Building
|
### Building
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ navigate to the folder of your consuming project and run one of next commando's.
|
|||||||
_published:_
|
_published:_
|
||||||
|
|
||||||
```
|
```
|
||||||
npm install @swagger/angular2-typescript-petstore@0.0.1-SNAPSHOT.201703271250 --save
|
npm install @swagger/angular2-typescript-petstore@0.0.1-SNAPSHOT.201704172305 --save
|
||||||
```
|
```
|
||||||
|
|
||||||
_unPublished (not recommended):_
|
_unPublished (not recommended):_
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
export * from './PetApi';
|
export * from './pet.service';
|
||||||
import { PetApi } from './PetApi';
|
import { PetService } from './pet.service';
|
||||||
export * from './StoreApi';
|
export * from './store.service';
|
||||||
import { StoreApi } from './StoreApi';
|
import { StoreService } from './store.service';
|
||||||
export * from './UserApi';
|
export * from './user.service';
|
||||||
import { UserApi } from './UserApi';
|
import { UserService } from './user.service';
|
||||||
export const APIS = [PetApi, StoreApi, UserApi];
|
export const APIS = [PetService, StoreService, UserService];
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@swagger/angular2-typescript-petstore",
|
"name": "@swagger/angular2-typescript-petstore",
|
||||||
"version": "0.0.1-SNAPSHOT.201703271250",
|
"version": "0.0.1-SNAPSHOT.201704172305",
|
||||||
"description": "swagger client for @swagger/angular2-typescript-petstore",
|
"description": "swagger client for @swagger/angular2-typescript-petstore",
|
||||||
"author": "Swagger Codegen Contributors",
|
"author": "Swagger Codegen Contributors",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
@ -10,30 +10,29 @@
|
|||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "typings install && tsc --outDir dist/",
|
"build": "typings install && tsc --outDir dist/"
|
||||||
"postinstall": "npm run build"
|
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@angular/core": "^2.0.0-rc.5",
|
"@angular/core": "^2.0.0",
|
||||||
"@angular/http": "^2.0.0-rc.5",
|
"@angular/http": "^2.0.0",
|
||||||
"@angular/common": "^2.0.0-rc.5",
|
"@angular/common": "^2.0.0",
|
||||||
"@angular/compiler": "^2.0.0-rc.5",
|
"@angular/compiler": "^2.0.0",
|
||||||
"core-js": "^2.4.0",
|
"core-js": "^2.4.0",
|
||||||
"reflect-metadata": "^0.1.3",
|
"reflect-metadata": "^0.1.3",
|
||||||
"rxjs": "5.0.0-beta.6",
|
"rxjs": "5.0.0-beta.12",
|
||||||
"zone.js": "^0.6.17"
|
"zone.js": "^0.6.17"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@angular/core": "^2.0.0-rc.5",
|
"@angular/core": "^2.0.0",
|
||||||
"@angular/http": "^2.0.0-rc.5",
|
"@angular/http": "^2.0.0",
|
||||||
"@angular/common": "^2.0.0-rc.5",
|
"@angular/common": "^2.0.0",
|
||||||
"@angular/compiler": "^2.0.0-rc.5",
|
"@angular/compiler": "^2.0.0",
|
||||||
"@angular/platform-browser": "^2.0.0-rc.5",
|
"@angular/platform-browser": "^2.0.0",
|
||||||
"core-js": "^2.4.0",
|
"core-js": "^2.4.0",
|
||||||
"reflect-metadata": "^0.1.3",
|
"reflect-metadata": "^0.1.3",
|
||||||
"rxjs": "5.0.0-beta.6",
|
"rxjs": "5.0.0-beta.12",
|
||||||
"zone.js": "^0.6.17",
|
"zone.js": "^0.6.17",
|
||||||
"typescript": "^1.8.10",
|
"typescript": "^2.0.0",
|
||||||
"typings": "^1.3.2"
|
"typings": "^1.3.2"
|
||||||
},
|
},
|
||||||
"publishConfig":{
|
"publishConfig":{
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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(int code, String message){
|
|
||||||
this.code = code;
|
|
||||||
switch(code){
|
|
||||||
case ERROR:
|
|
||||||
setType("error");
|
|
||||||
break;
|
|
||||||
case WARNING:
|
|
||||||
setType("warning");
|
|
||||||
break;
|
|
||||||
case INFO:
|
|
||||||
setType("info");
|
|
||||||
break;
|
|
||||||
case OK:
|
|
||||||
setType("ok");
|
|
||||||
break;
|
|
||||||
case TOO_BUSY:
|
|
||||||
setType("too busy");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
setType("unknown");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
@XmlTransient
|
public ApiResponseMessage(){}
|
||||||
public int getCode() {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCode(int code) {
|
public ApiResponseMessage(int code, String message){
|
||||||
this.code = code;
|
this.code = code;
|
||||||
}
|
switch(code){
|
||||||
|
case ERROR:
|
||||||
|
setType("error");
|
||||||
|
break;
|
||||||
|
case WARNING:
|
||||||
|
setType("warning");
|
||||||
|
break;
|
||||||
|
case INFO:
|
||||||
|
setType("info");
|
||||||
|
break;
|
||||||
|
case OK:
|
||||||
|
setType("ok");
|
||||||
|
break;
|
||||||
|
case TOO_BUSY:
|
||||||
|
setType("too busy");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
setType("unknown");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
public String getType() {
|
@XmlTransient
|
||||||
return type;
|
public int getCode() {
|
||||||
}
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
public void setType(String type) {
|
public void setCode(int code) {
|
||||||
this.type = type;
|
this.code = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMessage() {
|
public String getType() {
|
||||||
return message;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMessage(String message) {
|
public void setType(String type) {
|
||||||
this.message = message;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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(int code, String message){
|
|
||||||
this.code = code;
|
|
||||||
switch(code){
|
|
||||||
case ERROR:
|
|
||||||
setType("error");
|
|
||||||
break;
|
|
||||||
case WARNING:
|
|
||||||
setType("warning");
|
|
||||||
break;
|
|
||||||
case INFO:
|
|
||||||
setType("info");
|
|
||||||
break;
|
|
||||||
case OK:
|
|
||||||
setType("ok");
|
|
||||||
break;
|
|
||||||
case TOO_BUSY:
|
|
||||||
setType("too busy");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
setType("unknown");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
@XmlTransient
|
public ApiResponseMessage(){}
|
||||||
public int getCode() {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCode(int code) {
|
public ApiResponseMessage(int code, String message){
|
||||||
this.code = code;
|
this.code = code;
|
||||||
}
|
switch(code){
|
||||||
|
case ERROR:
|
||||||
|
setType("error");
|
||||||
|
break;
|
||||||
|
case WARNING:
|
||||||
|
setType("warning");
|
||||||
|
break;
|
||||||
|
case INFO:
|
||||||
|
setType("info");
|
||||||
|
break;
|
||||||
|
case OK:
|
||||||
|
setType("ok");
|
||||||
|
break;
|
||||||
|
case TOO_BUSY:
|
||||||
|
setType("too busy");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
setType("unknown");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
public String getType() {
|
@XmlTransient
|
||||||
return type;
|
public int getCode() {
|
||||||
}
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
public void setType(String type) {
|
public void setCode(int code) {
|
||||||
this.type = type;
|
this.code = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMessage() {
|
public String getType() {
|
||||||
return message;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMessage(String message) {
|
public void setType(String type) {
|
||||||
this.message = message;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>io.swagger</groupId>
|
<groupId>io.swagger</groupId>
|
||||||
<artifactId>swagger-spring</artifactId>
|
<artifactId>swagger-spring-beanvalidation</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>swagger-spring</name>
|
<name>swagger-spring</name>
|
||||||
<version>1.0.0</version>
|
<version>1.0.0</version>
|
||||||
@ -70,4 +70,4 @@
|
|||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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(int code, String message){
|
|
||||||
this.code = code;
|
|
||||||
switch(code){
|
|
||||||
case ERROR:
|
|
||||||
setType("error");
|
|
||||||
break;
|
|
||||||
case WARNING:
|
|
||||||
setType("warning");
|
|
||||||
break;
|
|
||||||
case INFO:
|
|
||||||
setType("info");
|
|
||||||
break;
|
|
||||||
case OK:
|
|
||||||
setType("ok");
|
|
||||||
break;
|
|
||||||
case TOO_BUSY:
|
|
||||||
setType("too busy");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
setType("unknown");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
@XmlTransient
|
public ApiResponseMessage(){}
|
||||||
public int getCode() {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCode(int code) {
|
public ApiResponseMessage(int code, String message){
|
||||||
this.code = code;
|
this.code = code;
|
||||||
}
|
switch(code){
|
||||||
|
case ERROR:
|
||||||
|
setType("error");
|
||||||
|
break;
|
||||||
|
case WARNING:
|
||||||
|
setType("warning");
|
||||||
|
break;
|
||||||
|
case INFO:
|
||||||
|
setType("info");
|
||||||
|
break;
|
||||||
|
case OK:
|
||||||
|
setType("ok");
|
||||||
|
break;
|
||||||
|
case TOO_BUSY:
|
||||||
|
setType("too busy");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
setType("unknown");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
public String getType() {
|
@XmlTransient
|
||||||
return type;
|
public int getCode() {
|
||||||
}
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
public void setType(String type) {
|
public void setCode(int code) {
|
||||||
this.type = type;
|
this.code = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMessage() {
|
public String getType() {
|
||||||
return message;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMessage(String message) {
|
public void setType(String type) {
|
||||||
this.message = message;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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(int code, String message){
|
|
||||||
this.code = code;
|
|
||||||
switch(code){
|
|
||||||
case ERROR:
|
|
||||||
setType("error");
|
|
||||||
break;
|
|
||||||
case WARNING:
|
|
||||||
setType("warning");
|
|
||||||
break;
|
|
||||||
case INFO:
|
|
||||||
setType("info");
|
|
||||||
break;
|
|
||||||
case OK:
|
|
||||||
setType("ok");
|
|
||||||
break;
|
|
||||||
case TOO_BUSY:
|
|
||||||
setType("too busy");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
setType("unknown");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
@XmlTransient
|
public ApiResponseMessage(){}
|
||||||
public int getCode() {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCode(int code) {
|
public ApiResponseMessage(int code, String message){
|
||||||
this.code = code;
|
this.code = code;
|
||||||
}
|
switch(code){
|
||||||
|
case ERROR:
|
||||||
|
setType("error");
|
||||||
|
break;
|
||||||
|
case WARNING:
|
||||||
|
setType("warning");
|
||||||
|
break;
|
||||||
|
case INFO:
|
||||||
|
setType("info");
|
||||||
|
break;
|
||||||
|
case OK:
|
||||||
|
setType("ok");
|
||||||
|
break;
|
||||||
|
case TOO_BUSY:
|
||||||
|
setType("too busy");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
setType("unknown");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
public String getType() {
|
@XmlTransient
|
||||||
return type;
|
public int getCode() {
|
||||||
}
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
public void setType(String type) {
|
public void setCode(int code) {
|
||||||
this.type = type;
|
this.code = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMessage() {
|
public String getType() {
|
||||||
return message;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMessage(String message) {
|
public void setType(String type) {
|
||||||
this.message = message;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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(int code, String message){
|
|
||||||
this.code = code;
|
|
||||||
switch(code){
|
|
||||||
case ERROR:
|
|
||||||
setType("error");
|
|
||||||
break;
|
|
||||||
case WARNING:
|
|
||||||
setType("warning");
|
|
||||||
break;
|
|
||||||
case INFO:
|
|
||||||
setType("info");
|
|
||||||
break;
|
|
||||||
case OK:
|
|
||||||
setType("ok");
|
|
||||||
break;
|
|
||||||
case TOO_BUSY:
|
|
||||||
setType("too busy");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
setType("unknown");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
@XmlTransient
|
public ApiResponseMessage(){}
|
||||||
public int getCode() {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCode(int code) {
|
public ApiResponseMessage(int code, String message){
|
||||||
this.code = code;
|
this.code = code;
|
||||||
}
|
switch(code){
|
||||||
|
case ERROR:
|
||||||
|
setType("error");
|
||||||
|
break;
|
||||||
|
case WARNING:
|
||||||
|
setType("warning");
|
||||||
|
break;
|
||||||
|
case INFO:
|
||||||
|
setType("info");
|
||||||
|
break;
|
||||||
|
case OK:
|
||||||
|
setType("ok");
|
||||||
|
break;
|
||||||
|
case TOO_BUSY:
|
||||||
|
setType("too busy");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
setType("unknown");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
public String getType() {
|
@XmlTransient
|
||||||
return type;
|
public int getCode() {
|
||||||
}
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
public void setType(String type) {
|
public void setCode(int code) {
|
||||||
this.type = type;
|
this.code = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMessage() {
|
public String getType() {
|
||||||
return message;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMessage(String message) {
|
public void setType(String type) {
|
||||||
this.message = message;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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(int code, String message){
|
|
||||||
this.code = code;
|
|
||||||
switch(code){
|
|
||||||
case ERROR:
|
|
||||||
setType("error");
|
|
||||||
break;
|
|
||||||
case WARNING:
|
|
||||||
setType("warning");
|
|
||||||
break;
|
|
||||||
case INFO:
|
|
||||||
setType("info");
|
|
||||||
break;
|
|
||||||
case OK:
|
|
||||||
setType("ok");
|
|
||||||
break;
|
|
||||||
case TOO_BUSY:
|
|
||||||
setType("too busy");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
setType("unknown");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
@XmlTransient
|
public ApiResponseMessage(){}
|
||||||
public int getCode() {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCode(int code) {
|
public ApiResponseMessage(int code, String message){
|
||||||
this.code = code;
|
this.code = code;
|
||||||
}
|
switch(code){
|
||||||
|
case ERROR:
|
||||||
|
setType("error");
|
||||||
|
break;
|
||||||
|
case WARNING:
|
||||||
|
setType("warning");
|
||||||
|
break;
|
||||||
|
case INFO:
|
||||||
|
setType("info");
|
||||||
|
break;
|
||||||
|
case OK:
|
||||||
|
setType("ok");
|
||||||
|
break;
|
||||||
|
case TOO_BUSY:
|
||||||
|
setType("too busy");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
setType("unknown");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
public String getType() {
|
@XmlTransient
|
||||||
return type;
|
public int getCode() {
|
||||||
}
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
public void setType(String type) {
|
public void setCode(int code) {
|
||||||
this.type = type;
|
this.code = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMessage() {
|
public String getType() {
|
||||||
return message;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMessage(String message) {
|
public void setType(String type) {
|
||||||
this.message = message;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user