forked from loafle/openapi-generator-original
Merge pull request #1967 from wing328/support-jaxrs-cxf-2
[Java][JAX-RS] Support JAX-RS CXF
This commit is contained in:
commit
fc88cb9801
13
README.md
13
README.md
@ -534,13 +534,22 @@ java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
|
|||||||
-o samples/server/petstore/scalatra
|
-o samples/server/petstore/scalatra
|
||||||
```
|
```
|
||||||
|
|
||||||
### Java JAX-RS
|
### Java JAX-RS (Jersey v1.18)
|
||||||
|
|
||||||
```
|
```
|
||||||
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
|
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
|
||||||
-i http://petstore.swagger.io/v2/swagger.json \
|
-i http://petstore.swagger.io/v2/swagger.json \
|
||||||
-l jaxrs \
|
-l jaxrs \
|
||||||
-o samples/server/petstore/jaxrs
|
-o samples/server/petstore/jaxrs-jersey
|
||||||
|
```
|
||||||
|
|
||||||
|
### Java JAX-RS (Apache CXF 3)
|
||||||
|
|
||||||
|
```
|
||||||
|
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
|
||||||
|
-i http://petstore.swagger.io/v2/swagger.json \
|
||||||
|
-l jaxrs-cxf \
|
||||||
|
-o samples/server/petstore/jaxrs-cxf
|
||||||
```
|
```
|
||||||
|
|
||||||
### Java Spring MVC
|
### Java Spring MVC
|
||||||
|
31
bin/jaxrs-cxf-petstore-server.sh
Executable file
31
bin/jaxrs-cxf-petstore-server.sh
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
SCRIPT="$0"
|
||||||
|
|
||||||
|
while [ -h "$SCRIPT" ] ; do
|
||||||
|
ls=`ls -ld "$SCRIPT"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
SCRIPT="$link"
|
||||||
|
else
|
||||||
|
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ ! -d "${APP_DIR}" ]; then
|
||||||
|
APP_DIR=`dirname "$SCRIPT"`/..
|
||||||
|
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||||
|
fi
|
||||||
|
|
||||||
|
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||||
|
|
||||||
|
if [ ! -f "$executable" ]
|
||||||
|
then
|
||||||
|
mvn clean package
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
|
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaJaxRS -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l jaxrs-cxf -o samples/server/petstore/jaxrs-cxf"
|
||||||
|
|
||||||
|
java $JAVA_OPTS -jar $executable $ags
|
@ -0,0 +1,183 @@
|
|||||||
|
package io.swagger.codegen.languages;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import io.swagger.codegen.CodegenOperation;
|
||||||
|
import io.swagger.codegen.CodegenResponse;
|
||||||
|
import io.swagger.codegen.CodegenType;
|
||||||
|
import io.swagger.models.Operation;
|
||||||
|
import io.swagger.models.Path;
|
||||||
|
import io.swagger.models.Swagger;
|
||||||
|
|
||||||
|
public abstract class AbstractJavaJAXRSServerCodegen extends JavaClientCodegen
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Name of the sub-directory in "src/main/resource" where to find the
|
||||||
|
* Mustache template for the JAX-RS Codegen.
|
||||||
|
*/
|
||||||
|
protected static final String JAXRS_TEMPLATE_DIRECTORY_NAME = "JavaJaxRS";
|
||||||
|
protected String implFolder = "src/main/java";
|
||||||
|
protected String title = "Swagger Server";
|
||||||
|
|
||||||
|
public AbstractJavaJAXRSServerCodegen()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================
|
||||||
|
// ABSTRACT METHODS
|
||||||
|
// ================
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public abstract String getHelp();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public abstract String getName();
|
||||||
|
|
||||||
|
// ===============
|
||||||
|
// COMMONS METHODS
|
||||||
|
// ===============
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CodegenType getTag()
|
||||||
|
{
|
||||||
|
return CodegenType.SERVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void preprocessSwagger(Swagger swagger)
|
||||||
|
{
|
||||||
|
if ( "/".equals(swagger.getBasePath()) ) {
|
||||||
|
swagger.setBasePath("");
|
||||||
|
}
|
||||||
|
|
||||||
|
String host = swagger.getHost();
|
||||||
|
String port = "8080"; // Default value for a JEE Server
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||||
|
if ( operations != null ) {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
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 String toApiName(final String name)
|
||||||
|
{
|
||||||
|
String computed = name;
|
||||||
|
if ( computed.length() == 0 ) {
|
||||||
|
return "DefaultApi";
|
||||||
|
}
|
||||||
|
computed = sanitizeName(computed);
|
||||||
|
return camelize(computed) + "Api";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String apiFilename(String templateName, String tag)
|
||||||
|
{
|
||||||
|
String result = super.apiFilename(templateName, tag);
|
||||||
|
|
||||||
|
if ( templateName.endsWith("Impl.mustache") ) {
|
||||||
|
int ix = result.lastIndexOf('/');
|
||||||
|
result = result.substring(0, ix) + "/impl" + result.substring(ix, result.length() - 5) + "ServiceImpl.java";
|
||||||
|
result = result.replace(apiFileFolder(), implFileFolder(implFolder));
|
||||||
|
} else if ( templateName.endsWith("Factory.mustache") ) {
|
||||||
|
int ix = result.lastIndexOf('/');
|
||||||
|
result = result.substring(0, ix) + "/factories" + result.substring(ix, result.length() - 5) + "ServiceFactory.java";
|
||||||
|
result = result.replace(apiFileFolder(), implFileFolder(implFolder));
|
||||||
|
} else if ( templateName.endsWith("Service.mustache") ) {
|
||||||
|
int ix = result.lastIndexOf('.');
|
||||||
|
result = result.substring(0, ix) + "Service.java";
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String implFileFolder(String output)
|
||||||
|
{
|
||||||
|
return outputFolder + "/" + output + "/" + apiPackage().replace('.', '/');
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldOverwrite(String filename)
|
||||||
|
{
|
||||||
|
return super.shouldOverwrite(filename) && !filename.endsWith("ServiceImpl.java") && !filename.endsWith("ServiceFactory.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,73 @@
|
|||||||
|
|
||||||
|
package io.swagger.codegen.languages;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import io.swagger.codegen.CliOption;
|
||||||
|
import io.swagger.codegen.CodegenConstants;
|
||||||
|
import io.swagger.codegen.CodegenOperation;
|
||||||
|
import io.swagger.models.Operation;
|
||||||
|
|
||||||
|
public class JavaCXFServerCodegen extends AbstractJavaJAXRSServerCodegen
|
||||||
|
{
|
||||||
|
public JavaCXFServerCodegen()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
|
||||||
|
sourceFolder = "src/gen/java";
|
||||||
|
invokerPackage = "io.swagger.api";
|
||||||
|
artifactId = "swagger-jaxrs-server";
|
||||||
|
outputFolder = "generated-code/JavaJaxRS-CXF";
|
||||||
|
|
||||||
|
modelTemplateFiles.put("model.mustache", ".java");
|
||||||
|
apiTemplateFiles.put("api.mustache", ".java");
|
||||||
|
apiPackage = "io.swagger.api";
|
||||||
|
modelPackage = "io.swagger.model";
|
||||||
|
|
||||||
|
additionalProperties.put("title", title);
|
||||||
|
|
||||||
|
super.embeddedTemplateDir = templateDir = JAXRS_TEMPLATE_DIRECTORY_NAME + File.separator + "cxf";
|
||||||
|
|
||||||
|
for ( int i = 0; i < cliOptions.size(); i++ ) {
|
||||||
|
if ( CodegenConstants.LIBRARY.equals(cliOptions.get(i).getOpt()) ) {
|
||||||
|
cliOptions.remove(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cliOptions.add(new CliOption(CodegenConstants.IMPL_FOLDER, CodegenConstants.IMPL_FOLDER_DESC));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processOpts()
|
||||||
|
{
|
||||||
|
super.processOpts();
|
||||||
|
sourceFolder = "gen" + File.separator + "java";
|
||||||
|
|
||||||
|
modelTemplateFiles.clear();
|
||||||
|
modelTemplateFiles.put("entityModel.mustache", ".java");
|
||||||
|
|
||||||
|
supportingFiles.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return "jaxrs-cxf";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co, Map<String, List<CodegenOperation>> operations) {
|
||||||
|
super.addOperationToGroup(tag, resourcePath, operation, co, operations);
|
||||||
|
co.subresourceOperation = !co.path.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getHelp()
|
||||||
|
{
|
||||||
|
return "Generates a Java JAXRS Server application based on Apache CXF framework.";
|
||||||
|
}
|
||||||
|
}
|
@ -493,7 +493,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
if (allDefinitions != null && codegenModel != null && codegenModel.parentSchema != null && codegenModel.hasEnums) {
|
if (allDefinitions != null && codegenModel != null && codegenModel.parentSchema != null && codegenModel.hasEnums) {
|
||||||
final Model parentModel = allDefinitions.get(codegenModel.parentSchema);
|
final Model parentModel = allDefinitions.get(codegenModel.parentSchema);
|
||||||
final CodegenModel parentCodegenModel = super.fromModel(codegenModel.parent, parentModel);
|
final CodegenModel parentCodegenModel = super.fromModel(codegenModel.parent, parentModel);
|
||||||
codegenModel = this.reconcileInlineEnums(codegenModel, parentCodegenModel);
|
codegenModel = JavaClientCodegen.reconcileInlineEnums(codegenModel, parentCodegenModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
return codegenModel;
|
return codegenModel;
|
||||||
|
@ -0,0 +1,124 @@
|
|||||||
|
package io.swagger.codegen.languages;
|
||||||
|
|
||||||
|
import io.swagger.codegen.*;
|
||||||
|
import io.swagger.models.Operation;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class JavaJerseyServerCodegen extends AbstractJavaJAXRSServerCodegen
|
||||||
|
{
|
||||||
|
|
||||||
|
public JavaJerseyServerCodegen()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
|
||||||
|
sourceFolder = "src/gen/java";
|
||||||
|
invokerPackage = "io.swagger.api";
|
||||||
|
artifactId = "swagger-jaxrs-server";
|
||||||
|
outputFolder = "generated-code/JavaJaxRS-Jersey";
|
||||||
|
|
||||||
|
modelTemplateFiles.put("model.mustache", ".java");
|
||||||
|
apiTemplateFiles.put("api.mustache", ".java");
|
||||||
|
apiTemplateFiles.put("apiService.mustache", ".java");
|
||||||
|
apiTemplateFiles.put("apiServiceImpl.mustache", ".java");
|
||||||
|
apiTemplateFiles.put("apiServiceFactory.mustache", ".java");
|
||||||
|
apiPackage = "io.swagger.api";
|
||||||
|
modelPackage = "io.swagger.model";
|
||||||
|
|
||||||
|
additionalProperties.put("title", title);
|
||||||
|
|
||||||
|
embeddedTemplateDir = templateDir = JAXRS_TEMPLATE_DIRECTORY_NAME + File.separator + "jersey1_18";
|
||||||
|
|
||||||
|
for ( int i = 0; i < cliOptions.size(); i++ ) {
|
||||||
|
if ( CodegenConstants.LIBRARY.equals(cliOptions.get(i).getOpt()) ) {
|
||||||
|
cliOptions.remove(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CliOption library = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use");
|
||||||
|
library.setDefault(DEFAULT_LIBRARY);
|
||||||
|
|
||||||
|
Map<String, String> supportedLibraries = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
|
supportedLibraries.put(DEFAULT_LIBRARY, "Jersey core 1.18.1");
|
||||||
|
library.setEnum(supportedLibraries);
|
||||||
|
|
||||||
|
cliOptions.add(library);
|
||||||
|
cliOptions.add(new CliOption(CodegenConstants.IMPL_FOLDER, CodegenConstants.IMPL_FOLDER_DESC));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return "jaxrs"; // TODO should be renamed as "jaxrs-jersey"
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getHelp()
|
||||||
|
{
|
||||||
|
return "Generates a Java JAXRS Server application based on Jersey framework.";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processOpts()
|
||||||
|
{
|
||||||
|
super.processOpts();
|
||||||
|
|
||||||
|
if ( additionalProperties.containsKey(CodegenConstants.IMPL_FOLDER) ) {
|
||||||
|
implFolder = (String) additionalProperties.get(CodegenConstants.IMPL_FOLDER);
|
||||||
|
}
|
||||||
|
|
||||||
|
supportingFiles.clear();
|
||||||
|
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
|
||||||
|
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||||
|
supportingFiles.add(new SupportingFile("ApiException.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "ApiException.java"));
|
||||||
|
supportingFiles.add(new SupportingFile("ApiOriginFilter.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "ApiOriginFilter.java"));
|
||||||
|
supportingFiles.add(new SupportingFile("ApiResponseMessage.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "ApiResponseMessage.java"));
|
||||||
|
supportingFiles.add(new SupportingFile("NotFoundException.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "NotFoundException.java"));
|
||||||
|
supportingFiles.add(new SupportingFile("web.mustache", ("src/main/webapp/WEB-INF"), "web.xml"));
|
||||||
|
supportingFiles.add(new SupportingFile("StringUtil.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "StringUtil.java"));
|
||||||
|
|
||||||
|
if ( additionalProperties.containsKey("dateLibrary") ) {
|
||||||
|
setDateLibrary(additionalProperties.get("dateLibrary").toString());
|
||||||
|
additionalProperties.put(dateLibrary, "true");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( "joda".equals(dateLibrary) ) {
|
||||||
|
supportingFiles.add(new SupportingFile("JodaDateTimeProvider.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "JodaDateTimeProvider.java"));
|
||||||
|
supportingFiles.add(new SupportingFile("JodaLocalDateProvider.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "JodaLocalDateProvider.java"));
|
||||||
|
} else if ( "java8".equals(dateLibrary) ) {
|
||||||
|
supportingFiles.add(new SupportingFile("LocalDateTimeProvider.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "LocalDateTimeProvider.java"));
|
||||||
|
supportingFiles.add(new SupportingFile("LocalDateProvider.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "LocalDateProvider.java"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co, Map<String, List<CodegenOperation>> operations) {
|
||||||
|
String basePath = resourcePath;
|
||||||
|
if (basePath.startsWith("/")) {
|
||||||
|
basePath = basePath.substring(1);
|
||||||
|
}
|
||||||
|
int pos = basePath.indexOf("/");
|
||||||
|
if (pos > 0) {
|
||||||
|
basePath = basePath.substring(0, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (basePath == "") {
|
||||||
|
basePath = "default";
|
||||||
|
} else {
|
||||||
|
if (co.path.startsWith("/" + basePath)) {
|
||||||
|
co.path = co.path.substring(("/" + basePath).length());
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
@ -1,267 +0,0 @@
|
|||||||
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 JaxRSServerCodegen extends JavaClientCodegen {
|
|
||||||
protected String title = "Swagger Server";
|
|
||||||
protected String implFolder = "src/main/java";
|
|
||||||
|
|
||||||
public JaxRSServerCodegen() {
|
|
||||||
super();
|
|
||||||
|
|
||||||
sourceFolder = "src/gen/java";
|
|
||||||
invokerPackage = "io.swagger.api";
|
|
||||||
artifactId = "swagger-jaxrs-server";
|
|
||||||
|
|
||||||
outputFolder = "generated-code/javaJaxRS";
|
|
||||||
modelTemplateFiles.put("model.mustache", ".java");
|
|
||||||
apiTemplateFiles.put("api.mustache", ".java");
|
|
||||||
apiTemplateFiles.put("apiService.mustache", ".java");
|
|
||||||
apiTemplateFiles.put("apiServiceImpl.mustache", ".java");
|
|
||||||
apiTemplateFiles.put("apiServiceFactory.mustache", ".java");
|
|
||||||
apiPackage = "io.swagger.api";
|
|
||||||
modelPackage = "io.swagger.model";
|
|
||||||
|
|
||||||
additionalProperties.put("title", title);
|
|
||||||
|
|
||||||
embeddedTemplateDir = templateDir = "JavaJaxRS" + File.separator + "jersey1_18";
|
|
||||||
|
|
||||||
for(int i = 0; i < cliOptions.size(); i++) {
|
|
||||||
if(CodegenConstants.LIBRARY.equals(cliOptions.get(i).getOpt())) {
|
|
||||||
cliOptions.remove(i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CliOption library = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use");
|
|
||||||
library.setDefault(DEFAULT_LIBRARY);
|
|
||||||
|
|
||||||
Map<String, String> supportedLibraries = new LinkedHashMap<String, String>();
|
|
||||||
|
|
||||||
supportedLibraries.put(DEFAULT_LIBRARY, "Jersey core 1.18.1");
|
|
||||||
// supportedLibraries.put("jersey2", "Jersey2 core library 2.x");
|
|
||||||
library.setEnum(supportedLibraries);
|
|
||||||
|
|
||||||
cliOptions.add(library);
|
|
||||||
cliOptions.add(new CliOption(CodegenConstants.IMPL_FOLDER, CodegenConstants.IMPL_FOLDER_DESC));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CodegenType getTag() {
|
|
||||||
return CodegenType.SERVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return "jaxrs";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getHelp() {
|
|
||||||
return "Generates a Java JAXRS Server application.";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void processOpts() {
|
|
||||||
super.processOpts();
|
|
||||||
|
|
||||||
if(additionalProperties.containsKey(CodegenConstants.IMPL_FOLDER)) {
|
|
||||||
implFolder = (String) additionalProperties.get(CodegenConstants.IMPL_FOLDER);
|
|
||||||
}
|
|
||||||
|
|
||||||
supportingFiles.clear();
|
|
||||||
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
|
|
||||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
|
||||||
supportingFiles.add(new SupportingFile("ApiException.mustache",
|
|
||||||
(sourceFolder + '/' + apiPackage).replace(".", "/"), "ApiException.java"));
|
|
||||||
supportingFiles.add(new SupportingFile("ApiOriginFilter.mustache",
|
|
||||||
(sourceFolder + '/' + apiPackage).replace(".", "/"), "ApiOriginFilter.java"));
|
|
||||||
supportingFiles.add(new SupportingFile("ApiResponseMessage.mustache",
|
|
||||||
(sourceFolder + '/' + apiPackage).replace(".", "/"), "ApiResponseMessage.java"));
|
|
||||||
supportingFiles.add(new SupportingFile("NotFoundException.mustache",
|
|
||||||
(sourceFolder + '/' + apiPackage).replace(".", "/"), "NotFoundException.java"));
|
|
||||||
supportingFiles.add(new SupportingFile("web.mustache",
|
|
||||||
("src/main/webapp/WEB-INF"), "web.xml"));
|
|
||||||
supportingFiles.add(new SupportingFile("StringUtil.mustache",
|
|
||||||
(sourceFolder + '/' + apiPackage).replace(".", "/"), "StringUtil.java"));
|
|
||||||
|
|
||||||
if (additionalProperties.containsKey("dateLibrary")) {
|
|
||||||
setDateLibrary(additionalProperties.get("dateLibrary").toString());
|
|
||||||
additionalProperties.put(dateLibrary, "true");
|
|
||||||
}
|
|
||||||
|
|
||||||
if("joda".equals(dateLibrary)) {
|
|
||||||
supportingFiles.add(new SupportingFile("JodaDateTimeProvider.mustache",
|
|
||||||
(sourceFolder + '/' + apiPackage).replace(".", "/"), "JodaDateTimeProvider.java"));
|
|
||||||
supportingFiles.add(new SupportingFile("JodaLocalDateProvider.mustache",
|
|
||||||
(sourceFolder + '/' + apiPackage).replace(".", "/"), "JodaLocalDateProvider.java"));
|
|
||||||
}
|
|
||||||
else if ("java8".equals(dateLibrary)) {
|
|
||||||
supportingFiles.add(new SupportingFile("LocalDateTimeProvider.mustache",
|
|
||||||
(sourceFolder + '/' + apiPackage).replace(".", "/"), "LocalDateTimeProvider.java"));
|
|
||||||
supportingFiles.add(new SupportingFile("LocalDateProvider.mustache",
|
|
||||||
(sourceFolder + '/' + apiPackage).replace(".", "/"), "LocalDateProvider.java"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co, Map<String, List<CodegenOperation>> operations) {
|
|
||||||
String basePath = resourcePath;
|
|
||||||
if (basePath.startsWith("/")) {
|
|
||||||
basePath = basePath.substring(1);
|
|
||||||
}
|
|
||||||
int pos = basePath.indexOf("/");
|
|
||||||
if (pos > 0) {
|
|
||||||
basePath = basePath.substring(0, pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (basePath == "") {
|
|
||||||
basePath = "default";
|
|
||||||
} else {
|
|
||||||
if (co.path.startsWith("/" + basePath)) {
|
|
||||||
co.path = co.path.substring(("/" + basePath).length());
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void preprocessSwagger(Swagger swagger) {
|
|
||||||
if("/".equals(swagger.getBasePath())) {
|
|
||||||
swagger.setBasePath("");
|
|
||||||
}
|
|
||||||
|
|
||||||
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 String toApiName(String name) {
|
|
||||||
if (name.length() == 0) {
|
|
||||||
return "DefaultApi";
|
|
||||||
}
|
|
||||||
name = sanitizeName(name);
|
|
||||||
return camelize(name) + "Api";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String apiFilename(String templateName, String tag) {
|
|
||||||
|
|
||||||
String result = super.apiFilename(templateName, tag);
|
|
||||||
|
|
||||||
if (templateName.endsWith("Impl.mustache")) {
|
|
||||||
int ix = result.lastIndexOf('/');
|
|
||||||
result = result.substring(0, ix) + "/impl" + result.substring(ix, result.length() - 5) + "ServiceImpl.java";
|
|
||||||
|
|
||||||
result = result.replace(apiFileFolder(), implFileFolder(implFolder));
|
|
||||||
} else if (templateName.endsWith("Factory.mustache")) {
|
|
||||||
int ix = result.lastIndexOf('/');
|
|
||||||
result = result.substring(0, ix) + "/factories" + result.substring(ix, result.length() - 5) + "ServiceFactory.java";
|
|
||||||
|
|
||||||
result = result.replace(apiFileFolder(), implFileFolder(implFolder));
|
|
||||||
} else if (templateName.endsWith("Service.mustache")) {
|
|
||||||
int ix = result.lastIndexOf('.');
|
|
||||||
result = result.substring(0, ix) + "Service.java";
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String implFileFolder(String output) {
|
|
||||||
return outputFolder + "/" + output + "/" + apiPackage().replace('.', '/');
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldOverwrite(String filename) {
|
|
||||||
return super.shouldOverwrite(filename) && !filename.endsWith("ServiceImpl.java") && !filename.endsWith("ServiceFactory.java");
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1 @@
|
|||||||
|
{{#allowableValues}}allowableValues="{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{/values}}{{^values}}range=[{{#min}}{{.}}{{/min}}{{^min}}-infinity{{/min}}, {{#max}}{{.}}{{/max}}{{^max}}infinity{{/max}}]{{/values}}"{{/allowableValues}}
|
@ -0,0 +1,22 @@
|
|||||||
|
package {{package}};
|
||||||
|
|
||||||
|
{{#imports}}import {{import}};
|
||||||
|
{{/imports}}
|
||||||
|
|
||||||
|
import javax.ws.rs.*;
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
|
@Path("{{contextPath}}")
|
||||||
|
public interface {{classname}} {
|
||||||
|
{{#operations}}
|
||||||
|
{{#operation}}
|
||||||
|
@{{httpMethod}}
|
||||||
|
{{#subresourceOperation}}@Path("{{path}}"){{/subresourceOperation}}
|
||||||
|
{{#hasConsumes}}@Consumes({ {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
|
||||||
|
{{#hasProduces}}@Produces({ {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
|
||||||
|
public Response {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},
|
||||||
|
{{/hasMore}}{{/allParams}});
|
||||||
|
{{/operation}}
|
||||||
|
}
|
||||||
|
{{/operations}}
|
||||||
|
|
@ -0,0 +1 @@
|
|||||||
|
{{#isBodyParam}}{{{dataType}}} {{paramName}}{{/isBodyParam}}
|
@ -0,0 +1,51 @@
|
|||||||
|
package {{package}};
|
||||||
|
|
||||||
|
{{#imports}}import {{import}};
|
||||||
|
{{/imports}}
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
{{#models}}
|
||||||
|
|
||||||
|
{{#model}}{{#description}}
|
||||||
|
/**
|
||||||
|
* {{description}}
|
||||||
|
**/{{/description}}
|
||||||
|
@XmlRootElement(name="{{classname}}")
|
||||||
|
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {
|
||||||
|
{{#vars}}
|
||||||
|
{{#isEnum}}
|
||||||
|
public enum {{datatypeWithEnum}} {
|
||||||
|
{{#allowableValues}}{{#values}} {{.}}, {{/values}}{{/allowableValues}}
|
||||||
|
};
|
||||||
|
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};{{/isEnum}}{{^isEnum}}
|
||||||
|
private {{{datatype}}} {{name}} = {{{defaultValue}}};{{/isEnum}}{{/vars}}
|
||||||
|
|
||||||
|
{{#vars}}
|
||||||
|
/**{{#description}}
|
||||||
|
* {{{description}}}{{/description}}{{#minimum}}
|
||||||
|
* minimum: {{minimum}}{{/minimum}}{{#maximum}}
|
||||||
|
* maximum: {{maximum}}{{/maximum}}
|
||||||
|
**/
|
||||||
|
@JsonProperty("{{name}}")
|
||||||
|
public {{{datatypeWithEnum}}} {{getter}}() {
|
||||||
|
return {{name}};
|
||||||
|
}
|
||||||
|
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
|
||||||
|
this.{{name}} = {{name}};
|
||||||
|
}
|
||||||
|
|
||||||
|
{{/vars}}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("class {{classname}} {\n");
|
||||||
|
{{#parent}}sb.append(" " + super.toString()).append("\n");{{/parent}}
|
||||||
|
{{#vars}}sb.append(" {{name}}: ").append({{name}}).append("\n");
|
||||||
|
{{/vars}}sb.append("}\n");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{{/model}}
|
||||||
|
{{/models}}
|
@ -0,0 +1,3 @@
|
|||||||
|
public enum {{classname}} {
|
||||||
|
{{#allowableValues}}{{.}}{{^-last}}, {{/-last}}{{/allowableValues}}
|
||||||
|
}
|
@ -0,0 +1,2 @@
|
|||||||
|
{{#isFormParam}}{{#notFile}}@Multipart(value = "{{paramName}}"{{^required}}, required = false{{/required}}) {{{dataType}}} {{paramName}}{{/notFile}}{{#isFile}} @Multipart(value = "{{paramName}}"{{^required}}, required = false{{/required}}) InputStream {{paramName}}InputStream,
|
||||||
|
@Multipart(value = "{{paramName}}" {{^required}}, required = false{{/required}}) Attachment {{paramName}}Detail{{/isFile}}{{/isFormParam}}
|
@ -0,0 +1 @@
|
|||||||
|
@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}")
|
@ -0,0 +1 @@
|
|||||||
|
{{#isHeaderParam}}@HeaderParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isHeaderParam}}
|
@ -0,0 +1,15 @@
|
|||||||
|
package {{package}};
|
||||||
|
|
||||||
|
{{#imports}}import{{import}};
|
||||||
|
{{/imports}}
|
||||||
|
|
||||||
|
{{#serializableModel}}import java.io.Serializable;{{/serializableModel}}
|
||||||
|
{{#models}}
|
||||||
|
{{#model}}{{#description}}
|
||||||
|
/**
|
||||||
|
* {{description}}
|
||||||
|
**/{{/description}}
|
||||||
|
{{#isEnum}}{{>enumOuterClass}}{{/isEnum}}
|
||||||
|
{{^isEnum}}{{>pojo}}{{/isEnum}}
|
||||||
|
{{/model}}
|
||||||
|
{{/models}}
|
@ -0,0 +1 @@
|
|||||||
|
{{#isPathParam}}@PathParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isPathParam}}
|
@ -0,0 +1 @@
|
|||||||
|
sbt.version=0.12.0
|
@ -0,0 +1 @@
|
|||||||
|
{{#isQueryParam}}@QueryParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isQueryParam}}
|
@ -6,9 +6,10 @@ io.swagger.codegen.languages.FlashClientCodegen
|
|||||||
io.swagger.codegen.languages.FlaskConnexionCodegen
|
io.swagger.codegen.languages.FlaskConnexionCodegen
|
||||||
io.swagger.codegen.languages.GoClientCodegen
|
io.swagger.codegen.languages.GoClientCodegen
|
||||||
io.swagger.codegen.languages.JavaClientCodegen
|
io.swagger.codegen.languages.JavaClientCodegen
|
||||||
io.swagger.codegen.languages.JavascriptClientCodegen
|
io.swagger.codegen.languages.JavaJerseyServerCodegen
|
||||||
io.swagger.codegen.languages.JaxRSServerCodegen
|
io.swagger.codegen.languages.JavaCXFServerCodegen
|
||||||
io.swagger.codegen.languages.JavaInflectorServerCodegen
|
io.swagger.codegen.languages.JavaInflectorServerCodegen
|
||||||
|
io.swagger.codegen.languages.JavascriptClientCodegen
|
||||||
io.swagger.codegen.languages.JMeterCodegen
|
io.swagger.codegen.languages.JMeterCodegen
|
||||||
io.swagger.codegen.languages.NodeJSServerCodegen
|
io.swagger.codegen.languages.NodeJSServerCodegen
|
||||||
io.swagger.codegen.languages.ObjcClientCodegen
|
io.swagger.codegen.languages.ObjcClientCodegen
|
||||||
|
@ -2,7 +2,7 @@ package io.swagger.codegen.jaxrs;
|
|||||||
|
|
||||||
import io.swagger.codegen.CodegenConfig;
|
import io.swagger.codegen.CodegenConfig;
|
||||||
import io.swagger.codegen.java.JavaClientOptionsTest;
|
import io.swagger.codegen.java.JavaClientOptionsTest;
|
||||||
import io.swagger.codegen.languages.JaxRSServerCodegen;
|
import io.swagger.codegen.languages.JavaJerseyServerCodegen;
|
||||||
import io.swagger.codegen.options.JaxRSServerOptionsProvider;
|
import io.swagger.codegen.options.JaxRSServerOptionsProvider;
|
||||||
|
|
||||||
import mockit.Expectations;
|
import mockit.Expectations;
|
||||||
@ -11,7 +11,7 @@ import mockit.Tested;
|
|||||||
public class JaxRSServerOptionsTest extends JavaClientOptionsTest {
|
public class JaxRSServerOptionsTest extends JavaClientOptionsTest {
|
||||||
|
|
||||||
@Tested
|
@Tested
|
||||||
private JaxRSServerCodegen clientCodegen;
|
private JavaJerseyServerCodegen clientCodegen;
|
||||||
|
|
||||||
public JaxRSServerOptionsTest() {
|
public JaxRSServerOptionsTest() {
|
||||||
super(new JaxRSServerOptionsProvider());
|
super(new JaxRSServerOptionsProvider());
|
||||||
|
@ -2,7 +2,7 @@ package io.swagger.codegen.jaxrs;
|
|||||||
|
|
||||||
import io.swagger.codegen.CodegenModel;
|
import io.swagger.codegen.CodegenModel;
|
||||||
|
|
||||||
import io.swagger.codegen.languages.JaxRSServerCodegen;
|
import io.swagger.codegen.languages.JavaJerseyServerCodegen;
|
||||||
import io.swagger.models.Model;
|
import io.swagger.models.Model;
|
||||||
import io.swagger.models.ModelImpl;
|
import io.swagger.models.ModelImpl;
|
||||||
import io.swagger.models.properties.DateProperty;
|
import io.swagger.models.properties.DateProperty;
|
||||||
@ -26,7 +26,7 @@ public class JaxrsJava8ModelTest {
|
|||||||
.required("id")
|
.required("id")
|
||||||
.required("name");
|
.required("name");
|
||||||
|
|
||||||
final JaxRSServerCodegen codegen = new JaxRSServerCodegen();
|
final JavaJerseyServerCodegen codegen = new JavaJerseyServerCodegen();
|
||||||
codegen.setDateLibrary("java8");
|
codegen.setDateLibrary("java8");
|
||||||
codegen.processOpts();
|
codegen.processOpts();
|
||||||
final CodegenModel cm = codegen.fromModel("sample", model);
|
final CodegenModel cm = codegen.fromModel("sample", model);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package io.swagger.codegen.jaxrs;
|
package io.swagger.codegen.jaxrs;
|
||||||
|
|
||||||
import io.swagger.codegen.CodegenModel;
|
import io.swagger.codegen.CodegenModel;
|
||||||
import io.swagger.codegen.languages.JaxRSServerCodegen;
|
import io.swagger.codegen.languages.JavaJerseyServerCodegen;
|
||||||
import io.swagger.models.Model;
|
import io.swagger.models.Model;
|
||||||
import io.swagger.models.ModelImpl;
|
import io.swagger.models.ModelImpl;
|
||||||
import io.swagger.models.properties.DateProperty;
|
import io.swagger.models.properties.DateProperty;
|
||||||
@ -25,7 +25,7 @@ public class JaxrsJodaModelTest {
|
|||||||
.required("id")
|
.required("id")
|
||||||
.required("name");
|
.required("name");
|
||||||
|
|
||||||
final JaxRSServerCodegen codegen = new JaxRSServerCodegen();
|
final JavaJerseyServerCodegen codegen = new JavaJerseyServerCodegen();
|
||||||
codegen.setDateLibrary("joda");
|
codegen.setDateLibrary("joda");
|
||||||
codegen.processOpts();
|
codegen.processOpts();
|
||||||
final CodegenModel cm = codegen.fromModel("sample", model);
|
final CodegenModel cm = codegen.fromModel("sample", model);
|
||||||
|
@ -25,7 +25,9 @@ public class JaxRSServerOptionsProvider extends JavaOptionsProvider {
|
|||||||
|
|
||||||
ImmutableMap.Builder<String, String> builder = new ImmutableMap.Builder<String, String>();
|
ImmutableMap.Builder<String, String> builder = new ImmutableMap.Builder<String, String>();
|
||||||
builder.putAll(options)
|
builder.putAll(options)
|
||||||
.put(CodegenConstants.IMPL_FOLDER, IMPL_FOLDER_VALUE);
|
.put(CodegenConstants.IMPL_FOLDER, IMPL_FOLDER_VALUE)
|
||||||
|
//.put(JavaJaxRSJersey1ServerCodegen.DATE_LIBRARY, "joda") //java.lang.IllegalArgumentException: Multiple entries with same key: dateLibrary=joda and dateLibrary=joda
|
||||||
|
;
|
||||||
|
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,68 @@
|
|||||||
|
package io.swagger.api;
|
||||||
|
|
||||||
|
import io.swagger.model.Pet;
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import javax.ws.rs.*;
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
|
@Path("/v2")
|
||||||
|
public interface PetApi {
|
||||||
|
@PUT
|
||||||
|
@Path("/pet")
|
||||||
|
@Consumes({ "application/json", "application/xml" })
|
||||||
|
@Produces({ "application/json", "application/xml" })
|
||||||
|
public Response updatePet(Pet body);
|
||||||
|
@POST
|
||||||
|
@Path("/pet")
|
||||||
|
@Consumes({ "application/json", "application/xml" })
|
||||||
|
@Produces({ "application/json", "application/xml" })
|
||||||
|
public Response addPet(Pet body);
|
||||||
|
@GET
|
||||||
|
@Path("/pet/findByStatus")
|
||||||
|
|
||||||
|
@Produces({ "application/json", "application/xml" })
|
||||||
|
public Response findPetsByStatus(@QueryParam("status") List<String> status);
|
||||||
|
@GET
|
||||||
|
@Path("/pet/findByTags")
|
||||||
|
|
||||||
|
@Produces({ "application/json", "application/xml" })
|
||||||
|
public Response findPetsByTags(@QueryParam("tags") List<String> tags);
|
||||||
|
@GET
|
||||||
|
@Path("/pet/{petId}")
|
||||||
|
|
||||||
|
@Produces({ "application/json", "application/xml" })
|
||||||
|
public Response getPetById(@PathParam("petId") Long petId);
|
||||||
|
@POST
|
||||||
|
@Path("/pet/{petId}")
|
||||||
|
@Consumes({ "application/x-www-form-urlencoded" })
|
||||||
|
@Produces({ "application/json", "application/xml" })
|
||||||
|
public Response updatePetWithForm(@PathParam("petId") String petId,
|
||||||
|
@Multipart(value = "name", required = false) String name,
|
||||||
|
@Multipart(value = "status", required = false) String status);
|
||||||
|
@DELETE
|
||||||
|
@Path("/pet/{petId}")
|
||||||
|
|
||||||
|
@Produces({ "application/json", "application/xml" })
|
||||||
|
public Response deletePet(@PathParam("petId") Long petId,
|
||||||
|
@HeaderParam("api_key") String apiKey);
|
||||||
|
@POST
|
||||||
|
@Path("/pet/{petId}/uploadImage")
|
||||||
|
@Consumes({ "multipart/form-data" })
|
||||||
|
@Produces({ "application/json", "application/xml" })
|
||||||
|
public Response uploadFile(@PathParam("petId") Long petId,
|
||||||
|
@Multipart(value = "additionalMetadata", required = false) String additionalMetadata,
|
||||||
|
@Multipart(value = "file", required = false) InputStream fileInputStream,
|
||||||
|
@Multipart(value = "file" , required = false) Attachment fileDetail);
|
||||||
|
@GET
|
||||||
|
@Path("/pet/{petId}?testing_byte_array=true")
|
||||||
|
|
||||||
|
@Produces({ "application/json", "application/xml" })
|
||||||
|
public Response getPetByIdWithByteArray(@PathParam("petId") Long petId);
|
||||||
|
@POST
|
||||||
|
@Path("/pet?testing_byte_array=true")
|
||||||
|
@Consumes({ "application/json", "application/xml" })
|
||||||
|
@Produces({ "application/json", "application/xml" })
|
||||||
|
public Response addPetUsingByteArray(byte[] body);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,32 @@
|
|||||||
|
package io.swagger.api;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import io.swagger.model.Order;
|
||||||
|
|
||||||
|
import javax.ws.rs.*;
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
|
@Path("/v2")
|
||||||
|
public interface StoreApi {
|
||||||
|
@GET
|
||||||
|
@Path("/store/inventory")
|
||||||
|
|
||||||
|
@Produces({ "application/json", "application/xml" })
|
||||||
|
public Response getInventory();
|
||||||
|
@POST
|
||||||
|
@Path("/store/order")
|
||||||
|
|
||||||
|
@Produces({ "application/json", "application/xml" })
|
||||||
|
public Response placeOrder(Order body);
|
||||||
|
@GET
|
||||||
|
@Path("/store/order/{orderId}")
|
||||||
|
|
||||||
|
@Produces({ "application/json", "application/xml" })
|
||||||
|
public Response getOrderById(@PathParam("orderId") String orderId);
|
||||||
|
@DELETE
|
||||||
|
@Path("/store/order/{orderId}")
|
||||||
|
|
||||||
|
@Produces({ "application/json", "application/xml" })
|
||||||
|
public Response deleteOrder(@PathParam("orderId") String orderId);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,54 @@
|
|||||||
|
package io.swagger.api;
|
||||||
|
|
||||||
|
import io.swagger.model.User;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import javax.ws.rs.*;
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
|
@Path("/v2")
|
||||||
|
public interface UserApi {
|
||||||
|
@POST
|
||||||
|
@Path("/user")
|
||||||
|
|
||||||
|
@Produces({ "application/json", "application/xml" })
|
||||||
|
public Response createUser(User body);
|
||||||
|
@POST
|
||||||
|
@Path("/user/createWithArray")
|
||||||
|
|
||||||
|
@Produces({ "application/json", "application/xml" })
|
||||||
|
public Response createUsersWithArrayInput(List<User> body);
|
||||||
|
@POST
|
||||||
|
@Path("/user/createWithList")
|
||||||
|
|
||||||
|
@Produces({ "application/json", "application/xml" })
|
||||||
|
public Response createUsersWithListInput(List<User> body);
|
||||||
|
@GET
|
||||||
|
@Path("/user/login")
|
||||||
|
|
||||||
|
@Produces({ "application/json", "application/xml" })
|
||||||
|
public Response loginUser(@QueryParam("username") String username,
|
||||||
|
@QueryParam("password") String password);
|
||||||
|
@GET
|
||||||
|
@Path("/user/logout")
|
||||||
|
|
||||||
|
@Produces({ "application/json", "application/xml" })
|
||||||
|
public Response logoutUser();
|
||||||
|
@GET
|
||||||
|
@Path("/user/{username}")
|
||||||
|
|
||||||
|
@Produces({ "application/json", "application/xml" })
|
||||||
|
public Response getUserByName(@PathParam("username") String username);
|
||||||
|
@PUT
|
||||||
|
@Path("/user/{username}")
|
||||||
|
|
||||||
|
@Produces({ "application/json", "application/xml" })
|
||||||
|
public Response updateUser(@PathParam("username") String username,
|
||||||
|
User body);
|
||||||
|
@DELETE
|
||||||
|
@Path("/user/{username}")
|
||||||
|
|
||||||
|
@Produces({ "application/json", "application/xml" })
|
||||||
|
public Response deleteUser(@PathParam("username") String username);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,54 @@
|
|||||||
|
package io.swagger.model;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@XmlRootElement(name="Category")
|
||||||
|
public class Category {
|
||||||
|
|
||||||
|
|
||||||
|
private Long id = null;
|
||||||
|
|
||||||
|
private String name = null;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
**/
|
||||||
|
@JsonProperty("id")
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
**/
|
||||||
|
@JsonProperty("name")
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("class Category {\n");
|
||||||
|
|
||||||
|
sb.append(" id: ").append(id).append("\n");
|
||||||
|
sb.append(" name: ").append(name).append("\n");
|
||||||
|
sb.append("}\n");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,115 @@
|
|||||||
|
package io.swagger.model;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@XmlRootElement(name="Order")
|
||||||
|
public class Order {
|
||||||
|
|
||||||
|
|
||||||
|
private Long id = null;
|
||||||
|
|
||||||
|
private Long petId = null;
|
||||||
|
|
||||||
|
private Integer quantity = null;
|
||||||
|
|
||||||
|
private Date shipDate = null;
|
||||||
|
|
||||||
|
public enum StatusEnum {
|
||||||
|
placed, approved, delivered,
|
||||||
|
};
|
||||||
|
private StatusEnum status = null;
|
||||||
|
|
||||||
|
private Boolean complete = null;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
**/
|
||||||
|
@JsonProperty("id")
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
**/
|
||||||
|
@JsonProperty("petId")
|
||||||
|
public Long getPetId() {
|
||||||
|
return petId;
|
||||||
|
}
|
||||||
|
public void setPetId(Long petId) {
|
||||||
|
this.petId = petId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
**/
|
||||||
|
@JsonProperty("quantity")
|
||||||
|
public Integer getQuantity() {
|
||||||
|
return quantity;
|
||||||
|
}
|
||||||
|
public void setQuantity(Integer quantity) {
|
||||||
|
this.quantity = quantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
**/
|
||||||
|
@JsonProperty("shipDate")
|
||||||
|
public Date getShipDate() {
|
||||||
|
return shipDate;
|
||||||
|
}
|
||||||
|
public void setShipDate(Date shipDate) {
|
||||||
|
this.shipDate = shipDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Order Status
|
||||||
|
**/
|
||||||
|
@JsonProperty("status")
|
||||||
|
public StatusEnum getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
public void setStatus(StatusEnum status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
**/
|
||||||
|
@JsonProperty("complete")
|
||||||
|
public Boolean getComplete() {
|
||||||
|
return complete;
|
||||||
|
}
|
||||||
|
public void setComplete(Boolean complete) {
|
||||||
|
this.complete = complete;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("class Order {\n");
|
||||||
|
|
||||||
|
sb.append(" id: ").append(id).append("\n");
|
||||||
|
sb.append(" petId: ").append(petId).append("\n");
|
||||||
|
sb.append(" quantity: ").append(quantity).append("\n");
|
||||||
|
sb.append(" shipDate: ").append(shipDate).append("\n");
|
||||||
|
sb.append(" status: ").append(status).append("\n");
|
||||||
|
sb.append(" complete: ").append(complete).append("\n");
|
||||||
|
sb.append("}\n");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,117 @@
|
|||||||
|
package io.swagger.model;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import io.swagger.model.Category;
|
||||||
|
import io.swagger.model.Tag;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@XmlRootElement(name="Pet")
|
||||||
|
public class Pet {
|
||||||
|
|
||||||
|
|
||||||
|
private Long id = null;
|
||||||
|
|
||||||
|
private Category category = null;
|
||||||
|
|
||||||
|
private String name = null;
|
||||||
|
|
||||||
|
private List<String> photoUrls = new ArrayList<String>();
|
||||||
|
|
||||||
|
private List<Tag> tags = new ArrayList<Tag>();
|
||||||
|
|
||||||
|
public enum StatusEnum {
|
||||||
|
available, pending, sold,
|
||||||
|
};
|
||||||
|
private StatusEnum status = null;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
**/
|
||||||
|
@JsonProperty("id")
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
**/
|
||||||
|
@JsonProperty("category")
|
||||||
|
public Category getCategory() {
|
||||||
|
return category;
|
||||||
|
}
|
||||||
|
public void setCategory(Category category) {
|
||||||
|
this.category = category;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
**/
|
||||||
|
@JsonProperty("name")
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
**/
|
||||||
|
@JsonProperty("photoUrls")
|
||||||
|
public List<String> getPhotoUrls() {
|
||||||
|
return photoUrls;
|
||||||
|
}
|
||||||
|
public void setPhotoUrls(List<String> photoUrls) {
|
||||||
|
this.photoUrls = photoUrls;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
**/
|
||||||
|
@JsonProperty("tags")
|
||||||
|
public List<Tag> getTags() {
|
||||||
|
return tags;
|
||||||
|
}
|
||||||
|
public void setTags(List<Tag> tags) {
|
||||||
|
this.tags = tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pet status in the store
|
||||||
|
**/
|
||||||
|
@JsonProperty("status")
|
||||||
|
public StatusEnum getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
public void setStatus(StatusEnum status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("class Pet {\n");
|
||||||
|
|
||||||
|
sb.append(" id: ").append(id).append("\n");
|
||||||
|
sb.append(" category: ").append(category).append("\n");
|
||||||
|
sb.append(" name: ").append(name).append("\n");
|
||||||
|
sb.append(" photoUrls: ").append(photoUrls).append("\n");
|
||||||
|
sb.append(" tags: ").append(tags).append("\n");
|
||||||
|
sb.append(" status: ").append(status).append("\n");
|
||||||
|
sb.append("}\n");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
package io.swagger.model;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@XmlRootElement(name="Tag")
|
||||||
|
public class Tag {
|
||||||
|
|
||||||
|
|
||||||
|
private Long id = null;
|
||||||
|
|
||||||
|
private String name = null;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
**/
|
||||||
|
@JsonProperty("id")
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
**/
|
||||||
|
@JsonProperty("name")
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("class Tag {\n");
|
||||||
|
|
||||||
|
sb.append(" id: ").append(id).append("\n");
|
||||||
|
sb.append(" name: ").append(name).append("\n");
|
||||||
|
sb.append("}\n");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,139 @@
|
|||||||
|
package io.swagger.model;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@XmlRootElement(name="User")
|
||||||
|
public class User {
|
||||||
|
|
||||||
|
|
||||||
|
private Long id = null;
|
||||||
|
|
||||||
|
private String username = null;
|
||||||
|
|
||||||
|
private String firstName = null;
|
||||||
|
|
||||||
|
private String lastName = null;
|
||||||
|
|
||||||
|
private String email = null;
|
||||||
|
|
||||||
|
private String password = null;
|
||||||
|
|
||||||
|
private String phone = null;
|
||||||
|
|
||||||
|
private Integer userStatus = null;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
**/
|
||||||
|
@JsonProperty("id")
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
**/
|
||||||
|
@JsonProperty("username")
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
**/
|
||||||
|
@JsonProperty("firstName")
|
||||||
|
public String getFirstName() {
|
||||||
|
return firstName;
|
||||||
|
}
|
||||||
|
public void setFirstName(String firstName) {
|
||||||
|
this.firstName = firstName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
**/
|
||||||
|
@JsonProperty("lastName")
|
||||||
|
public String getLastName() {
|
||||||
|
return lastName;
|
||||||
|
}
|
||||||
|
public void setLastName(String lastName) {
|
||||||
|
this.lastName = lastName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
**/
|
||||||
|
@JsonProperty("email")
|
||||||
|
public String getEmail() {
|
||||||
|
return email;
|
||||||
|
}
|
||||||
|
public void setEmail(String email) {
|
||||||
|
this.email = email;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
**/
|
||||||
|
@JsonProperty("password")
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
public void setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
**/
|
||||||
|
@JsonProperty("phone")
|
||||||
|
public String getPhone() {
|
||||||
|
return phone;
|
||||||
|
}
|
||||||
|
public void setPhone(String phone) {
|
||||||
|
this.phone = phone;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User Status
|
||||||
|
**/
|
||||||
|
@JsonProperty("userStatus")
|
||||||
|
public Integer getUserStatus() {
|
||||||
|
return userStatus;
|
||||||
|
}
|
||||||
|
public void setUserStatus(Integer userStatus) {
|
||||||
|
this.userStatus = userStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("class User {\n");
|
||||||
|
|
||||||
|
sb.append(" id: ").append(id).append("\n");
|
||||||
|
sb.append(" username: ").append(username).append("\n");
|
||||||
|
sb.append(" firstName: ").append(firstName).append("\n");
|
||||||
|
sb.append(" lastName: ").append(lastName).append("\n");
|
||||||
|
sb.append(" email: ").append(email).append("\n");
|
||||||
|
sb.append(" password: ").append(password).append("\n");
|
||||||
|
sb.append(" phone: ").append(phone).append("\n");
|
||||||
|
sb.append(" userStatus: ").append(userStatus).append("\n");
|
||||||
|
sb.append("}\n");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user