forked from loafle/openapi-generator-original
[Spring] Add beanvalidation annotations (#4600)
* update generated sample for spring boot #4091 * add beanvalidation annotations to spring #4091 * add tests for spring #4091 * cleanup spring-cloud (client lib) #4091 * update client sample spring-cloud #4091 * replace tabs * add beanvalidation annotations to spring #4091 * add tests for spring #4091 * cleanup spring-cloud (client lib) #4091 * update client sample spring-cloud #4091 * replace tabs * update spring-cloud sample
This commit is contained in:
@@ -1,483 +1,498 @@
|
||||
package io.swagger.codegen.languages;
|
||||
|
||||
import io.swagger.codegen.*;
|
||||
import io.swagger.models.Operation;
|
||||
import io.swagger.models.Path;
|
||||
import io.swagger.models.Swagger;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
public class SpringCodegen extends AbstractJavaCodegen {
|
||||
public static final String DEFAULT_LIBRARY = "spring-boot";
|
||||
public static final String TITLE = "title";
|
||||
public static final String CONFIG_PACKAGE = "configPackage";
|
||||
public static final String BASE_PACKAGE = "basePackage";
|
||||
public static final String INTERFACE_ONLY = "interfaceOnly";
|
||||
public static final String DELEGATE_PATTERN = "delegatePattern";
|
||||
public static final String SINGLE_CONTENT_TYPES = "singleContentTypes";
|
||||
public static final String JAVA_8 = "java8";
|
||||
public static final String ASYNC = "async";
|
||||
public static final String RESPONSE_WRAPPER = "responseWrapper";
|
||||
public static final String USE_TAGS = "useTags";
|
||||
public static final String SPRING_MVC_LIBRARY = "spring-mvc";
|
||||
public static final String SPRING_CLOUD_LIBRARY = "spring-cloud";
|
||||
|
||||
protected String title = "swagger-petstore";
|
||||
protected String configPackage = "io.swagger.configuration";
|
||||
protected String basePackage = "io.swagger";
|
||||
protected boolean interfaceOnly = false;
|
||||
protected boolean delegatePattern = false;
|
||||
protected boolean singleContentTypes = false;
|
||||
protected boolean java8 = false;
|
||||
protected boolean async = false;
|
||||
protected String responseWrapper = "";
|
||||
protected boolean useTags = false;
|
||||
|
||||
public SpringCodegen() {
|
||||
super();
|
||||
outputFolder = "generated-code/javaSpring";
|
||||
apiTestTemplateFiles.clear(); // TODO: add test template
|
||||
embeddedTemplateDir = templateDir = "JavaSpring";
|
||||
apiPackage = "io.swagger.api";
|
||||
modelPackage = "io.swagger.model";
|
||||
invokerPackage = "io.swagger.api";
|
||||
artifactId = "swagger-spring";
|
||||
|
||||
additionalProperties.put(CONFIG_PACKAGE, configPackage);
|
||||
additionalProperties.put(BASE_PACKAGE, basePackage);
|
||||
|
||||
// spring uses the jackson lib
|
||||
additionalProperties.put("jackson", "true");
|
||||
|
||||
cliOptions.add(new CliOption(TITLE, "server title name or client service name"));
|
||||
cliOptions.add(new CliOption(CONFIG_PACKAGE, "configuration package for generated code"));
|
||||
cliOptions.add(new CliOption(BASE_PACKAGE, "base package for generated code"));
|
||||
cliOptions.add(CliOption.newBoolean(INTERFACE_ONLY, "Whether to generate only API interface stubs without the server files."));
|
||||
cliOptions.add(CliOption.newBoolean(DELEGATE_PATTERN, "Whether to generate the server files using the delegate pattern"));
|
||||
cliOptions.add(CliOption.newBoolean(SINGLE_CONTENT_TYPES, "Whether to select only one produces/consumes content-type by operation."));
|
||||
cliOptions.add(CliOption.newBoolean(JAVA_8, "use java8 default interface"));
|
||||
cliOptions.add(CliOption.newBoolean(ASYNC, "use async Callable controllers"));
|
||||
cliOptions.add(new CliOption(RESPONSE_WRAPPER, "wrap the responses in given type (Future,Callable,CompletableFuture,ListenableFuture,DeferredResult,HystrixCommand,RxObservable,RxSingle or fully qualified type)"));
|
||||
cliOptions.add(CliOption.newBoolean(USE_TAGS, "use tags for creating interface and controller classnames"));
|
||||
|
||||
supportedLibraries.put(DEFAULT_LIBRARY, "Spring-boot Server application using the SpringFox integration.");
|
||||
supportedLibraries.put(SPRING_MVC_LIBRARY, "Spring-MVC Server application using the SpringFox integration.");
|
||||
supportedLibraries.put(SPRING_CLOUD_LIBRARY, "Spring-Cloud-Feign client with Spring-Boot auto-configured settings.");
|
||||
setLibrary(DEFAULT_LIBRARY);
|
||||
|
||||
CliOption library = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use");
|
||||
library.setDefault(DEFAULT_LIBRARY);
|
||||
library.setEnum(supportedLibraries);
|
||||
library.setDefault(DEFAULT_LIBRARY);
|
||||
cliOptions.add(library);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.SERVER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "spring";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return "Generates a Java SpringBoot Server application using the SpringFox integration.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
||||
// clear model and api doc template as this codegen
|
||||
// does not support auto-generated markdown doc at the moment
|
||||
//TODO: add doc templates
|
||||
modelDocTemplateFiles.remove("model_doc.mustache");
|
||||
apiDocTemplateFiles.remove("api_doc.mustache");
|
||||
|
||||
if (additionalProperties.containsKey(TITLE)) {
|
||||
this.setTitle((String) additionalProperties.get(TITLE));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CONFIG_PACKAGE)) {
|
||||
this.setConfigPackage((String) additionalProperties.get(CONFIG_PACKAGE));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(BASE_PACKAGE)) {
|
||||
this.setBasePackage((String) additionalProperties.get(BASE_PACKAGE));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(INTERFACE_ONLY)) {
|
||||
this.setInterfaceOnly(Boolean.valueOf(additionalProperties.get(INTERFACE_ONLY).toString()));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(DELEGATE_PATTERN)) {
|
||||
this.setDelegatePattern(Boolean.valueOf(additionalProperties.get(DELEGATE_PATTERN).toString()));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(SINGLE_CONTENT_TYPES)) {
|
||||
this.setSingleContentTypes(Boolean.valueOf(additionalProperties.get(SINGLE_CONTENT_TYPES).toString()));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(JAVA_8)) {
|
||||
this.setJava8(Boolean.valueOf(additionalProperties.get(JAVA_8).toString()));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(ASYNC)) {
|
||||
this.setAsync(Boolean.valueOf(additionalProperties.get(ASYNC).toString()));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(RESPONSE_WRAPPER)) {
|
||||
this.setResponseWrapper((String) additionalProperties.get(RESPONSE_WRAPPER));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(USE_TAGS)) {
|
||||
this.setUseTags(Boolean.valueOf(additionalProperties.get(USE_TAGS).toString()));
|
||||
}
|
||||
|
||||
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
|
||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||
|
||||
if (this.interfaceOnly && this.delegatePattern) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format("Can not generate code with `%s` and `%s` both true.", DELEGATE_PATTERN, INTERFACE_ONLY));
|
||||
}
|
||||
|
||||
if (!this.interfaceOnly) {
|
||||
if (library.equals(DEFAULT_LIBRARY)) {
|
||||
supportingFiles.add(new SupportingFile("homeController.mustache",
|
||||
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "HomeController.java"));
|
||||
supportingFiles.add(new SupportingFile("swagger2SpringBoot.mustache",
|
||||
(sourceFolder + File.separator + basePackage).replace(".", java.io.File.separator), "Swagger2SpringBoot.java"));
|
||||
supportingFiles.add(new SupportingFile("RFC3339DateFormat.mustache",
|
||||
(sourceFolder + File.separator + basePackage).replace(".", java.io.File.separator), "RFC3339DateFormat.java"));
|
||||
supportingFiles.add(new SupportingFile("application.mustache",
|
||||
("src.main.resources").replace(".", java.io.File.separator), "application.properties"));
|
||||
}
|
||||
if (library.equals(SPRING_MVC_LIBRARY)) {
|
||||
supportingFiles.add(new SupportingFile("webApplication.mustache",
|
||||
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "WebApplication.java"));
|
||||
supportingFiles.add(new SupportingFile("webMvcConfiguration.mustache",
|
||||
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "WebMvcConfiguration.java"));
|
||||
supportingFiles.add(new SupportingFile("swaggerUiConfiguration.mustache",
|
||||
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "SwaggerUiConfiguration.java"));
|
||||
supportingFiles.add(new SupportingFile("RFC3339DateFormat.mustache",
|
||||
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "RFC3339DateFormat.java"));
|
||||
supportingFiles.add(new SupportingFile("application.properties",
|
||||
("src.main.resources").replace(".", java.io.File.separator), "swagger.properties"));
|
||||
}
|
||||
if (library.equals(SPRING_CLOUD_LIBRARY)) {
|
||||
supportingFiles.add(new SupportingFile("apiKeyRequestInterceptor.mustache",
|
||||
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "ApiKeyRequestInterceptor.java"));
|
||||
supportingFiles.add(new SupportingFile("clientConfiguration.mustache",
|
||||
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "ClientConfiguration.java"));
|
||||
apiTemplateFiles.put("apiClient.mustache", "Client.java");
|
||||
if (!additionalProperties.containsKey(SINGLE_CONTENT_TYPES)) {
|
||||
additionalProperties.put(SINGLE_CONTENT_TYPES, "true");
|
||||
this.setSingleContentTypes(true);
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
apiTemplateFiles.put("apiController.mustache", "Controller.java");
|
||||
supportingFiles.add(new SupportingFile("apiException.mustache",
|
||||
(sourceFolder + File.separator + apiPackage).replace(".", java.io.File.separator), "ApiException.java"));
|
||||
supportingFiles.add(new SupportingFile("apiResponseMessage.mustache",
|
||||
(sourceFolder + File.separator + apiPackage).replace(".", java.io.File.separator), "ApiResponseMessage.java"));
|
||||
supportingFiles.add(new SupportingFile("notFoundException.mustache",
|
||||
(sourceFolder + File.separator + apiPackage).replace(".", java.io.File.separator), "NotFoundException.java"));
|
||||
supportingFiles.add(new SupportingFile("apiOriginFilter.mustache",
|
||||
(sourceFolder + File.separator + apiPackage).replace(".", java.io.File.separator), "ApiOriginFilter.java"));
|
||||
supportingFiles.add(new SupportingFile("swaggerDocumentationConfig.mustache",
|
||||
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "SwaggerDocumentationConfig.java"));
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.delegatePattern && this.java8) {
|
||||
additionalProperties.put("jdk8-no-delegate", true);
|
||||
}
|
||||
|
||||
|
||||
if (this.delegatePattern) {
|
||||
additionalProperties.put("isDelegate", "true");
|
||||
apiTemplateFiles.put("apiDelegate.mustache", "Delegate.java");
|
||||
}
|
||||
|
||||
if (this.java8) {
|
||||
additionalProperties.put("javaVersion", "1.8");
|
||||
additionalProperties.put("jdk8", "true");
|
||||
if (this.async) {
|
||||
additionalProperties.put(RESPONSE_WRAPPER, "CompletableFuture");
|
||||
}
|
||||
typeMapping.put("date", "LocalDate");
|
||||
typeMapping.put("DateTime", "OffsetDateTime");
|
||||
importMapping.put("LocalDate", "java.time.LocalDate");
|
||||
importMapping.put("OffsetDateTime", "java.time.OffsetDateTime");
|
||||
} else if (this.async) {
|
||||
additionalProperties.put(RESPONSE_WRAPPER, "Callable");
|
||||
}
|
||||
|
||||
// Some well-known Spring or Spring-Cloud response wrappers
|
||||
switch (this.responseWrapper) {
|
||||
case "Future":
|
||||
case "Callable":
|
||||
case "CompletableFuture":
|
||||
additionalProperties.put(RESPONSE_WRAPPER, "java.util.concurrent" + this.responseWrapper);
|
||||
break;
|
||||
case "ListenableFuture":
|
||||
additionalProperties.put(RESPONSE_WRAPPER, "org.springframework.util.concurrent.ListenableFuture");
|
||||
break;
|
||||
case "DeferredResult":
|
||||
additionalProperties.put(RESPONSE_WRAPPER, "org.springframework.web.context.request.DeferredResult");
|
||||
break;
|
||||
case "HystrixCommand":
|
||||
additionalProperties.put(RESPONSE_WRAPPER, "com.netflix.hystrix.HystrixCommand");
|
||||
break;
|
||||
case "RxObservable":
|
||||
additionalProperties.put(RESPONSE_WRAPPER, "rx.Observable");
|
||||
break;
|
||||
case "RxSingle":
|
||||
additionalProperties.put(RESPONSE_WRAPPER, "rx.Single");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co, Map<String, List<CodegenOperation>> operations) {
|
||||
if((library.equals(DEFAULT_LIBRARY) || library.equals(SPRING_MVC_LIBRARY)) && !useTags) {
|
||||
String basePath = resourcePath;
|
||||
if (basePath.startsWith("/")) {
|
||||
basePath = basePath.substring(1);
|
||||
}
|
||||
int pos = basePath.indexOf("/");
|
||||
if (pos > 0) {
|
||||
basePath = basePath.substring(0, pos);
|
||||
}
|
||||
|
||||
if (basePath.equals("")) {
|
||||
basePath = "default";
|
||||
} else {
|
||||
co.subresourceOperation = !co.path.isEmpty();
|
||||
}
|
||||
List<CodegenOperation> opList = operations.get(basePath);
|
||||
if (opList == null) {
|
||||
opList = new ArrayList<CodegenOperation>();
|
||||
operations.put(basePath, opList);
|
||||
}
|
||||
opList.add(co);
|
||||
co.baseName = basePath;
|
||||
} else {
|
||||
super.addOperationToGroup(tag, resourcePath, operation, co, operations);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preprocessSwagger(Swagger swagger) {
|
||||
super.preprocessSwagger(swagger);
|
||||
if ("/".equals(swagger.getBasePath())) {
|
||||
swagger.setBasePath("");
|
||||
}
|
||||
|
||||
if(!additionalProperties.containsKey(TITLE)) {
|
||||
// From the title, compute a reasonable name for the package and the API
|
||||
String title = swagger.getInfo().getTitle();
|
||||
|
||||
// Drop any API suffix
|
||||
if (title != null) {
|
||||
title = title.trim().replace(" ", "-");
|
||||
if (title.toUpperCase().endsWith("API")) {
|
||||
title = title.substring(0, title.length() - 3);
|
||||
}
|
||||
|
||||
this.title = camelize(sanitizeName(title), true);
|
||||
}
|
||||
additionalProperties.put(TITLE, this.title);
|
||||
}
|
||||
|
||||
String host = swagger.getHost();
|
||||
String port = "8080";
|
||||
if (host != null) {
|
||||
String[] parts = host.split(":");
|
||||
if (parts.length > 1) {
|
||||
port = parts[1];
|
||||
}
|
||||
}
|
||||
|
||||
this.additionalProperties.put("serverPort", port);
|
||||
if (swagger.getPaths() != null) {
|
||||
for (String pathname : swagger.getPaths().keySet()) {
|
||||
Path path = swagger.getPath(pathname);
|
||||
if (path.getOperations() != null) {
|
||||
for (Operation operation : path.getOperations()) {
|
||||
if (operation.getTags() != null) {
|
||||
List<Map<String, String>> tags = new ArrayList<Map<String, String>>();
|
||||
for (String tag : operation.getTags()) {
|
||||
Map<String, String> value = new HashMap<String, String>();
|
||||
value.put("tag", tag);
|
||||
value.put("hasMore", "true");
|
||||
tags.add(value);
|
||||
}
|
||||
if (tags.size() > 0) {
|
||||
tags.get(tags.size() - 1).remove("hasMore");
|
||||
}
|
||||
if (operation.getTags().size() > 0) {
|
||||
String tag = operation.getTags().get(0);
|
||||
operation.setTags(Arrays.asList(tag));
|
||||
}
|
||||
operation.setVendorExtension("x-tags", tags);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
if (operations != null) {
|
||||
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
||||
for (CodegenOperation operation : ops) {
|
||||
List<CodegenResponse> responses = operation.responses;
|
||||
if (responses != null) {
|
||||
for (CodegenResponse resp : responses) {
|
||||
if ("0".equals(resp.code)) {
|
||||
resp.code = "200";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (operation.returnType == null) {
|
||||
operation.returnType = "Void";
|
||||
} else if (operation.returnType.startsWith("List")) {
|
||||
String rt = operation.returnType;
|
||||
int end = rt.lastIndexOf(">");
|
||||
if (end > 0) {
|
||||
operation.returnType = rt.substring("List<".length(), end).trim();
|
||||
operation.returnContainer = "List";
|
||||
}
|
||||
} else if (operation.returnType.startsWith("Map")) {
|
||||
String rt = operation.returnType;
|
||||
int end = rt.lastIndexOf(">");
|
||||
if (end > 0) {
|
||||
operation.returnType = rt.substring("Map<".length(), end).split(",")[1].trim();
|
||||
operation.returnContainer = "Map";
|
||||
}
|
||||
} else if (operation.returnType.startsWith("Set")) {
|
||||
String rt = operation.returnType;
|
||||
int end = rt.lastIndexOf(">");
|
||||
if (end > 0) {
|
||||
operation.returnType = rt.substring("Set<".length(), end).trim();
|
||||
operation.returnContainer = "Set";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return objs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs) {
|
||||
if(library.equals(SPRING_CLOUD_LIBRARY)) {
|
||||
List<CodegenSecurity> authMethods = (List<CodegenSecurity>) objs.get("authMethods");
|
||||
if (authMethods != null) {
|
||||
for (CodegenSecurity authMethod : authMethods) {
|
||||
authMethod.name = camelize(sanitizeName(authMethod.name), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
return objs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiName(String name) {
|
||||
if (name.length() == 0) {
|
||||
return "DefaultApi";
|
||||
}
|
||||
name = sanitizeName(name);
|
||||
return camelize(name) + "Api";
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public void setConfigPackage(String configPackage) {
|
||||
this.configPackage = configPackage;
|
||||
}
|
||||
|
||||
public void setBasePackage(String configPackage) {
|
||||
this.basePackage = configPackage;
|
||||
}
|
||||
|
||||
public void setInterfaceOnly(boolean interfaceOnly) { this.interfaceOnly = interfaceOnly; }
|
||||
|
||||
public void setDelegatePattern(boolean delegatePattern) { this.delegatePattern = delegatePattern; }
|
||||
|
||||
public void setSingleContentTypes(boolean singleContentTypes) {
|
||||
this.singleContentTypes = singleContentTypes;
|
||||
}
|
||||
|
||||
public void setJava8(boolean java8) { this.java8 = java8; }
|
||||
|
||||
public void setAsync(boolean async) { this.async = async; }
|
||||
|
||||
public void setResponseWrapper(String responseWrapper) { this.responseWrapper = responseWrapper; }
|
||||
|
||||
public void setUseTags(boolean useTags) {
|
||||
this.useTags = useTags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
|
||||
super.postProcessModelProperty(model, property);
|
||||
|
||||
if ("null".equals(property.example)) {
|
||||
property.example = null;
|
||||
}
|
||||
|
||||
//Add imports for Jackson
|
||||
if (!Boolean.TRUE.equals(model.isEnum)) {
|
||||
model.imports.add("JsonProperty");
|
||||
|
||||
if (Boolean.TRUE.equals(model.hasEnums)) {
|
||||
model.imports.add("JsonValue");
|
||||
}
|
||||
} else { // enum class
|
||||
//Needed imports for Jackson's JsonCreator
|
||||
if (additionalProperties.containsKey("jackson")) {
|
||||
model.imports.add("JsonCreator");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessModelsEnum(Map<String, Object> objs) {
|
||||
objs = super.postProcessModelsEnum(objs);
|
||||
|
||||
//Add imports for Jackson
|
||||
List<Map<String, String>> imports = (List<Map<String, String>>)objs.get("imports");
|
||||
List<Object> models = (List<Object>) objs.get("models");
|
||||
for (Object _mo : models) {
|
||||
Map<String, Object> mo = (Map<String, Object>) _mo;
|
||||
CodegenModel cm = (CodegenModel) mo.get("model");
|
||||
// for enum model
|
||||
if (Boolean.TRUE.equals(cm.isEnum) && cm.allowableValues != null) {
|
||||
cm.imports.add(importMapping.get("JsonValue"));
|
||||
Map<String, String> item = new HashMap<String, String>();
|
||||
item.put("import", importMapping.get("JsonValue"));
|
||||
imports.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
return objs;
|
||||
}
|
||||
|
||||
}
|
||||
package io.swagger.codegen.languages;
|
||||
|
||||
import io.swagger.codegen.*;
|
||||
import io.swagger.codegen.languages.features.BeanValidationFeatures;
|
||||
import io.swagger.models.Operation;
|
||||
import io.swagger.models.Path;
|
||||
import io.swagger.models.Swagger;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
public class SpringCodegen extends AbstractJavaCodegen implements BeanValidationFeatures {
|
||||
public static final String DEFAULT_LIBRARY = "spring-boot";
|
||||
public static final String TITLE = "title";
|
||||
public static final String CONFIG_PACKAGE = "configPackage";
|
||||
public static final String BASE_PACKAGE = "basePackage";
|
||||
public static final String INTERFACE_ONLY = "interfaceOnly";
|
||||
public static final String DELEGATE_PATTERN = "delegatePattern";
|
||||
public static final String SINGLE_CONTENT_TYPES = "singleContentTypes";
|
||||
public static final String JAVA_8 = "java8";
|
||||
public static final String ASYNC = "async";
|
||||
public static final String RESPONSE_WRAPPER = "responseWrapper";
|
||||
public static final String USE_TAGS = "useTags";
|
||||
public static final String SPRING_MVC_LIBRARY = "spring-mvc";
|
||||
public static final String SPRING_CLOUD_LIBRARY = "spring-cloud";
|
||||
|
||||
protected String title = "swagger-petstore";
|
||||
protected String configPackage = "io.swagger.configuration";
|
||||
protected String basePackage = "io.swagger";
|
||||
protected boolean interfaceOnly = false;
|
||||
protected boolean delegatePattern = false;
|
||||
protected boolean singleContentTypes = false;
|
||||
protected boolean java8 = false;
|
||||
protected boolean async = false;
|
||||
protected String responseWrapper = "";
|
||||
protected boolean useTags = false;
|
||||
protected boolean useBeanValidation = true;
|
||||
|
||||
public SpringCodegen() {
|
||||
super();
|
||||
outputFolder = "generated-code/javaSpring";
|
||||
apiTestTemplateFiles.clear(); // TODO: add test template
|
||||
embeddedTemplateDir = templateDir = "JavaSpring";
|
||||
apiPackage = "io.swagger.api";
|
||||
modelPackage = "io.swagger.model";
|
||||
invokerPackage = "io.swagger.api";
|
||||
artifactId = "swagger-spring";
|
||||
|
||||
additionalProperties.put(CONFIG_PACKAGE, configPackage);
|
||||
additionalProperties.put(BASE_PACKAGE, basePackage);
|
||||
|
||||
// spring uses the jackson lib
|
||||
additionalProperties.put("jackson", "true");
|
||||
|
||||
cliOptions.add(new CliOption(TITLE, "server title name or client service name"));
|
||||
cliOptions.add(new CliOption(CONFIG_PACKAGE, "configuration package for generated code"));
|
||||
cliOptions.add(new CliOption(BASE_PACKAGE, "base package for generated code"));
|
||||
cliOptions.add(CliOption.newBoolean(INTERFACE_ONLY, "Whether to generate only API interface stubs without the server files."));
|
||||
cliOptions.add(CliOption.newBoolean(DELEGATE_PATTERN, "Whether to generate the server files using the delegate pattern"));
|
||||
cliOptions.add(CliOption.newBoolean(SINGLE_CONTENT_TYPES, "Whether to select only one produces/consumes content-type by operation."));
|
||||
cliOptions.add(CliOption.newBoolean(JAVA_8, "use java8 default interface"));
|
||||
cliOptions.add(CliOption.newBoolean(ASYNC, "use async Callable controllers"));
|
||||
cliOptions.add(new CliOption(RESPONSE_WRAPPER, "wrap the responses in given type (Future,Callable,CompletableFuture,ListenableFuture,DeferredResult,HystrixCommand,RxObservable,RxSingle or fully qualified type)"));
|
||||
cliOptions.add(CliOption.newBoolean(USE_TAGS, "use tags for creating interface and controller classnames"));
|
||||
cliOptions.add(CliOption.newBoolean(USE_BEANVALIDATION, "Use BeanValidation API annotations"));
|
||||
|
||||
supportedLibraries.put(DEFAULT_LIBRARY, "Spring-boot Server application using the SpringFox integration.");
|
||||
supportedLibraries.put(SPRING_MVC_LIBRARY, "Spring-MVC Server application using the SpringFox integration.");
|
||||
supportedLibraries.put(SPRING_CLOUD_LIBRARY, "Spring-Cloud-Feign client with Spring-Boot auto-configured settings.");
|
||||
setLibrary(DEFAULT_LIBRARY);
|
||||
|
||||
CliOption library = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use");
|
||||
library.setDefault(DEFAULT_LIBRARY);
|
||||
library.setEnum(supportedLibraries);
|
||||
library.setDefault(DEFAULT_LIBRARY);
|
||||
cliOptions.add(library);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.SERVER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "spring";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return "Generates a Java SpringBoot Server application using the SpringFox integration.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
||||
// clear model and api doc template as this codegen
|
||||
// does not support auto-generated markdown doc at the moment
|
||||
//TODO: add doc templates
|
||||
modelDocTemplateFiles.remove("model_doc.mustache");
|
||||
apiDocTemplateFiles.remove("api_doc.mustache");
|
||||
|
||||
if (additionalProperties.containsKey(TITLE)) {
|
||||
this.setTitle((String) additionalProperties.get(TITLE));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CONFIG_PACKAGE)) {
|
||||
this.setConfigPackage((String) additionalProperties.get(CONFIG_PACKAGE));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(BASE_PACKAGE)) {
|
||||
this.setBasePackage((String) additionalProperties.get(BASE_PACKAGE));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(INTERFACE_ONLY)) {
|
||||
this.setInterfaceOnly(Boolean.valueOf(additionalProperties.get(INTERFACE_ONLY).toString()));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(DELEGATE_PATTERN)) {
|
||||
this.setDelegatePattern(Boolean.valueOf(additionalProperties.get(DELEGATE_PATTERN).toString()));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(SINGLE_CONTENT_TYPES)) {
|
||||
this.setSingleContentTypes(Boolean.valueOf(additionalProperties.get(SINGLE_CONTENT_TYPES).toString()));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(JAVA_8)) {
|
||||
this.setJava8(Boolean.valueOf(additionalProperties.get(JAVA_8).toString()));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(ASYNC)) {
|
||||
this.setAsync(Boolean.valueOf(additionalProperties.get(ASYNC).toString()));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(RESPONSE_WRAPPER)) {
|
||||
this.setResponseWrapper((String) additionalProperties.get(RESPONSE_WRAPPER));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(USE_TAGS)) {
|
||||
this.setUseTags(Boolean.valueOf(additionalProperties.get(USE_TAGS).toString()));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(USE_BEANVALIDATION)) {
|
||||
this.setUseBeanValidation(convertPropertyToBoolean(USE_BEANVALIDATION));
|
||||
}
|
||||
|
||||
if (useBeanValidation) {
|
||||
writePropertyBack(USE_BEANVALIDATION, useBeanValidation);
|
||||
}
|
||||
|
||||
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
|
||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||
|
||||
if (this.interfaceOnly && this.delegatePattern) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format("Can not generate code with `%s` and `%s` both true.", DELEGATE_PATTERN, INTERFACE_ONLY));
|
||||
}
|
||||
|
||||
if (!this.interfaceOnly) {
|
||||
if (library.equals(DEFAULT_LIBRARY)) {
|
||||
supportingFiles.add(new SupportingFile("homeController.mustache",
|
||||
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "HomeController.java"));
|
||||
supportingFiles.add(new SupportingFile("swagger2SpringBoot.mustache",
|
||||
(sourceFolder + File.separator + basePackage).replace(".", java.io.File.separator), "Swagger2SpringBoot.java"));
|
||||
supportingFiles.add(new SupportingFile("RFC3339DateFormat.mustache",
|
||||
(sourceFolder + File.separator + basePackage).replace(".", java.io.File.separator), "RFC3339DateFormat.java"));
|
||||
supportingFiles.add(new SupportingFile("application.mustache",
|
||||
("src.main.resources").replace(".", java.io.File.separator), "application.properties"));
|
||||
}
|
||||
if (library.equals(SPRING_MVC_LIBRARY)) {
|
||||
supportingFiles.add(new SupportingFile("webApplication.mustache",
|
||||
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "WebApplication.java"));
|
||||
supportingFiles.add(new SupportingFile("webMvcConfiguration.mustache",
|
||||
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "WebMvcConfiguration.java"));
|
||||
supportingFiles.add(new SupportingFile("swaggerUiConfiguration.mustache",
|
||||
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "SwaggerUiConfiguration.java"));
|
||||
supportingFiles.add(new SupportingFile("RFC3339DateFormat.mustache",
|
||||
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "RFC3339DateFormat.java"));
|
||||
supportingFiles.add(new SupportingFile("application.properties",
|
||||
("src.main.resources").replace(".", java.io.File.separator), "swagger.properties"));
|
||||
}
|
||||
if (library.equals(SPRING_CLOUD_LIBRARY)) {
|
||||
supportingFiles.add(new SupportingFile("apiKeyRequestInterceptor.mustache",
|
||||
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "ApiKeyRequestInterceptor.java"));
|
||||
supportingFiles.add(new SupportingFile("clientConfiguration.mustache",
|
||||
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "ClientConfiguration.java"));
|
||||
apiTemplateFiles.put("apiClient.mustache", "Client.java");
|
||||
if (!additionalProperties.containsKey(SINGLE_CONTENT_TYPES)) {
|
||||
additionalProperties.put(SINGLE_CONTENT_TYPES, "true");
|
||||
this.setSingleContentTypes(true);
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
apiTemplateFiles.put("apiController.mustache", "Controller.java");
|
||||
supportingFiles.add(new SupportingFile("apiException.mustache",
|
||||
(sourceFolder + File.separator + apiPackage).replace(".", java.io.File.separator), "ApiException.java"));
|
||||
supportingFiles.add(new SupportingFile("apiResponseMessage.mustache",
|
||||
(sourceFolder + File.separator + apiPackage).replace(".", java.io.File.separator), "ApiResponseMessage.java"));
|
||||
supportingFiles.add(new SupportingFile("notFoundException.mustache",
|
||||
(sourceFolder + File.separator + apiPackage).replace(".", java.io.File.separator), "NotFoundException.java"));
|
||||
supportingFiles.add(new SupportingFile("apiOriginFilter.mustache",
|
||||
(sourceFolder + File.separator + apiPackage).replace(".", java.io.File.separator), "ApiOriginFilter.java"));
|
||||
supportingFiles.add(new SupportingFile("swaggerDocumentationConfig.mustache",
|
||||
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "SwaggerDocumentationConfig.java"));
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.delegatePattern && this.java8) {
|
||||
additionalProperties.put("jdk8-no-delegate", true);
|
||||
}
|
||||
|
||||
|
||||
if (this.delegatePattern) {
|
||||
additionalProperties.put("isDelegate", "true");
|
||||
apiTemplateFiles.put("apiDelegate.mustache", "Delegate.java");
|
||||
}
|
||||
|
||||
if (this.java8) {
|
||||
additionalProperties.put("javaVersion", "1.8");
|
||||
additionalProperties.put("jdk8", "true");
|
||||
if (this.async) {
|
||||
additionalProperties.put(RESPONSE_WRAPPER, "CompletableFuture");
|
||||
}
|
||||
typeMapping.put("date", "LocalDate");
|
||||
typeMapping.put("DateTime", "OffsetDateTime");
|
||||
importMapping.put("LocalDate", "java.time.LocalDate");
|
||||
importMapping.put("OffsetDateTime", "java.time.OffsetDateTime");
|
||||
} else if (this.async) {
|
||||
additionalProperties.put(RESPONSE_WRAPPER, "Callable");
|
||||
}
|
||||
|
||||
// Some well-known Spring or Spring-Cloud response wrappers
|
||||
switch (this.responseWrapper) {
|
||||
case "Future":
|
||||
case "Callable":
|
||||
case "CompletableFuture":
|
||||
additionalProperties.put(RESPONSE_WRAPPER, "java.util.concurrent" + this.responseWrapper);
|
||||
break;
|
||||
case "ListenableFuture":
|
||||
additionalProperties.put(RESPONSE_WRAPPER, "org.springframework.util.concurrent.ListenableFuture");
|
||||
break;
|
||||
case "DeferredResult":
|
||||
additionalProperties.put(RESPONSE_WRAPPER, "org.springframework.web.context.request.DeferredResult");
|
||||
break;
|
||||
case "HystrixCommand":
|
||||
additionalProperties.put(RESPONSE_WRAPPER, "com.netflix.hystrix.HystrixCommand");
|
||||
break;
|
||||
case "RxObservable":
|
||||
additionalProperties.put(RESPONSE_WRAPPER, "rx.Observable");
|
||||
break;
|
||||
case "RxSingle":
|
||||
additionalProperties.put(RESPONSE_WRAPPER, "rx.Single");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co, Map<String, List<CodegenOperation>> operations) {
|
||||
if((library.equals(DEFAULT_LIBRARY) || library.equals(SPRING_MVC_LIBRARY)) && !useTags) {
|
||||
String basePath = resourcePath;
|
||||
if (basePath.startsWith("/")) {
|
||||
basePath = basePath.substring(1);
|
||||
}
|
||||
int pos = basePath.indexOf("/");
|
||||
if (pos > 0) {
|
||||
basePath = basePath.substring(0, pos);
|
||||
}
|
||||
|
||||
if (basePath.equals("")) {
|
||||
basePath = "default";
|
||||
} else {
|
||||
co.subresourceOperation = !co.path.isEmpty();
|
||||
}
|
||||
List<CodegenOperation> opList = operations.get(basePath);
|
||||
if (opList == null) {
|
||||
opList = new ArrayList<CodegenOperation>();
|
||||
operations.put(basePath, opList);
|
||||
}
|
||||
opList.add(co);
|
||||
co.baseName = basePath;
|
||||
} else {
|
||||
super.addOperationToGroup(tag, resourcePath, operation, co, operations);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preprocessSwagger(Swagger swagger) {
|
||||
super.preprocessSwagger(swagger);
|
||||
if ("/".equals(swagger.getBasePath())) {
|
||||
swagger.setBasePath("");
|
||||
}
|
||||
|
||||
if(!additionalProperties.containsKey(TITLE)) {
|
||||
// From the title, compute a reasonable name for the package and the API
|
||||
String title = swagger.getInfo().getTitle();
|
||||
|
||||
// Drop any API suffix
|
||||
if (title != null) {
|
||||
title = title.trim().replace(" ", "-");
|
||||
if (title.toUpperCase().endsWith("API")) {
|
||||
title = title.substring(0, title.length() - 3);
|
||||
}
|
||||
|
||||
this.title = camelize(sanitizeName(title), true);
|
||||
}
|
||||
additionalProperties.put(TITLE, this.title);
|
||||
}
|
||||
|
||||
String host = swagger.getHost();
|
||||
String port = "8080";
|
||||
if (host != null) {
|
||||
String[] parts = host.split(":");
|
||||
if (parts.length > 1) {
|
||||
port = parts[1];
|
||||
}
|
||||
}
|
||||
|
||||
this.additionalProperties.put("serverPort", port);
|
||||
if (swagger.getPaths() != null) {
|
||||
for (String pathname : swagger.getPaths().keySet()) {
|
||||
Path path = swagger.getPath(pathname);
|
||||
if (path.getOperations() != null) {
|
||||
for (Operation operation : path.getOperations()) {
|
||||
if (operation.getTags() != null) {
|
||||
List<Map<String, String>> tags = new ArrayList<Map<String, String>>();
|
||||
for (String tag : operation.getTags()) {
|
||||
Map<String, String> value = new HashMap<String, String>();
|
||||
value.put("tag", tag);
|
||||
value.put("hasMore", "true");
|
||||
tags.add(value);
|
||||
}
|
||||
if (tags.size() > 0) {
|
||||
tags.get(tags.size() - 1).remove("hasMore");
|
||||
}
|
||||
if (operation.getTags().size() > 0) {
|
||||
String tag = operation.getTags().get(0);
|
||||
operation.setTags(Arrays.asList(tag));
|
||||
}
|
||||
operation.setVendorExtension("x-tags", tags);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
if (operations != null) {
|
||||
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
||||
for (CodegenOperation operation : ops) {
|
||||
List<CodegenResponse> responses = operation.responses;
|
||||
if (responses != null) {
|
||||
for (CodegenResponse resp : responses) {
|
||||
if ("0".equals(resp.code)) {
|
||||
resp.code = "200";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (operation.returnType == null) {
|
||||
operation.returnType = "Void";
|
||||
} else if (operation.returnType.startsWith("List")) {
|
||||
String rt = operation.returnType;
|
||||
int end = rt.lastIndexOf(">");
|
||||
if (end > 0) {
|
||||
operation.returnType = rt.substring("List<".length(), end).trim();
|
||||
operation.returnContainer = "List";
|
||||
}
|
||||
} else if (operation.returnType.startsWith("Map")) {
|
||||
String rt = operation.returnType;
|
||||
int end = rt.lastIndexOf(">");
|
||||
if (end > 0) {
|
||||
operation.returnType = rt.substring("Map<".length(), end).split(",")[1].trim();
|
||||
operation.returnContainer = "Map";
|
||||
}
|
||||
} else if (operation.returnType.startsWith("Set")) {
|
||||
String rt = operation.returnType;
|
||||
int end = rt.lastIndexOf(">");
|
||||
if (end > 0) {
|
||||
operation.returnType = rt.substring("Set<".length(), end).trim();
|
||||
operation.returnContainer = "Set";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return objs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs) {
|
||||
if(library.equals(SPRING_CLOUD_LIBRARY)) {
|
||||
List<CodegenSecurity> authMethods = (List<CodegenSecurity>) objs.get("authMethods");
|
||||
if (authMethods != null) {
|
||||
for (CodegenSecurity authMethod : authMethods) {
|
||||
authMethod.name = camelize(sanitizeName(authMethod.name), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
return objs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiName(String name) {
|
||||
if (name.length() == 0) {
|
||||
return "DefaultApi";
|
||||
}
|
||||
name = sanitizeName(name);
|
||||
return camelize(name) + "Api";
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public void setConfigPackage(String configPackage) {
|
||||
this.configPackage = configPackage;
|
||||
}
|
||||
|
||||
public void setBasePackage(String configPackage) {
|
||||
this.basePackage = configPackage;
|
||||
}
|
||||
|
||||
public void setInterfaceOnly(boolean interfaceOnly) { this.interfaceOnly = interfaceOnly; }
|
||||
|
||||
public void setDelegatePattern(boolean delegatePattern) { this.delegatePattern = delegatePattern; }
|
||||
|
||||
public void setSingleContentTypes(boolean singleContentTypes) {
|
||||
this.singleContentTypes = singleContentTypes;
|
||||
}
|
||||
|
||||
public void setJava8(boolean java8) { this.java8 = java8; }
|
||||
|
||||
public void setAsync(boolean async) { this.async = async; }
|
||||
|
||||
public void setResponseWrapper(String responseWrapper) { this.responseWrapper = responseWrapper; }
|
||||
|
||||
public void setUseTags(boolean useTags) {
|
||||
this.useTags = useTags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
|
||||
super.postProcessModelProperty(model, property);
|
||||
|
||||
if ("null".equals(property.example)) {
|
||||
property.example = null;
|
||||
}
|
||||
|
||||
//Add imports for Jackson
|
||||
if (!Boolean.TRUE.equals(model.isEnum)) {
|
||||
model.imports.add("JsonProperty");
|
||||
|
||||
if (Boolean.TRUE.equals(model.hasEnums)) {
|
||||
model.imports.add("JsonValue");
|
||||
}
|
||||
} else { // enum class
|
||||
//Needed imports for Jackson's JsonCreator
|
||||
if (additionalProperties.containsKey("jackson")) {
|
||||
model.imports.add("JsonCreator");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessModelsEnum(Map<String, Object> objs) {
|
||||
objs = super.postProcessModelsEnum(objs);
|
||||
|
||||
//Add imports for Jackson
|
||||
List<Map<String, String>> imports = (List<Map<String, String>>)objs.get("imports");
|
||||
List<Object> models = (List<Object>) objs.get("models");
|
||||
for (Object _mo : models) {
|
||||
Map<String, Object> mo = (Map<String, Object>) _mo;
|
||||
CodegenModel cm = (CodegenModel) mo.get("model");
|
||||
// for enum model
|
||||
if (Boolean.TRUE.equals(cm.isEnum) && cm.allowableValues != null) {
|
||||
cm.imports.add(importMapping.get("JsonValue"));
|
||||
Map<String, String> item = new HashMap<String, String>();
|
||||
item.put("import", importMapping.get("JsonValue"));
|
||||
imports.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
return objs;
|
||||
}
|
||||
|
||||
public void setUseBeanValidation(boolean useBeanValidation) {
|
||||
this.useBeanValidation = useBeanValidation;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,7 +21,9 @@ import java.util.List;
|
||||
{{#async}}
|
||||
import java.util.concurrent.{{^jdk8}}Callable{{/jdk8}}{{#jdk8}}CompletableFuture{{/jdk8}};
|
||||
{{/async}}
|
||||
|
||||
{{#useBeanValidation}}
|
||||
import javax.validation.constraints.*;
|
||||
{{/useBeanValidation}}
|
||||
{{>generatedAnnotation}}
|
||||
@Api(value = "{{{baseName}}}", description = "the {{{baseName}}} API")
|
||||
{{#operations}}
|
||||
|
||||
@@ -22,7 +22,9 @@ import java.util.List;
|
||||
{{#async}}
|
||||
import java.util.concurrent.Callable;
|
||||
{{/async}}{{/jdk8-no-delegate}}
|
||||
|
||||
{{#useBeanValidation}}
|
||||
import javax.validation.constraints.*;
|
||||
{{/useBeanValidation}}
|
||||
{{>generatedAnnotation}}
|
||||
@Controller
|
||||
{{#operations}}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
{{#required}}
|
||||
@NotNull
|
||||
{{/required}}
|
||||
{{#pattern}}
|
||||
@Pattern(regexp="{{pattern}}")
|
||||
{{/pattern}}
|
||||
{{#minLength}}
|
||||
{{#maxLength}}
|
||||
@Size(min={{minLength}},max={{maxLength}})
|
||||
{{/maxLength}}
|
||||
{{/minLength}}
|
||||
{{#minLength}}
|
||||
{{^maxLength}}
|
||||
@Size(min={{minLength}})
|
||||
{{/maxLength}}
|
||||
{{/minLength}}
|
||||
{{^minLength}}
|
||||
{{#maxLength}}
|
||||
@Size(max={{maxLength}})
|
||||
{{/maxLength}}
|
||||
{{/minLength}}
|
||||
{{#minItems}}
|
||||
{{#maxItems}}
|
||||
@Size(min={{minItems}},max={{maxItems}})
|
||||
{{/maxItems}}
|
||||
{{/minItems}}
|
||||
{{#minItems}}
|
||||
{{^maxItems}}
|
||||
@Size(min={{minItems}})
|
||||
{{/maxItems}}
|
||||
{{/minItems}}
|
||||
{{^minItems}}
|
||||
{{#maxItems}}
|
||||
@Size(max={{maxItems}})
|
||||
{{/maxItems}}
|
||||
{{/minItems}}
|
||||
{{! check for integer / number=decimal type}}
|
||||
{{#isInteger}}
|
||||
{{#minimum}}
|
||||
@Min({{minimum}})
|
||||
{{/minimum}}
|
||||
{{#maximum}}
|
||||
@Max({{maximum}})
|
||||
{{/maximum}}
|
||||
{{/isInteger}}
|
||||
{{^isInteger}}
|
||||
{{#minimum}}
|
||||
@DecimalMin("{{minimum}}")
|
||||
{{/minimum}}
|
||||
{{#maximum}}
|
||||
@DecimalMax("{{maximum}}")
|
||||
{{/maximum}}
|
||||
{{/isInteger}}
|
||||
@@ -0,0 +1 @@
|
||||
{{! PathParam is always required, no @NotNull necessary }}{{#pattern}} @Pattern(regexp="{{pattern}}"){{/pattern}}{{#minLength}}{{#maxLength}} @Size(min={{minLength}},max={{maxLength}}){{/maxLength}}{{/minLength}}{{#minLength}}{{^maxLength}} @Size(min={{minLength}}){{/maxLength}}{{/minLength}}{{^minLength}}{{#maxLength}} @Size(max={{maxLength}}){{/maxLength}}{{/minLength}}{{#minItems}}{{#maxItems}} @Size(min={{minItems}},max={{maxItems}}){{/maxItems}}{{/minItems}}{{#minItems}}{{^maxItems}} @Size(min={{minItems}}){{/maxItems}}{{/minItems}}{{^minItems}}{{#maxItems}} @Size(max={{maxItems}}){{/maxItems}}{{/minItems}}{{#minimum}} @Min({{minimum}}){{/minimum}}{{#maximum}} @Max({{maximum}}){{/maximum}}
|
||||
@@ -0,0 +1 @@
|
||||
{{#required}} @NotNull{{/required}}{{#pattern}} @Pattern(regexp="{{pattern}}"){{/pattern}}{{#minLength}}{{#maxLength}} @Size(min={{minLength}},max={{maxLength}}){{/maxLength}}{{/minLength}}{{#minLength}}{{^maxLength}} @Size(min={{minLength}}){{/maxLength}}{{/minLength}}{{^minLength}}{{#maxLength}} @Size(max={{maxLength}}){{/maxLength}}{{/minLength}}{{#minItems}}{{#maxItems}} @Size(min={{minItems}},max={{maxItems}}){{/maxItems}}{{/minItems}}{{#minItems}}{{^maxItems}} @Size(min={{minItems}}){{/maxItems}}{{/minItems}}{{^minItems}}{{#maxItems}} @Size(max={{maxItems}}){{/maxItems}}{{/minItems}}{{#minimum}} @Min({{minimum}}){{/minimum}}{{#maximum}} @Max({{maximum}}){{/maximum}}
|
||||
@@ -73,5 +73,14 @@
|
||||
<artifactId>joda-time</artifactId>
|
||||
</dependency>
|
||||
{{/java8}}
|
||||
{{#useBeanValidation}}
|
||||
<!-- Bean Validation API support -->
|
||||
<dependency>
|
||||
<groupId>javax.validation</groupId>
|
||||
<artifactId>validation-api</artifactId>
|
||||
<version>1.1.0.Final</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
{{/useBeanValidation}}
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -68,6 +68,15 @@
|
||||
<artifactId>joda-time</artifactId>
|
||||
</dependency>
|
||||
{{/java8}}
|
||||
{{#useBeanValidation}}
|
||||
<!-- Bean Validation API support -->
|
||||
<dependency>
|
||||
<groupId>javax.validation</groupId>
|
||||
<artifactId>validation-api</artifactId>
|
||||
<version>1.1.0.Final</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
{{/useBeanValidation}}
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
|
||||
@@ -131,6 +131,15 @@
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>${servlet-api-version}</version>
|
||||
</dependency>
|
||||
{{#useBeanValidation}}
|
||||
<!-- Bean Validation API support -->
|
||||
<dependency>
|
||||
<groupId>javax.validation</groupId>
|
||||
<artifactId>validation-api</artifactId>
|
||||
<version>1.1.0.Final</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
{{/useBeanValidation}}
|
||||
</dependencies>
|
||||
<properties>
|
||||
<java.version>{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}</java.version>
|
||||
|
||||
@@ -6,7 +6,9 @@ import java.util.Objects;
|
||||
{{#serializableModel}}
|
||||
import java.io.Serializable;
|
||||
{{/serializableModel}}
|
||||
|
||||
{{#useBeanValidation}}
|
||||
import javax.validation.constraints.*;
|
||||
{{/useBeanValidation}}
|
||||
{{#models}}
|
||||
{{#model}}
|
||||
{{#isEnum}}
|
||||
|
||||
@@ -1 +1 @@
|
||||
{{#isPathParam}}@ApiParam(value = "{{{description}}}"{{#required}},required=true{{/required}}{{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}} {{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @PathVariable("{{paramName}}") {{{dataType}}} {{paramName}}{{/isPathParam}}
|
||||
{{#isPathParam}}{{#useBeanValidation}}{{>beanValidationPathParams}}{{/useBeanValidation}}@ApiParam(value = "{{{description}}}"{{#required}},required=true{{/required}}{{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}} {{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @PathVariable("{{paramName}}") {{{dataType}}} {{paramName}}{{/isPathParam}}
|
||||
@@ -65,7 +65,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
|
||||
{{{vendorExtensions.extraAnnotation}}}
|
||||
{{/vendorExtensions.extraAnnotation}}
|
||||
@ApiModelProperty({{#example}}example = "{{example}}", {{/example}}{{#required}}required = {{required}}, {{/required}}{{#isReadOnly}}readOnly = {{{isReadOnly}}}, {{/isReadOnly}}value = "{{{description}}}")
|
||||
public {{{datatypeWithEnum}}} {{getter}}() {
|
||||
{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{getter}}() {
|
||||
return {{name}};
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
{{#isQueryParam}}@ApiParam(value = "{{{description}}}"{{#required}}, required = true{{/required}}{{#allowableValues}}, allowableValues = "{{#enumVars}}{{{name}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/enumVars}}"{{/allowableValues}}{{#defaultValue}}, defaultValue = "{{{defaultValue}}}"{{/defaultValue}}) @RequestParam(value = "{{paramName}}"{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) {{{dataType}}} {{paramName}}{{/isQueryParam}}
|
||||
{{#isQueryParam}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}@ApiParam(value = "{{{description}}}"{{#required}}, required = true{{/required}}{{#allowableValues}}, allowableValues = "{{#enumVars}}{{{name}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/enumVars}}"{{/allowableValues}}{{#defaultValue}}, defaultValue = "{{{defaultValue}}}"{{/defaultValue}}) @RequestParam(value = "{{paramName}}"{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) {{{dataType}}} {{paramName}}{{/isQueryParam}}
|
||||
@@ -1,49 +1,51 @@
|
||||
package io.swagger.codegen.options;
|
||||
|
||||
import io.swagger.codegen.CodegenConstants;
|
||||
import io.swagger.codegen.languages.SpringCodegen;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class SpringOptionsProvider extends JavaOptionsProvider {
|
||||
public static final String TITLE = "swagger";
|
||||
public static final String CONFIG_PACKAGE_VALUE = "configPackage";
|
||||
public static final String BASE_PACKAGE_VALUE = "basePackage";
|
||||
public static final String LIBRARY_VALUE = "spring-mvc"; //FIXME hidding value from super class
|
||||
public static final String INTERFACE_ONLY = "true";
|
||||
public static final String DELEGATE_PATTERN = "true";
|
||||
public static final String SINGLE_CONTENT_TYPES = "true";
|
||||
public static final String JAVA_8 = "true";
|
||||
public static final String ASYNC = "true";
|
||||
public static final String RESPONSE_WRAPPER = "Callable";
|
||||
public static final String USE_TAGS = "useTags";
|
||||
|
||||
@Override
|
||||
public String getLanguage() {
|
||||
return "spring";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> createOptions() {
|
||||
Map<String, String> options = new HashMap<String, String>(super.createOptions());
|
||||
options.put(SpringCodegen.TITLE, TITLE);
|
||||
options.put(SpringCodegen.CONFIG_PACKAGE, CONFIG_PACKAGE_VALUE);
|
||||
options.put(SpringCodegen.BASE_PACKAGE, BASE_PACKAGE_VALUE);
|
||||
options.put(CodegenConstants.LIBRARY, LIBRARY_VALUE);
|
||||
options.put(SpringCodegen.INTERFACE_ONLY, INTERFACE_ONLY);
|
||||
options.put(SpringCodegen.DELEGATE_PATTERN, DELEGATE_PATTERN);
|
||||
options.put(SpringCodegen.SINGLE_CONTENT_TYPES, SINGLE_CONTENT_TYPES);
|
||||
options.put(SpringCodegen.JAVA_8, JAVA_8);
|
||||
options.put(SpringCodegen.ASYNC, ASYNC);
|
||||
options.put(SpringCodegen.RESPONSE_WRAPPER, RESPONSE_WRAPPER);
|
||||
options.put(SpringCodegen.USE_TAGS, USE_TAGS);
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isServer() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
package io.swagger.codegen.options;
|
||||
|
||||
import io.swagger.codegen.CodegenConstants;
|
||||
import io.swagger.codegen.languages.SpringCodegen;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class SpringOptionsProvider extends JavaOptionsProvider {
|
||||
public static final String TITLE = "swagger";
|
||||
public static final String CONFIG_PACKAGE_VALUE = "configPackage";
|
||||
public static final String BASE_PACKAGE_VALUE = "basePackage";
|
||||
public static final String LIBRARY_VALUE = "spring-mvc"; //FIXME hidding value from super class
|
||||
public static final String INTERFACE_ONLY = "true";
|
||||
public static final String DELEGATE_PATTERN = "true";
|
||||
public static final String SINGLE_CONTENT_TYPES = "true";
|
||||
public static final String JAVA_8 = "true";
|
||||
public static final String ASYNC = "true";
|
||||
public static final String RESPONSE_WRAPPER = "Callable";
|
||||
public static final String USE_TAGS = "useTags";
|
||||
public static final String USE_BEANVALIDATION = "false";
|
||||
|
||||
@Override
|
||||
public String getLanguage() {
|
||||
return "spring";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> createOptions() {
|
||||
Map<String, String> options = new HashMap<String, String>(super.createOptions());
|
||||
options.put(SpringCodegen.TITLE, TITLE);
|
||||
options.put(SpringCodegen.CONFIG_PACKAGE, CONFIG_PACKAGE_VALUE);
|
||||
options.put(SpringCodegen.BASE_PACKAGE, BASE_PACKAGE_VALUE);
|
||||
options.put(CodegenConstants.LIBRARY, LIBRARY_VALUE);
|
||||
options.put(SpringCodegen.INTERFACE_ONLY, INTERFACE_ONLY);
|
||||
options.put(SpringCodegen.DELEGATE_PATTERN, DELEGATE_PATTERN);
|
||||
options.put(SpringCodegen.SINGLE_CONTENT_TYPES, SINGLE_CONTENT_TYPES);
|
||||
options.put(SpringCodegen.JAVA_8, JAVA_8);
|
||||
options.put(SpringCodegen.ASYNC, ASYNC);
|
||||
options.put(SpringCodegen.RESPONSE_WRAPPER, RESPONSE_WRAPPER);
|
||||
options.put(SpringCodegen.USE_TAGS, USE_TAGS);
|
||||
options.put(SpringCodegen.USE_BEANVALIDATION, USE_BEANVALIDATION);
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isServer() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,76 +1,78 @@
|
||||
package io.swagger.codegen.spring;
|
||||
|
||||
import io.swagger.codegen.CodegenConfig;
|
||||
import io.swagger.codegen.java.JavaClientOptionsTest;
|
||||
import io.swagger.codegen.languages.SpringCodegen;
|
||||
import io.swagger.codegen.options.SpringOptionsProvider;
|
||||
|
||||
import mockit.Expectations;
|
||||
import mockit.Tested;
|
||||
|
||||
public class SpringOptionsTest extends JavaClientOptionsTest {
|
||||
|
||||
@Tested
|
||||
private SpringCodegen clientCodegen;
|
||||
|
||||
public SpringOptionsTest() {
|
||||
super(new SpringOptionsProvider());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CodegenConfig getCodegenConfig() {
|
||||
return clientCodegen;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Override
|
||||
protected void setExpectations() {
|
||||
new Expectations(clientCodegen) {{
|
||||
clientCodegen.setModelPackage(SpringOptionsProvider.MODEL_PACKAGE_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setApiPackage(SpringOptionsProvider.API_PACKAGE_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setSortParamsByRequiredFlag(Boolean.valueOf(SpringOptionsProvider.SORT_PARAMS_VALUE));
|
||||
times = 1;
|
||||
clientCodegen.setInvokerPackage(SpringOptionsProvider.INVOKER_PACKAGE_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setGroupId(SpringOptionsProvider.GROUP_ID_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setArtifactId(SpringOptionsProvider.ARTIFACT_ID_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setArtifactVersion(SpringOptionsProvider.ARTIFACT_VERSION_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setSourceFolder(SpringOptionsProvider.SOURCE_FOLDER_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setLocalVariablePrefix(SpringOptionsProvider.LOCAL_PREFIX_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setSerializableModel(Boolean.valueOf(SpringOptionsProvider.SERIALIZABLE_MODEL_VALUE));
|
||||
times = 1;
|
||||
clientCodegen.setLibrary(SpringOptionsProvider.LIBRARY_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setFullJavaUtil(Boolean.valueOf(SpringOptionsProvider.FULL_JAVA_UTIL_VALUE));
|
||||
times = 1;
|
||||
clientCodegen.setTitle(SpringOptionsProvider.TITLE);
|
||||
times = 1;
|
||||
clientCodegen.setConfigPackage(SpringOptionsProvider.CONFIG_PACKAGE_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setBasePackage(SpringOptionsProvider.BASE_PACKAGE_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setInterfaceOnly(Boolean.valueOf(SpringOptionsProvider.INTERFACE_ONLY));
|
||||
times = 1;
|
||||
clientCodegen.setDelegatePattern(Boolean.valueOf(SpringOptionsProvider.DELEGATE_PATTERN));
|
||||
times = 1;
|
||||
clientCodegen.setSingleContentTypes(Boolean.valueOf(SpringOptionsProvider.SINGLE_CONTENT_TYPES));
|
||||
times = 1;
|
||||
clientCodegen.setJava8(Boolean.valueOf(SpringOptionsProvider.JAVA_8));
|
||||
times = 1;
|
||||
clientCodegen.setAsync(Boolean.valueOf(SpringOptionsProvider.ASYNC));
|
||||
times = 1;
|
||||
clientCodegen.setResponseWrapper(SpringOptionsProvider.RESPONSE_WRAPPER);
|
||||
times = 1;
|
||||
clientCodegen.setUseTags(Boolean.valueOf(SpringOptionsProvider.USE_TAGS));
|
||||
times = 1;
|
||||
|
||||
}};
|
||||
}
|
||||
}
|
||||
package io.swagger.codegen.spring;
|
||||
|
||||
import io.swagger.codegen.CodegenConfig;
|
||||
import io.swagger.codegen.java.JavaClientOptionsTest;
|
||||
import io.swagger.codegen.languages.SpringCodegen;
|
||||
import io.swagger.codegen.options.SpringOptionsProvider;
|
||||
|
||||
import mockit.Expectations;
|
||||
import mockit.Tested;
|
||||
|
||||
public class SpringOptionsTest extends JavaClientOptionsTest {
|
||||
|
||||
@Tested
|
||||
private SpringCodegen clientCodegen;
|
||||
|
||||
public SpringOptionsTest() {
|
||||
super(new SpringOptionsProvider());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CodegenConfig getCodegenConfig() {
|
||||
return clientCodegen;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Override
|
||||
protected void setExpectations() {
|
||||
new Expectations(clientCodegen) {{
|
||||
clientCodegen.setModelPackage(SpringOptionsProvider.MODEL_PACKAGE_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setApiPackage(SpringOptionsProvider.API_PACKAGE_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setSortParamsByRequiredFlag(Boolean.valueOf(SpringOptionsProvider.SORT_PARAMS_VALUE));
|
||||
times = 1;
|
||||
clientCodegen.setInvokerPackage(SpringOptionsProvider.INVOKER_PACKAGE_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setGroupId(SpringOptionsProvider.GROUP_ID_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setArtifactId(SpringOptionsProvider.ARTIFACT_ID_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setArtifactVersion(SpringOptionsProvider.ARTIFACT_VERSION_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setSourceFolder(SpringOptionsProvider.SOURCE_FOLDER_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setLocalVariablePrefix(SpringOptionsProvider.LOCAL_PREFIX_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setSerializableModel(Boolean.valueOf(SpringOptionsProvider.SERIALIZABLE_MODEL_VALUE));
|
||||
times = 1;
|
||||
clientCodegen.setLibrary(SpringOptionsProvider.LIBRARY_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setFullJavaUtil(Boolean.valueOf(SpringOptionsProvider.FULL_JAVA_UTIL_VALUE));
|
||||
times = 1;
|
||||
clientCodegen.setTitle(SpringOptionsProvider.TITLE);
|
||||
times = 1;
|
||||
clientCodegen.setConfigPackage(SpringOptionsProvider.CONFIG_PACKAGE_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setBasePackage(SpringOptionsProvider.BASE_PACKAGE_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setInterfaceOnly(Boolean.valueOf(SpringOptionsProvider.INTERFACE_ONLY));
|
||||
times = 1;
|
||||
clientCodegen.setDelegatePattern(Boolean.valueOf(SpringOptionsProvider.DELEGATE_PATTERN));
|
||||
times = 1;
|
||||
clientCodegen.setSingleContentTypes(Boolean.valueOf(SpringOptionsProvider.SINGLE_CONTENT_TYPES));
|
||||
times = 1;
|
||||
clientCodegen.setJava8(Boolean.valueOf(SpringOptionsProvider.JAVA_8));
|
||||
times = 1;
|
||||
clientCodegen.setAsync(Boolean.valueOf(SpringOptionsProvider.ASYNC));
|
||||
times = 1;
|
||||
clientCodegen.setResponseWrapper(SpringOptionsProvider.RESPONSE_WRAPPER);
|
||||
times = 1;
|
||||
clientCodegen.setUseTags(Boolean.valueOf(SpringOptionsProvider.USE_TAGS));
|
||||
times = 1;
|
||||
clientCodegen.setUseBeanValidation(Boolean.valueOf(SpringOptionsProvider.USE_BEANVALIDATION));
|
||||
times = 1;
|
||||
|
||||
}};
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
# swagger-petstore-spring-cloud
|
||||
# swagger-spring
|
||||
|
||||
## Requirements
|
||||
|
||||
@@ -27,7 +27,7 @@ Add this dependency to your project's POM:
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-petstore-spring-cloud</artifactId>
|
||||
<artifactId>swagger-spring</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
@@ -38,7 +38,7 @@ Add this dependency to your project's POM:
|
||||
Add this dependency to your project's build file:
|
||||
|
||||
```groovy
|
||||
compile "io.swagger:swagger-petstore-spring-cloud:1.0.0"
|
||||
compile "io.swagger:swagger-spring:1.0.0"
|
||||
```
|
||||
|
||||
### Others
|
||||
@@ -49,5 +49,5 @@ mvn package
|
||||
|
||||
Then manually install the following JARs:
|
||||
|
||||
* target/swagger-petstore-spring-cloud-1.0.0.jar
|
||||
* target/swagger-spring-1.0.0.jar
|
||||
* target/lib/*.jar
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<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>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-petstore-spring-cloud</artifactId>
|
||||
<artifactId>swagger-spring</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>swagger-petstore-spring-cloud</name>
|
||||
<name>swagger-spring</name>
|
||||
<version>1.0.0</version>
|
||||
<properties>
|
||||
<java.version>1.7</java.version>
|
||||
@@ -59,6 +59,13 @@
|
||||
<groupId>joda-time</groupId>
|
||||
<artifactId>joda-time</artifactId>
|
||||
</dependency>
|
||||
<!-- Bean Validation API support -->
|
||||
<dependency>
|
||||
<groupId>javax.validation</groupId>
|
||||
<artifactId>validation-api</artifactId>
|
||||
<version>1.1.0.Final</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
|
||||
@@ -16,7 +16,7 @@ import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Api(value = "Pet", description = "the Pet API")
|
||||
public interface PetApi {
|
||||
@@ -65,7 +65,7 @@ public interface PetApi {
|
||||
produces = "application/json",
|
||||
consumes = "application/json",
|
||||
method = RequestMethod.GET)
|
||||
com.netflix.hystrix.HystrixCommand<ResponseEntity<List<Pet>>> findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "AVAILABLE, PENDING, SOLD") @RequestParam(value = "status", required = true) List<String> status);
|
||||
com.netflix.hystrix.HystrixCommand<ResponseEntity<List<Pet>>> findPetsByStatus( @NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "AVAILABLE, PENDING, SOLD") @RequestParam(value = "status", required = true) List<String> status);
|
||||
|
||||
|
||||
@ApiOperation(value = "Finds Pets by tags", notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List", authorizations = {
|
||||
@@ -81,7 +81,7 @@ public interface PetApi {
|
||||
produces = "application/json",
|
||||
consumes = "application/json",
|
||||
method = RequestMethod.GET)
|
||||
com.netflix.hystrix.HystrixCommand<ResponseEntity<List<Pet>>> findPetsByTags(@ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List<String> tags);
|
||||
com.netflix.hystrix.HystrixCommand<ResponseEntity<List<Pet>>> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List<String> tags);
|
||||
|
||||
|
||||
@ApiOperation(value = "Find pet by ID", notes = "Returns a single pet", response = Pet.class, authorizations = {
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Api(value = "Store", description = "the Store API")
|
||||
public interface StoreApi {
|
||||
@@ -52,7 +52,7 @@ public interface StoreApi {
|
||||
produces = "application/json",
|
||||
consumes = "application/json",
|
||||
method = RequestMethod.GET)
|
||||
com.netflix.hystrix.HystrixCommand<ResponseEntity<Order>> getOrderById(@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("orderId") Long orderId);
|
||||
com.netflix.hystrix.HystrixCommand<ResponseEntity<Order>> getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("orderId") Long orderId);
|
||||
|
||||
|
||||
@ApiOperation(value = "Place an order for a pet", notes = "", response = Order.class, tags={ "store", })
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Api(value = "User", description = "the User API")
|
||||
public interface UserApi {
|
||||
@@ -81,8 +81,8 @@ public interface UserApi {
|
||||
produces = "application/json",
|
||||
consumes = "application/json",
|
||||
method = RequestMethod.GET)
|
||||
com.netflix.hystrix.HystrixCommand<ResponseEntity<String>> loginUser(@ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username,
|
||||
@ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password);
|
||||
com.netflix.hystrix.HystrixCommand<ResponseEntity<String>> loginUser( @NotNull @ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username,
|
||||
@NotNull @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password);
|
||||
|
||||
|
||||
@ApiOperation(value = "Logs out current logged in user session", notes = "", response = Void.class, tags={ "user", })
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* A category for a pet
|
||||
*/
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* Describes the result of uploading an image resource
|
||||
*/
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* An order for a pets from the pet store
|
||||
*/
|
||||
|
||||
@@ -10,7 +10,7 @@ import io.swagger.model.Category;
|
||||
import io.swagger.model.Tag;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* A pet for sale in the pet store
|
||||
*/
|
||||
@@ -114,6 +114,7 @@ public class Pet {
|
||||
* @return name
|
||||
**/
|
||||
@ApiModelProperty(example = "doggie", required = true, value = "")
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@@ -137,6 +138,7 @@ public class Pet {
|
||||
* @return photoUrls
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
public List<String> getPhotoUrls() {
|
||||
return photoUrls;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* A tag for a pet
|
||||
*/
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* A User who is purchasing from the pet store
|
||||
*/
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<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>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-spring-mvc-server</artifactId>
|
||||
<artifactId>swagger-spring</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>swagger-spring-mvc-server</name>
|
||||
<name>swagger-spring</name>
|
||||
<version>1.0.0</version>
|
||||
<build>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
@@ -122,6 +122,13 @@
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>${servlet-api-version}</version>
|
||||
</dependency>
|
||||
<!-- Bean Validation API support -->
|
||||
<dependency>
|
||||
<groupId>javax.validation</groupId>
|
||||
<artifactId>validation-api</artifactId>
|
||||
<version>1.1.0.Final</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<java.version>1.7</java.version>
|
||||
|
||||
@@ -17,7 +17,7 @@ import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Api(value = "fake", description = "the fake API")
|
||||
public interface FakeApi {
|
||||
@@ -70,9 +70,9 @@ public interface FakeApi {
|
||||
@ApiParam(value = "Form parameter enum test (string)" , allowableValues="_ABC, _EFG, _XYZ_", defaultValue="-efg") @RequestPart(value="enumFormString", required=false) String enumFormString,
|
||||
@ApiParam(value = "Header parameter enum test (string array)" , allowableValues="GREATER_THAN, DOLLAR") @RequestHeader(value="enum_header_string_array", required=false) List<String> enumHeaderStringArray,
|
||||
@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_ABC, _EFG, _XYZ_", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,
|
||||
@ApiParam(value = "Query parameter enum test (string array)", allowableValues = "GREATER_THAN, DOLLAR") @RequestParam(value = "enumQueryStringArray", required = false) List<String> enumQueryStringArray,
|
||||
@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_ABC, _EFG, _XYZ_", defaultValue = "-efg") @RequestParam(value = "enumQueryString", required = false, defaultValue="-efg") String enumQueryString,
|
||||
@ApiParam(value = "Query parameter enum test (double)") @RequestParam(value = "enumQueryInteger", required = false) Integer enumQueryInteger,
|
||||
@ApiParam(value = "Query parameter enum test (string array)", allowableValues = "GREATER_THAN, DOLLAR") @RequestParam(value = "enumQueryStringArray", required = false) List<String> enumQueryStringArray,
|
||||
@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_ABC, _EFG, _XYZ_", defaultValue = "-efg") @RequestParam(value = "enumQueryString", required = false, defaultValue="-efg") String enumQueryString,
|
||||
@ApiParam(value = "Query parameter enum test (double)") @RequestParam(value = "enumQueryInteger", required = false) Integer enumQueryInteger,
|
||||
@ApiParam(value = "Query parameter enum test (double)" ) @RequestPart(value="enumQueryDouble", required=false) Double enumQueryDouble);
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Controller
|
||||
public class FakeApiController implements FakeApi {
|
||||
|
||||
@@ -16,7 +16,7 @@ import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Api(value = "pet", description = "the pet API")
|
||||
public interface PetApi {
|
||||
@@ -63,7 +63,7 @@ public interface PetApi {
|
||||
@RequestMapping(value = "/pet/findByStatus",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.GET)
|
||||
ResponseEntity<List<Pet>> findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "AVAILABLE, PENDING, SOLD") @RequestParam(value = "status", required = true) List<String> status);
|
||||
ResponseEntity<List<Pet>> findPetsByStatus( @NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "AVAILABLE, PENDING, SOLD") @RequestParam(value = "status", required = true) List<String> status);
|
||||
|
||||
|
||||
@ApiOperation(value = "Finds Pets by tags", notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List", authorizations = {
|
||||
@@ -78,7 +78,7 @@ public interface PetApi {
|
||||
@RequestMapping(value = "/pet/findByTags",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.GET)
|
||||
ResponseEntity<List<Pet>> findPetsByTags(@ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List<String> tags);
|
||||
ResponseEntity<List<Pet>> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List<String> tags);
|
||||
|
||||
|
||||
@ApiOperation(value = "Find pet by ID", notes = "Returns a single pet", response = Pet.class, authorizations = {
|
||||
|
||||
@@ -18,7 +18,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Controller
|
||||
public class PetApiController implements PetApi {
|
||||
@@ -36,12 +36,12 @@ public class PetApiController implements PetApi {
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
public ResponseEntity<List<Pet>> findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "AVAILABLE, PENDING, SOLD") @RequestParam(value = "status", required = true) List<String> status) {
|
||||
public ResponseEntity<List<Pet>> findPetsByStatus( @NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "AVAILABLE, PENDING, SOLD") @RequestParam(value = "status", required = true) List<String> status) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<List<Pet>>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
public ResponseEntity<List<Pet>> findPetsByTags(@ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List<String> tags) {
|
||||
public ResponseEntity<List<Pet>> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List<String> tags) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<List<Pet>>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Api(value = "store", description = "the store API")
|
||||
public interface StoreApi {
|
||||
@@ -27,7 +27,7 @@ public interface StoreApi {
|
||||
@RequestMapping(value = "/store/order/{orderId}",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.DELETE)
|
||||
ResponseEntity<Void> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("orderId") String orderId);
|
||||
ResponseEntity<Void> deleteOrder( @Min(1)@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("orderId") String orderId);
|
||||
|
||||
|
||||
@ApiOperation(value = "Returns pet inventories by status", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map", authorizations = {
|
||||
@@ -49,7 +49,7 @@ public interface StoreApi {
|
||||
@RequestMapping(value = "/store/order/{orderId}",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.GET)
|
||||
ResponseEntity<Order> getOrderById(@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("orderId") Long orderId);
|
||||
ResponseEntity<Order> getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("orderId") Long orderId);
|
||||
|
||||
|
||||
@ApiOperation(value = "Place an order for a pet", notes = "", response = Order.class, tags={ "store", })
|
||||
|
||||
@@ -17,14 +17,12 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Controller
|
||||
public class StoreApiController implements StoreApi {
|
||||
|
||||
|
||||
|
||||
public ResponseEntity<Void> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("orderId") String orderId) {
|
||||
public ResponseEntity<Void> deleteOrder( @Min(1)@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("orderId") String orderId) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
}
|
||||
@@ -34,7 +32,7 @@ public class StoreApiController implements StoreApi {
|
||||
return new ResponseEntity<Map<String, Integer>>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
public ResponseEntity<Order> getOrderById(@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("orderId") Long orderId) {
|
||||
public ResponseEntity<Order> getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("orderId") Long orderId) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Order>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Api(value = "user", description = "the user API")
|
||||
public interface UserApi {
|
||||
@@ -75,8 +75,8 @@ public interface UserApi {
|
||||
@RequestMapping(value = "/user/login",
|
||||
produces = { "application/xml", "application/json" },
|
||||
method = RequestMethod.GET)
|
||||
ResponseEntity<String> loginUser(@ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username,
|
||||
@ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password);
|
||||
ResponseEntity<String> loginUser( @NotNull @ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username,
|
||||
@NotNull @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password);
|
||||
|
||||
|
||||
@ApiOperation(value = "Logs out current logged in user session", notes = "", response = Void.class, tags={ "user", })
|
||||
|
||||
@@ -17,7 +17,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Controller
|
||||
public class UserApiController implements UserApi {
|
||||
@@ -49,8 +49,8 @@ public class UserApiController implements UserApi {
|
||||
return new ResponseEntity<User>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
public ResponseEntity<String> loginUser(@ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username,
|
||||
@ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password) {
|
||||
public ResponseEntity<String> loginUser( @NotNull @ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username,
|
||||
@NotNull @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<String>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* AdditionalPropertiesClass
|
||||
*/
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.fasterxml.jackson.annotation.JsonSubTypes;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* Animal
|
||||
*/
|
||||
@@ -29,6 +29,7 @@ public class Animal {
|
||||
* @return className
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
public String getClassName() {
|
||||
return className;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import java.util.Objects;
|
||||
import io.swagger.model.Animal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* AnimalFarm
|
||||
*/
|
||||
|
||||
@@ -8,7 +8,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* ArrayOfArrayOfNumberOnly
|
||||
*/
|
||||
|
||||
@@ -8,7 +8,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* ArrayOfNumberOnly
|
||||
*/
|
||||
|
||||
@@ -8,7 +8,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.model.ReadOnlyFirst;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* ArrayTest
|
||||
*/
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.model.Animal;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* Cat
|
||||
*/
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* Category
|
||||
*/
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* Model for testing model with \"_class\" property
|
||||
*/
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* Client
|
||||
*/
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.model.Animal;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* Dog
|
||||
*/
|
||||
|
||||
@@ -8,7 +8,7 @@ import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* EnumArrays
|
||||
*/
|
||||
|
||||
@@ -2,7 +2,7 @@ package io.swagger.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.model.OuterEnum;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* EnumTest
|
||||
*/
|
||||
|
||||
@@ -8,7 +8,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import java.math.BigDecimal;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.LocalDate;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* FormatTest
|
||||
*/
|
||||
@@ -65,6 +65,8 @@ public class FormatTest {
|
||||
* @return integer
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
@Min(10)
|
||||
@Max(100)
|
||||
public Integer getInteger() {
|
||||
return integer;
|
||||
}
|
||||
@@ -85,6 +87,8 @@ public class FormatTest {
|
||||
* @return int32
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
@Min(20)
|
||||
@Max(200)
|
||||
public Integer getInt32() {
|
||||
return int32;
|
||||
}
|
||||
@@ -123,6 +127,9 @@ public class FormatTest {
|
||||
* @return number
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
@DecimalMin("32.1")
|
||||
@DecimalMax("543.2")
|
||||
public BigDecimal getNumber() {
|
||||
return number;
|
||||
}
|
||||
@@ -143,6 +150,8 @@ public class FormatTest {
|
||||
* @return _float
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
@DecimalMin("54.3")
|
||||
@DecimalMax("987.6")
|
||||
public Float getFloat() {
|
||||
return _float;
|
||||
}
|
||||
@@ -163,6 +172,8 @@ public class FormatTest {
|
||||
* @return _double
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
@DecimalMin("67.8")
|
||||
@DecimalMax("123.4")
|
||||
public Double getDouble() {
|
||||
return _double;
|
||||
}
|
||||
@@ -181,6 +192,7 @@ public class FormatTest {
|
||||
* @return string
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
@Pattern(regexp="/[a-z]/i")
|
||||
public String getString() {
|
||||
return string;
|
||||
}
|
||||
@@ -199,6 +211,7 @@ public class FormatTest {
|
||||
* @return _byte
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
public byte[] getByte() {
|
||||
return _byte;
|
||||
}
|
||||
@@ -235,6 +248,7 @@ public class FormatTest {
|
||||
* @return date
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
public LocalDate getDate() {
|
||||
return date;
|
||||
}
|
||||
@@ -289,6 +303,8 @@ public class FormatTest {
|
||||
* @return password
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
@Size(min=10,max=64)
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* HasOnlyReadOnly
|
||||
*/
|
||||
|
||||
@@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* MapTest
|
||||
*/
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* MixedPropertiesAndAdditionalPropertiesClass
|
||||
*/
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* Model for testing model name starting with number
|
||||
*/
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* ModelApiResponse
|
||||
*/
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* Model for testing reserved words
|
||||
*/
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* Model for testing model name same as property name
|
||||
*/
|
||||
@@ -34,6 +34,7 @@ public class Name {
|
||||
* @return name
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
public Integer getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* NumberOnly
|
||||
*/
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* Order
|
||||
*/
|
||||
|
||||
@@ -2,7 +2,7 @@ package io.swagger.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,7 +10,7 @@ import io.swagger.model.Category;
|
||||
import io.swagger.model.Tag;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* Pet
|
||||
*/
|
||||
@@ -113,6 +113,7 @@ public class Pet {
|
||||
* @return name
|
||||
**/
|
||||
@ApiModelProperty(example = "doggie", required = true, value = "")
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@@ -136,6 +137,7 @@ public class Pet {
|
||||
* @return photoUrls
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
public List<String> getPhotoUrls() {
|
||||
return photoUrls;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* ReadOnlyFirst
|
||||
*/
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* SpecialModelName
|
||||
*/
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* Tag
|
||||
*/
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* User
|
||||
*/
|
||||
|
||||
@@ -62,5 +62,12 @@
|
||||
<groupId>joda-time</groupId>
|
||||
<artifactId>joda-time</artifactId>
|
||||
</dependency>
|
||||
<!-- Bean Validation API support -->
|
||||
<dependency>
|
||||
<groupId>javax.validation</groupId>
|
||||
<artifactId>validation-api</artifactId>
|
||||
<version>1.1.0.Final</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -17,7 +17,7 @@ import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Api(value = "fake", description = "the fake API")
|
||||
public interface FakeApi {
|
||||
@@ -70,9 +70,9 @@ public interface FakeApi {
|
||||
@ApiParam(value = "Form parameter enum test (string)" , allowableValues="_ABC, _EFG, _XYZ_", defaultValue="-efg") @RequestPart(value="enumFormString", required=false) String enumFormString,
|
||||
@ApiParam(value = "Header parameter enum test (string array)" , allowableValues="GREATER_THAN, DOLLAR") @RequestHeader(value="enum_header_string_array", required=false) List<String> enumHeaderStringArray,
|
||||
@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_ABC, _EFG, _XYZ_", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,
|
||||
@ApiParam(value = "Query parameter enum test (string array)", allowableValues = "GREATER_THAN, DOLLAR") @RequestParam(value = "enumQueryStringArray", required = false) List<String> enumQueryStringArray,
|
||||
@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_ABC, _EFG, _XYZ_", defaultValue = "-efg") @RequestParam(value = "enumQueryString", required = false, defaultValue="-efg") String enumQueryString,
|
||||
@ApiParam(value = "Query parameter enum test (double)") @RequestParam(value = "enumQueryInteger", required = false) Integer enumQueryInteger,
|
||||
@ApiParam(value = "Query parameter enum test (string array)", allowableValues = "GREATER_THAN, DOLLAR") @RequestParam(value = "enumQueryStringArray", required = false) List<String> enumQueryStringArray,
|
||||
@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_ABC, _EFG, _XYZ_", defaultValue = "-efg") @RequestParam(value = "enumQueryString", required = false, defaultValue="-efg") String enumQueryString,
|
||||
@ApiParam(value = "Query parameter enum test (double)") @RequestParam(value = "enumQueryInteger", required = false) Integer enumQueryInteger,
|
||||
@ApiParam(value = "Query parameter enum test (double)" ) @RequestPart(value="enumQueryDouble", required=false) Double enumQueryDouble);
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Controller
|
||||
public class FakeApiController implements FakeApi {
|
||||
@@ -53,9 +53,9 @@ public class FakeApiController implements FakeApi {
|
||||
@ApiParam(value = "Form parameter enum test (string)" , allowableValues="_ABC, _EFG, _XYZ_", defaultValue="-efg") @RequestPart(value="enumFormString", required=false) String enumFormString,
|
||||
@ApiParam(value = "Header parameter enum test (string array)" , allowableValues="GREATER_THAN, DOLLAR") @RequestHeader(value="enum_header_string_array", required=false) List<String> enumHeaderStringArray,
|
||||
@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_ABC, _EFG, _XYZ_", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,
|
||||
@ApiParam(value = "Query parameter enum test (string array)", allowableValues = "GREATER_THAN, DOLLAR") @RequestParam(value = "enumQueryStringArray", required = false) List<String> enumQueryStringArray,
|
||||
@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_ABC, _EFG, _XYZ_", defaultValue = "-efg") @RequestParam(value = "enumQueryString", required = false, defaultValue="-efg") String enumQueryString,
|
||||
@ApiParam(value = "Query parameter enum test (double)") @RequestParam(value = "enumQueryInteger", required = false) Integer enumQueryInteger,
|
||||
@ApiParam(value = "Query parameter enum test (string array)", allowableValues = "GREATER_THAN, DOLLAR") @RequestParam(value = "enumQueryStringArray", required = false) List<String> enumQueryStringArray,
|
||||
@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_ABC, _EFG, _XYZ_", defaultValue = "-efg") @RequestParam(value = "enumQueryString", required = false, defaultValue="-efg") String enumQueryString,
|
||||
@ApiParam(value = "Query parameter enum test (double)") @RequestParam(value = "enumQueryInteger", required = false) Integer enumQueryInteger,
|
||||
@ApiParam(value = "Query parameter enum test (double)" ) @RequestPart(value="enumQueryDouble", required=false) Double enumQueryDouble) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import java.io.File;
|
||||
import io.swagger.model.ModelApiResponse;
|
||||
import io.swagger.model.Pet;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
@@ -16,7 +15,7 @@ import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Api(value = "pet", description = "the pet API")
|
||||
public interface PetApi {
|
||||
@@ -30,10 +29,10 @@ public interface PetApi {
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 405, message = "Invalid input", response = Void.class) })
|
||||
@RequestMapping(value = "/pet",
|
||||
produces = { "application/xml", "application/json" },
|
||||
produces = { "application/json", "application/xml" },
|
||||
consumes = { "application/json", "application/xml" },
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<Void> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @RequestBody Pet body);
|
||||
ResponseEntity<Void> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ) @RequestBody Pet body);
|
||||
|
||||
|
||||
@ApiOperation(value = "Deletes a pet", notes = "", response = Void.class, authorizations = {
|
||||
@@ -45,7 +44,7 @@ public interface PetApi {
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 400, message = "Invalid pet value", response = Void.class) })
|
||||
@RequestMapping(value = "/pet/{petId}",
|
||||
produces = { "application/xml", "application/json" },
|
||||
produces = { "application/json", "application/xml" },
|
||||
method = RequestMethod.DELETE)
|
||||
ResponseEntity<Void> deletePet(@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId,
|
||||
@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey);
|
||||
@@ -61,9 +60,9 @@ public interface PetApi {
|
||||
@ApiResponse(code = 200, message = "successful operation", response = Pet.class),
|
||||
@ApiResponse(code = 400, message = "Invalid status value", response = Pet.class) })
|
||||
@RequestMapping(value = "/pet/findByStatus",
|
||||
produces = { "application/xml", "application/json" },
|
||||
produces = { "application/json", "application/xml" },
|
||||
method = RequestMethod.GET)
|
||||
ResponseEntity<List<Pet>> findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "AVAILABLE, PENDING, SOLD") @RequestParam(value = "status", required = true) List<String> status);
|
||||
ResponseEntity<List<Pet>> findPetsByStatus( @ApiParam(value = "Status values that need to be considered for filter", allowableValues = "AVAILABLE, PENDING, SOLD", defaultValue = "available") @RequestParam(value = "status", required = false, defaultValue="available") List<String> status);
|
||||
|
||||
|
||||
@ApiOperation(value = "Finds Pets by tags", notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List", authorizations = {
|
||||
@@ -76,12 +75,16 @@ public interface PetApi {
|
||||
@ApiResponse(code = 200, message = "successful operation", response = Pet.class),
|
||||
@ApiResponse(code = 400, message = "Invalid tag value", response = Pet.class) })
|
||||
@RequestMapping(value = "/pet/findByTags",
|
||||
produces = { "application/xml", "application/json" },
|
||||
produces = { "application/json", "application/xml" },
|
||||
method = RequestMethod.GET)
|
||||
ResponseEntity<List<Pet>> findPetsByTags(@ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List<String> tags);
|
||||
ResponseEntity<List<Pet>> findPetsByTags( @ApiParam(value = "Tags to filter by") @RequestParam(value = "tags", required = false) List<String> tags);
|
||||
|
||||
|
||||
@ApiOperation(value = "Find pet by ID", notes = "Returns a single pet", response = Pet.class, authorizations = {
|
||||
@ApiOperation(value = "Find pet by ID", notes = "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions", response = Pet.class, authorizations = {
|
||||
@Authorization(value = "petstore_auth", scopes = {
|
||||
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
|
||||
@AuthorizationScope(scope = "read:pets", description = "read your pets")
|
||||
}),
|
||||
@Authorization(value = "api_key")
|
||||
}, tags={ "pet", })
|
||||
@ApiResponses(value = {
|
||||
@@ -89,9 +92,9 @@ public interface PetApi {
|
||||
@ApiResponse(code = 400, message = "Invalid ID supplied", response = Pet.class),
|
||||
@ApiResponse(code = 404, message = "Pet not found", response = Pet.class) })
|
||||
@RequestMapping(value = "/pet/{petId}",
|
||||
produces = { "application/xml", "application/json" },
|
||||
produces = { "application/json", "application/xml" },
|
||||
method = RequestMethod.GET)
|
||||
ResponseEntity<Pet> getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId);
|
||||
ResponseEntity<Pet> getPetById(@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("petId") Long petId);
|
||||
|
||||
|
||||
@ApiOperation(value = "Update an existing pet", notes = "", response = Void.class, authorizations = {
|
||||
@@ -105,10 +108,10 @@ public interface PetApi {
|
||||
@ApiResponse(code = 404, message = "Pet not found", response = Void.class),
|
||||
@ApiResponse(code = 405, message = "Validation exception", response = Void.class) })
|
||||
@RequestMapping(value = "/pet",
|
||||
produces = { "application/xml", "application/json" },
|
||||
produces = { "application/json", "application/xml" },
|
||||
consumes = { "application/json", "application/xml" },
|
||||
method = RequestMethod.PUT)
|
||||
ResponseEntity<Void> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @RequestBody Pet body);
|
||||
ResponseEntity<Void> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ) @RequestBody Pet body);
|
||||
|
||||
|
||||
@ApiOperation(value = "Updates a pet in the store with form data", notes = "", response = Void.class, authorizations = {
|
||||
@@ -120,27 +123,27 @@ public interface PetApi {
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 405, message = "Invalid input", response = Void.class) })
|
||||
@RequestMapping(value = "/pet/{petId}",
|
||||
produces = { "application/xml", "application/json" },
|
||||
produces = { "application/json", "application/xml" },
|
||||
consumes = { "application/x-www-form-urlencoded" },
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<Void> updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId,
|
||||
ResponseEntity<Void> updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") String petId,
|
||||
@ApiParam(value = "Updated name of the pet" ) @RequestPart(value="name", required=false) String name,
|
||||
@ApiParam(value = "Updated status of the pet" ) @RequestPart(value="status", required=false) String status);
|
||||
|
||||
|
||||
@ApiOperation(value = "uploads an image", notes = "", response = ModelApiResponse.class, authorizations = {
|
||||
@ApiOperation(value = "uploads an image", notes = "", response = Void.class, authorizations = {
|
||||
@Authorization(value = "petstore_auth", scopes = {
|
||||
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
|
||||
@AuthorizationScope(scope = "read:pets", description = "read your pets")
|
||||
})
|
||||
}, tags={ "pet", })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) })
|
||||
@ApiResponse(code = 200, message = "successful operation", response = Void.class) })
|
||||
@RequestMapping(value = "/pet/{petId}/uploadImage",
|
||||
produces = { "application/json" },
|
||||
produces = { "application/json", "application/xml" },
|
||||
consumes = { "multipart/form-data" },
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<ModelApiResponse> uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId,
|
||||
ResponseEntity<Void> uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId,
|
||||
@ApiParam(value = "Additional data to pass to server" ) @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,
|
||||
@ApiParam(value = "file detail") @RequestPart("file") MultipartFile file);
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import java.io.File;
|
||||
import io.swagger.model.ModelApiResponse;
|
||||
import io.swagger.model.Pet;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
@@ -18,14 +17,14 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Controller
|
||||
public class PetApiController implements PetApi {
|
||||
|
||||
|
||||
|
||||
public ResponseEntity<Void> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @RequestBody Pet body) {
|
||||
public ResponseEntity<Void> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ) @RequestBody Pet body) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
}
|
||||
@@ -36,38 +35,38 @@ public class PetApiController implements PetApi {
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
public ResponseEntity<List<Pet>> findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "AVAILABLE, PENDING, SOLD") @RequestParam(value = "status", required = true) List<String> status) {
|
||||
public ResponseEntity<List<Pet>> findPetsByStatus( @ApiParam(value = "Status values that need to be considered for filter", allowableValues = "AVAILABLE, PENDING, SOLD", defaultValue = "available") @RequestParam(value = "status", required = false, defaultValue="available") List<String> status) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<List<Pet>>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
public ResponseEntity<List<Pet>> findPetsByTags(@ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List<String> tags) {
|
||||
public ResponseEntity<List<Pet>> findPetsByTags( @ApiParam(value = "Tags to filter by") @RequestParam(value = "tags", required = false) List<String> tags) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<List<Pet>>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
public ResponseEntity<Pet> getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId) {
|
||||
public ResponseEntity<Pet> getPetById(@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("petId") Long petId) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Pet>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @RequestBody Pet body) {
|
||||
public ResponseEntity<Void> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ) @RequestBody Pet body) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId,
|
||||
public ResponseEntity<Void> updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") String petId,
|
||||
@ApiParam(value = "Updated name of the pet" ) @RequestPart(value="name", required=false) String name,
|
||||
@ApiParam(value = "Updated status of the pet" ) @RequestPart(value="status", required=false) String status) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
public ResponseEntity<ModelApiResponse> uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId,
|
||||
public ResponseEntity<Void> uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId,
|
||||
@ApiParam(value = "Additional data to pass to server" ) @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,
|
||||
@ApiParam(value = "file detail") @RequestPart("file") MultipartFile file) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<ModelApiResponse>(HttpStatus.OK);
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Api(value = "store", description = "the store API")
|
||||
public interface StoreApi {
|
||||
@@ -25,7 +25,7 @@ public interface StoreApi {
|
||||
@ApiResponse(code = 400, message = "Invalid ID supplied", response = Void.class),
|
||||
@ApiResponse(code = 404, message = "Order not found", response = Void.class) })
|
||||
@RequestMapping(value = "/store/order/{orderId}",
|
||||
produces = { "application/xml", "application/json" },
|
||||
produces = { "application/json", "application/xml" },
|
||||
method = RequestMethod.DELETE)
|
||||
ResponseEntity<Void> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("orderId") String orderId);
|
||||
|
||||
@@ -36,7 +36,7 @@ public interface StoreApi {
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "successful operation", response = Integer.class) })
|
||||
@RequestMapping(value = "/store/inventory",
|
||||
produces = { "application/json" },
|
||||
produces = { "application/json", "application/xml" },
|
||||
method = RequestMethod.GET)
|
||||
ResponseEntity<Map<String, Integer>> getInventory();
|
||||
|
||||
@@ -47,9 +47,9 @@ public interface StoreApi {
|
||||
@ApiResponse(code = 400, message = "Invalid ID supplied", response = Order.class),
|
||||
@ApiResponse(code = 404, message = "Order not found", response = Order.class) })
|
||||
@RequestMapping(value = "/store/order/{orderId}",
|
||||
produces = { "application/xml", "application/json" },
|
||||
produces = { "application/json", "application/xml" },
|
||||
method = RequestMethod.GET)
|
||||
ResponseEntity<Order> getOrderById(@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("orderId") Long orderId);
|
||||
ResponseEntity<Order> getOrderById(@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("orderId") String orderId);
|
||||
|
||||
|
||||
@ApiOperation(value = "Place an order for a pet", notes = "", response = Order.class, tags={ "store", })
|
||||
@@ -57,8 +57,8 @@ public interface StoreApi {
|
||||
@ApiResponse(code = 200, message = "successful operation", response = Order.class),
|
||||
@ApiResponse(code = 400, message = "Invalid Order", response = Order.class) })
|
||||
@RequestMapping(value = "/store/order",
|
||||
produces = { "application/xml", "application/json" },
|
||||
produces = { "application/json", "application/xml" },
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<Order> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @RequestBody Order body);
|
||||
ResponseEntity<Order> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ) @RequestBody Order body);
|
||||
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Controller
|
||||
public class StoreApiController implements StoreApi {
|
||||
@@ -34,12 +34,12 @@ public class StoreApiController implements StoreApi {
|
||||
return new ResponseEntity<Map<String, Integer>>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
public ResponseEntity<Order> getOrderById(@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("orderId") Long orderId) {
|
||||
public ResponseEntity<Order> getOrderById(@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("orderId") String orderId) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Order>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
public ResponseEntity<Order> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @RequestBody Order body) {
|
||||
public ResponseEntity<Order> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ) @RequestBody Order body) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Order>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Api(value = "user", description = "the user API")
|
||||
public interface UserApi {
|
||||
@@ -24,27 +24,27 @@ public interface UserApi {
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "successful operation", response = Void.class) })
|
||||
@RequestMapping(value = "/user",
|
||||
produces = { "application/xml", "application/json" },
|
||||
produces = { "application/json", "application/xml" },
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<Void> createUser(@ApiParam(value = "Created user object" ,required=true ) @RequestBody User body);
|
||||
ResponseEntity<Void> createUser(@ApiParam(value = "Created user object" ) @RequestBody User body);
|
||||
|
||||
|
||||
@ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class, tags={ "user", })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "successful operation", response = Void.class) })
|
||||
@RequestMapping(value = "/user/createWithArray",
|
||||
produces = { "application/xml", "application/json" },
|
||||
produces = { "application/json", "application/xml" },
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<Void> createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @RequestBody List<User> body);
|
||||
ResponseEntity<Void> createUsersWithArrayInput(@ApiParam(value = "List of user object" ) @RequestBody List<User> body);
|
||||
|
||||
|
||||
@ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class, tags={ "user", })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "successful operation", response = Void.class) })
|
||||
@RequestMapping(value = "/user/createWithList",
|
||||
produces = { "application/xml", "application/json" },
|
||||
produces = { "application/json", "application/xml" },
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<Void> createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @RequestBody List<User> body);
|
||||
ResponseEntity<Void> createUsersWithListInput(@ApiParam(value = "List of user object" ) @RequestBody List<User> body);
|
||||
|
||||
|
||||
@ApiOperation(value = "Delete user", notes = "This can only be done by the logged in user.", response = Void.class, tags={ "user", })
|
||||
@@ -52,7 +52,7 @@ public interface UserApi {
|
||||
@ApiResponse(code = 400, message = "Invalid username supplied", response = Void.class),
|
||||
@ApiResponse(code = 404, message = "User not found", response = Void.class) })
|
||||
@RequestMapping(value = "/user/{username}",
|
||||
produces = { "application/xml", "application/json" },
|
||||
produces = { "application/json", "application/xml" },
|
||||
method = RequestMethod.DELETE)
|
||||
ResponseEntity<Void> deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username);
|
||||
|
||||
@@ -63,7 +63,7 @@ public interface UserApi {
|
||||
@ApiResponse(code = 400, message = "Invalid username supplied", response = User.class),
|
||||
@ApiResponse(code = 404, message = "User not found", response = User.class) })
|
||||
@RequestMapping(value = "/user/{username}",
|
||||
produces = { "application/xml", "application/json" },
|
||||
produces = { "application/json", "application/xml" },
|
||||
method = RequestMethod.GET)
|
||||
ResponseEntity<User> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username);
|
||||
|
||||
@@ -73,17 +73,17 @@ public interface UserApi {
|
||||
@ApiResponse(code = 200, message = "successful operation", response = String.class),
|
||||
@ApiResponse(code = 400, message = "Invalid username/password supplied", response = String.class) })
|
||||
@RequestMapping(value = "/user/login",
|
||||
produces = { "application/xml", "application/json" },
|
||||
produces = { "application/json", "application/xml" },
|
||||
method = RequestMethod.GET)
|
||||
ResponseEntity<String> loginUser(@ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username,
|
||||
@ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password);
|
||||
ResponseEntity<String> loginUser( @ApiParam(value = "The user name for login") @RequestParam(value = "username", required = false) String username,
|
||||
@ApiParam(value = "The password for login in clear text") @RequestParam(value = "password", required = false) String password);
|
||||
|
||||
|
||||
@ApiOperation(value = "Logs out current logged in user session", notes = "", response = Void.class, tags={ "user", })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "successful operation", response = Void.class) })
|
||||
@RequestMapping(value = "/user/logout",
|
||||
produces = { "application/xml", "application/json" },
|
||||
produces = { "application/json", "application/xml" },
|
||||
method = RequestMethod.GET)
|
||||
ResponseEntity<Void> logoutUser();
|
||||
|
||||
@@ -93,9 +93,9 @@ public interface UserApi {
|
||||
@ApiResponse(code = 400, message = "Invalid user supplied", response = Void.class),
|
||||
@ApiResponse(code = 404, message = "User not found", response = Void.class) })
|
||||
@RequestMapping(value = "/user/{username}",
|
||||
produces = { "application/xml", "application/json" },
|
||||
produces = { "application/json", "application/xml" },
|
||||
method = RequestMethod.PUT)
|
||||
ResponseEntity<Void> updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username,
|
||||
@ApiParam(value = "Updated user object" ,required=true ) @RequestBody User body);
|
||||
@ApiParam(value = "Updated user object" ) @RequestBody User body);
|
||||
|
||||
}
|
||||
|
||||
@@ -17,24 +17,24 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Controller
|
||||
public class UserApiController implements UserApi {
|
||||
|
||||
|
||||
|
||||
public ResponseEntity<Void> createUser(@ApiParam(value = "Created user object" ,required=true ) @RequestBody User body) {
|
||||
public ResponseEntity<Void> createUser(@ApiParam(value = "Created user object" ) @RequestBody User body) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @RequestBody List<User> body) {
|
||||
public ResponseEntity<Void> createUsersWithArrayInput(@ApiParam(value = "List of user object" ) @RequestBody List<User> body) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @RequestBody List<User> body) {
|
||||
public ResponseEntity<Void> createUsersWithListInput(@ApiParam(value = "List of user object" ) @RequestBody List<User> body) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
}
|
||||
@@ -49,8 +49,8 @@ public class UserApiController implements UserApi {
|
||||
return new ResponseEntity<User>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
public ResponseEntity<String> loginUser(@ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username,
|
||||
@ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password) {
|
||||
public ResponseEntity<String> loginUser( @ApiParam(value = "The user name for login") @RequestParam(value = "username", required = false) String username,
|
||||
@ApiParam(value = "The password for login in clear text") @RequestParam(value = "password", required = false) String password) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<String>(HttpStatus.OK);
|
||||
}
|
||||
@@ -61,7 +61,7 @@ public class UserApiController implements UserApi {
|
||||
}
|
||||
|
||||
public ResponseEntity<Void> updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username,
|
||||
@ApiParam(value = "Updated user object" ,required=true ) @RequestBody User body) {
|
||||
@ApiParam(value = "Updated user object" ) @RequestBody User body) {
|
||||
// do some magic!
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@@ -17,12 +17,12 @@ public class SwaggerDocumentationConfig {
|
||||
ApiInfo apiInfo() {
|
||||
return new ApiInfoBuilder()
|
||||
.title("Swagger Petstore")
|
||||
.description("This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\")
|
||||
.description("This is a sample server Petstore server. You can find out more about Swagger at <a href=\"http://swagger.io\">http://swagger.io</a> or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters")
|
||||
.license("Apache 2.0")
|
||||
.licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html")
|
||||
.termsOfServiceUrl("")
|
||||
.version("1.0.0")
|
||||
.contact(new Contact("","", "apiteam@swagger.io"))
|
||||
.contact(new Contact("","", "apiteam@wordnik.com"))
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* AdditionalPropertiesClass
|
||||
*/
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.fasterxml.jackson.annotation.JsonSubTypes;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* Animal
|
||||
*/
|
||||
@@ -29,6 +29,7 @@ public class Animal {
|
||||
* @return className
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
public String getClassName() {
|
||||
return className;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import java.util.Objects;
|
||||
import io.swagger.model.Animal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* AnimalFarm
|
||||
*/
|
||||
|
||||
@@ -8,7 +8,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* ArrayOfArrayOfNumberOnly
|
||||
*/
|
||||
|
||||
@@ -8,7 +8,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* ArrayOfNumberOnly
|
||||
*/
|
||||
|
||||
@@ -8,7 +8,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.model.ReadOnlyFirst;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* ArrayTest
|
||||
*/
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.model.Animal;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* Cat
|
||||
*/
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* Category
|
||||
*/
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* Model for testing model with \"_class\" property
|
||||
*/
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* Client
|
||||
*/
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.model.Animal;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* Dog
|
||||
*/
|
||||
|
||||
@@ -8,7 +8,7 @@ import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* EnumArrays
|
||||
*/
|
||||
|
||||
@@ -2,7 +2,7 @@ package io.swagger.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.model.OuterEnum;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* EnumTest
|
||||
*/
|
||||
|
||||
@@ -8,7 +8,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import java.math.BigDecimal;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.LocalDate;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* FormatTest
|
||||
*/
|
||||
@@ -65,6 +65,8 @@ public class FormatTest {
|
||||
* @return integer
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
@Min(10)
|
||||
@Max(100)
|
||||
public Integer getInteger() {
|
||||
return integer;
|
||||
}
|
||||
@@ -85,6 +87,8 @@ public class FormatTest {
|
||||
* @return int32
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
@Min(20)
|
||||
@Max(200)
|
||||
public Integer getInt32() {
|
||||
return int32;
|
||||
}
|
||||
@@ -123,6 +127,9 @@ public class FormatTest {
|
||||
* @return number
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
@DecimalMin("32.1")
|
||||
@DecimalMax("543.2")
|
||||
public BigDecimal getNumber() {
|
||||
return number;
|
||||
}
|
||||
@@ -143,6 +150,8 @@ public class FormatTest {
|
||||
* @return _float
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
@DecimalMin("54.3")
|
||||
@DecimalMax("987.6")
|
||||
public Float getFloat() {
|
||||
return _float;
|
||||
}
|
||||
@@ -163,6 +172,8 @@ public class FormatTest {
|
||||
* @return _double
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
@DecimalMin("67.8")
|
||||
@DecimalMax("123.4")
|
||||
public Double getDouble() {
|
||||
return _double;
|
||||
}
|
||||
@@ -181,6 +192,7 @@ public class FormatTest {
|
||||
* @return string
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
@Pattern(regexp="/[a-z]/i")
|
||||
public String getString() {
|
||||
return string;
|
||||
}
|
||||
@@ -199,6 +211,7 @@ public class FormatTest {
|
||||
* @return _byte
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
public byte[] getByte() {
|
||||
return _byte;
|
||||
}
|
||||
@@ -235,6 +248,7 @@ public class FormatTest {
|
||||
* @return date
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
public LocalDate getDate() {
|
||||
return date;
|
||||
}
|
||||
@@ -289,6 +303,8 @@ public class FormatTest {
|
||||
* @return password
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
@Size(min=10,max=64)
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* HasOnlyReadOnly
|
||||
*/
|
||||
|
||||
@@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* MapTest
|
||||
*/
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* MixedPropertiesAndAdditionalPropertiesClass
|
||||
*/
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* Model for testing model name starting with number
|
||||
*/
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* ModelApiResponse
|
||||
*/
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* Model for testing reserved words
|
||||
*/
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* Model for testing model name same as property name
|
||||
*/
|
||||
@@ -34,6 +34,7 @@ public class Name {
|
||||
* @return name
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@NotNull
|
||||
public Integer getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* NumberOnly
|
||||
*/
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* Order
|
||||
*/
|
||||
@@ -62,7 +62,7 @@ public class Order {
|
||||
private StatusEnum status = null;
|
||||
|
||||
@JsonProperty("complete")
|
||||
private Boolean complete = false;
|
||||
private Boolean complete = null;
|
||||
|
||||
public Order id(Long id) {
|
||||
this.id = id;
|
||||
|
||||
@@ -2,7 +2,7 @@ package io.swagger.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
|
||||
/**
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user