From c0bea5ead9c48c52338cff30da682b535f216d81 Mon Sep 17 00:00:00 2001 From: Johannes Fiala Date: Mon, 23 Jan 2017 21:13:55 +0100 Subject: [PATCH 1/2] move beanvalidation code to AbstractJavaJAXRSServerCodegen.java #4091 --- .../AbstractJavaJAXRSServerCodegen.java | 22 +- .../languages/JavaCXFServerCodegen.java | 14 +- .../languages/JavaJAXRSSpecServerCodegen.java | 18 +- .../languages/JavaJerseyServerCodegen.java | 16 +- .../languages/JavaResteasyServerCodegen.java | 16 +- .../src/gen/java/io/swagger/api/PetApi.java | 151 +++---- .../src/gen/java/io/swagger/api/StoreApi.java | 93 ++-- .../src/gen/java/io/swagger/api/UserApi.java | 141 +++--- .../gen/java/io/swagger/model/Category.java | 1 + .../io/swagger/model/ModelApiResponse.java | 1 + .../src/gen/java/io/swagger/model/Order.java | 1 + .../src/gen/java/io/swagger/model/Pet.java | 3 + .../src/gen/java/io/swagger/model/Tag.java | 1 + .../src/gen/java/io/swagger/model/User.java | 1 + .../petstore/jaxrs-resteasy/default/pom.xml | 16 +- .../src/gen/java/io/swagger/api/StoreApi.java | 2 +- .../src/gen/java/io/swagger/api/PetApi.java | 312 ++++++------- .../src/gen/java/io/swagger/api/StoreApi.java | 146 +++---- .../src/gen/java/io/swagger/api/UserApi.java | 232 +++++----- .../gen/java/io/swagger/model/Category.java | 182 ++++---- .../io/swagger/model/ModelApiResponse.java | 220 +++++----- .../src/gen/java/io/swagger/model/Order.java | 398 ++++++++--------- .../src/gen/java/io/swagger/model/Pet.java | 410 ++++++++--------- .../src/gen/java/io/swagger/model/Tag.java | 182 ++++---- .../src/gen/java/io/swagger/model/User.java | 412 +++++++++--------- .../server/petstore/jaxrs-spec/swagger.json | 3 +- 26 files changed, 1488 insertions(+), 1506 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractJavaJAXRSServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractJavaJAXRSServerCodegen.java index 08410c47d44..3dc349edb70 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractJavaJAXRSServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractJavaJAXRSServerCodegen.java @@ -1,6 +1,7 @@ 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; @@ -10,7 +11,7 @@ import org.slf4j.LoggerFactory; import java.util.*; -public abstract class AbstractJavaJAXRSServerCodegen extends AbstractJavaCodegen { +public abstract class AbstractJavaJAXRSServerCodegen extends AbstractJavaCodegen implements BeanValidationFeatures { /** * Name of the sub-directory in "src/main/resource" where to find the * Mustache template for the JAX-RS Codegen. @@ -19,6 +20,9 @@ public abstract class AbstractJavaJAXRSServerCodegen extends AbstractJavaCodegen protected String implFolder = "src/main/java"; protected String testResourcesFolder = "src/test/resources"; protected String title = "Swagger Server"; + + protected boolean useBeanValidation = true; + static Logger LOGGER = LoggerFactory.getLogger(AbstractJavaJAXRSServerCodegen.class); public AbstractJavaJAXRSServerCodegen() @@ -40,6 +44,8 @@ public abstract class AbstractJavaJAXRSServerCodegen extends AbstractJavaCodegen cliOptions.add(new CliOption(CodegenConstants.IMPL_FOLDER, CodegenConstants.IMPL_FOLDER_DESC)); cliOptions.add(new CliOption("title", "a title describing the application")); + cliOptions.add(CliOption.newBoolean(USE_BEANVALIDATION, "Use BeanValidation API annotations")); + } @@ -60,6 +66,15 @@ public abstract class AbstractJavaJAXRSServerCodegen extends AbstractJavaCodegen if (additionalProperties.containsKey(CodegenConstants.IMPL_FOLDER)) { implFolder = (String) additionalProperties.get(CodegenConstants.IMPL_FOLDER); } + + if (additionalProperties.containsKey(USE_BEANVALIDATION)) { + this.setUseBeanValidation(convertPropertyToBoolean(USE_BEANVALIDATION)); + } + + if (useBeanValidation) { + writePropertyBack(USE_BEANVALIDATION, useBeanValidation); + } + } @Override @@ -204,4 +219,9 @@ public abstract class AbstractJavaJAXRSServerCodegen extends AbstractJavaCodegen private String implFileFolder(String output) { return outputFolder + "/" + output + "/" + apiPackage().replace('.', '/'); } + + public void setUseBeanValidation(boolean useBeanValidation) { + this.useBeanValidation = useBeanValidation; + } + } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaCXFServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaCXFServerCodegen.java index 6404f74e3a0..9df051198b4 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaCXFServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaCXFServerCodegen.java @@ -27,8 +27,6 @@ public class JavaCXFServerCodegen extends AbstractJavaJAXRSServerCodegen protected boolean addConsumesProducesJson = true; protected boolean useJaxbAnnotations = true; - - protected boolean useBeanValidation = false; protected boolean generateSpringApplication = false; @@ -41,7 +39,7 @@ public class JavaCXFServerCodegen extends AbstractJavaJAXRSServerCodegen protected boolean useWadlFeature = false; protected boolean useMultipartFeature = false; - + protected boolean useBeanValidationFeature = false; protected boolean generateSpringBootApplication= false; @@ -84,7 +82,6 @@ public class JavaCXFServerCodegen extends AbstractJavaJAXRSServerCodegen cliOptions.add(CliOption.newBoolean(USE_JAXB_ANNOTATIONS, "Use JAXB annotations for XML")); - cliOptions.add(CliOption.newBoolean(USE_BEANVALIDATION, "Use BeanValidation API annotations")); cliOptions.add(CliOption.newBoolean(GENERATE_SPRING_APPLICATION, "Generate Spring application")); cliOptions.add(CliOption.newBoolean(USE_SPRING_ANNOTATION_CONFIG, "Use Spring Annotation Config")); @@ -121,11 +118,6 @@ public class JavaCXFServerCodegen extends AbstractJavaJAXRSServerCodegen this.setUseJaxbAnnotations(useJaxbAnnotationsProp); } - if (additionalProperties.containsKey(USE_BEANVALIDATION)) { - boolean useBeanValidationProp = convertPropertyToBooleanAndWriteBack(USE_BEANVALIDATION); - this.setUseBeanValidation(useBeanValidationProp); - } - if (additionalProperties.containsKey(ADD_CONSUMES_PRODUCES_JSON)) { this.setAddConsumesProducesJson(convertPropertyToBooleanAndWriteBack(ADD_CONSUMES_PRODUCES_JSON)); } @@ -224,10 +216,6 @@ public class JavaCXFServerCodegen extends AbstractJavaJAXRSServerCodegen return "Generates a Java JAXRS Server application based on Apache CXF framework."; } - public void setUseBeanValidation(boolean useBeanValidation) { - this.useBeanValidation = useBeanValidation; - } - public void setGenerateSpringApplication(boolean generateSpringApplication) { this.generateSpringApplication = generateSpringApplication; } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaJAXRSSpecServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaJAXRSSpecServerCodegen.java index 74c2ccb0218..6c91e175db5 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaJAXRSSpecServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaJAXRSSpecServerCodegen.java @@ -21,9 +21,8 @@ import io.swagger.models.Swagger; import io.swagger.models.properties.Property; import io.swagger.util.Json; -public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen implements BeanValidationFeatures +public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen { - protected boolean useBeanValidation = true; public JavaJAXRSSpecServerCodegen() { @@ -71,8 +70,6 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen i library.setEnum(supportedLibraries); cliOptions.add(library); - - cliOptions.add(CliOption.newBoolean(USE_BEANVALIDATION, "Use BeanValidation API annotations")); } @Override @@ -80,14 +77,6 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen i { super.processOpts(); - if (additionalProperties.containsKey(USE_BEANVALIDATION)) { - this.setUseBeanValidation(convertPropertyToBoolean(USE_BEANVALIDATION)); - } - - if (useBeanValidation) { - writePropertyBack(USE_BEANVALIDATION, useBeanValidation); - } - supportingFiles.clear(); // Don't need extra files provided by AbstractJAX-RS & Java Codegen writeOptional(outputFolder, new SupportingFile("pom.mustache", "", "pom.xml")); @@ -159,9 +148,4 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen i { return "Generates a Java JAXRS Server according to JAXRS 2.0 specification."; } - - public void setUseBeanValidation(boolean useBeanValidation) { - this.useBeanValidation = useBeanValidation; - } - } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaJerseyServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaJerseyServerCodegen.java index 99d7f70ee7c..8cbd3a485d5 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaJerseyServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaJerseyServerCodegen.java @@ -9,11 +9,10 @@ import java.util.*; import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; -public class JavaJerseyServerCodegen extends AbstractJavaJAXRSServerCodegen implements BeanValidationFeatures { +public class JavaJerseyServerCodegen extends AbstractJavaJAXRSServerCodegen { protected static final String LIBRARY_JERSEY1 = "jersey1"; protected static final String LIBRARY_JERSEY2 = "jersey2"; - protected boolean useBeanValidation = true; /** * Default library template to use. (Default:{@value #DEFAULT_LIBRARY}) @@ -47,7 +46,6 @@ public class JavaJerseyServerCodegen extends AbstractJavaJAXRSServerCodegen impl cliOptions.add(library); cliOptions.add(CliOption.newBoolean(SUPPORT_JAVA6, "Whether to support Java6 with the Jersey1/2 library.")); - cliOptions.add(CliOption.newBoolean(USE_BEANVALIDATION, "Use BeanValidation API annotations")); } @Override @@ -88,14 +86,6 @@ public class JavaJerseyServerCodegen extends AbstractJavaJAXRSServerCodegen impl setLibrary(DEFAULT_LIBRARY); } - if (additionalProperties.containsKey(USE_BEANVALIDATION)) { - this.setUseBeanValidation(convertPropertyToBoolean(USE_BEANVALIDATION)); - } - - if (useBeanValidation) { - writePropertyBack(USE_BEANVALIDATION, useBeanValidation); - } - if ( additionalProperties.containsKey(CodegenConstants.IMPL_FOLDER)) { implFolder = (String) additionalProperties.get(CodegenConstants.IMPL_FOLDER); } @@ -172,8 +162,4 @@ public class JavaJerseyServerCodegen extends AbstractJavaJAXRSServerCodegen impl co.baseName = basePath; } - public void setUseBeanValidation(boolean useBeanValidation) { - this.useBeanValidation = useBeanValidation; - } - } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaResteasyServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaResteasyServerCodegen.java index dffa0cffa36..7627884c407 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaResteasyServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaResteasyServerCodegen.java @@ -10,9 +10,8 @@ import org.apache.commons.lang3.StringUtils; import java.io.File; import java.util.*; -public class JavaResteasyServerCodegen extends AbstractJavaJAXRSServerCodegen implements JbossFeature, BeanValidationFeatures { +public class JavaResteasyServerCodegen extends AbstractJavaJAXRSServerCodegen implements JbossFeature { - protected boolean useBeanValidation = true; protected boolean generateJbossDeploymentDescriptor = true; public JavaResteasyServerCodegen() { @@ -37,7 +36,6 @@ public class JavaResteasyServerCodegen extends AbstractJavaJAXRSServerCodegen im embeddedTemplateDir = templateDir = "JavaJaxRS" + File.separator + "resteasy"; - cliOptions.add(CliOption.newBoolean(USE_BEANVALIDATION, "Use BeanValidation API annotations")); cliOptions.add( CliOption.newBoolean(GENERATE_JBOSS_DEPLOYMENT_DESCRIPTOR, "Generate Jboss Deployment Descriptor")); } @@ -62,14 +60,6 @@ public class JavaResteasyServerCodegen extends AbstractJavaJAXRSServerCodegen im this.setGenerateJbossDeploymentDescriptor(generateJbossDeploymentDescriptorProp); } - if (additionalProperties.containsKey(USE_BEANVALIDATION)) { - this.setUseBeanValidation(convertPropertyToBoolean(USE_BEANVALIDATION)); - } - - if (useBeanValidation) { - writePropertyBack(USE_BEANVALIDATION, useBeanValidation); - } - writeOptional(outputFolder, new SupportingFile("pom.mustache", "", "pom.xml")); writeOptional(outputFolder, new SupportingFile("gradle.mustache", "", "build.gradle")); writeOptional(outputFolder, new SupportingFile("settingsGradle.mustache", "", "settings.gradle")); @@ -226,10 +216,6 @@ public class JavaResteasyServerCodegen extends AbstractJavaJAXRSServerCodegen im return objs; } - public void setUseBeanValidation(boolean useBeanValidation) { - this.useBeanValidation = useBeanValidation; - } - public void setGenerateJbossDeploymentDescriptor(boolean generateJbossDeploymentDescriptor) { this.generateJbossDeploymentDescriptor = generateJbossDeploymentDescriptor; } diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/PetApi.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/PetApi.java index edd25fbd563..64c0315ac8d 100644 --- a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/PetApi.java @@ -1,75 +1,76 @@ -package io.swagger.api; - -import java.io.File; -import io.swagger.model.ModelApiResponse; -import io.swagger.model.Pet; - -import java.io.InputStream; -import java.io.OutputStream; -import java.util.List; -import java.util.Map; -import javax.ws.rs.*; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.MediaType; -import org.apache.cxf.jaxrs.ext.multipart.*; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; - -@Path("/") -@Api(value = "/", description = "") -public interface PetApi { - - @POST - @Path("/pet") - @Consumes({ "application/json", "application/xml" }) - @Produces({ "application/xml", "application/json" }) - @ApiOperation(value = "Add a new pet to the store", tags={ "pet", }) - public void addPet(Pet body); - - @DELETE - @Path("/pet/{petId}") - @Produces({ "application/xml", "application/json" }) - @ApiOperation(value = "Deletes a pet", tags={ "pet", }) - public void deletePet(@PathParam("petId") Long petId, @HeaderParam("api_key") String apiKey); - - @GET - @Path("/pet/findByStatus") - @Produces({ "application/xml", "application/json" }) - @ApiOperation(value = "Finds Pets by status", tags={ "pet", }) - public List findPetsByStatus(@QueryParam("status")List status); - - @GET - @Path("/pet/findByTags") - @Produces({ "application/xml", "application/json" }) - @ApiOperation(value = "Finds Pets by tags", tags={ "pet", }) - public List findPetsByTags(@QueryParam("tags")List tags); - - @GET - @Path("/pet/{petId}") - @Produces({ "application/xml", "application/json" }) - @ApiOperation(value = "Find pet by ID", tags={ "pet", }) - public Pet getPetById(@PathParam("petId") Long petId); - - @PUT - @Path("/pet") - @Consumes({ "application/json", "application/xml" }) - @Produces({ "application/xml", "application/json" }) - @ApiOperation(value = "Update an existing pet", tags={ "pet", }) - public void updatePet(Pet body); - - @POST - @Path("/pet/{petId}") - @Consumes({ "application/x-www-form-urlencoded" }) - @Produces({ "application/xml", "application/json" }) - @ApiOperation(value = "Updates a pet in the store with form data", tags={ "pet", }) - public void updatePetWithForm(@PathParam("petId") Long petId, @Multipart(value = "name", required = false) String name, @Multipart(value = "status", required = false) String status); - - @POST - @Path("/pet/{petId}/uploadImage") - @Consumes({ "multipart/form-data" }) - @Produces({ "application/json" }) - @ApiOperation(value = "uploads an image", tags={ "pet" }) - public ModelApiResponse uploadFile(@PathParam("petId") Long petId, @Multipart(value = "additionalMetadata", required = false) String additionalMetadata, @Multipart(value = "file" , required = false) Attachment fileDetail); -} - +package io.swagger.api; + +import java.io.File; +import io.swagger.model.ModelApiResponse; +import io.swagger.model.Pet; + +import java.io.InputStream; +import java.io.OutputStream; +import java.util.List; +import java.util.Map; +import javax.ws.rs.*; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.MediaType; +import org.apache.cxf.jaxrs.ext.multipart.*; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import javax.validation.constraints.*; + +@Path("/") +@Api(value = "/", description = "") +public interface PetApi { + + @POST + @Path("/pet") + @Consumes({ "application/json", "application/xml" }) + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Add a new pet to the store", tags={ "pet", }) + public void addPet(Pet body); + + @DELETE + @Path("/pet/{petId}") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Deletes a pet", tags={ "pet", }) + public void deletePet(@PathParam("petId") Long petId, @HeaderParam("api_key") String apiKey); + + @GET + @Path("/pet/findByStatus") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Finds Pets by status", tags={ "pet", }) + public List findPetsByStatus(@QueryParam("status") @NotNull List status); + + @GET + @Path("/pet/findByTags") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Finds Pets by tags", tags={ "pet", }) + public List findPetsByTags(@QueryParam("tags") @NotNull List tags); + + @GET + @Path("/pet/{petId}") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Find pet by ID", tags={ "pet", }) + public Pet getPetById(@PathParam("petId") Long petId); + + @PUT + @Path("/pet") + @Consumes({ "application/json", "application/xml" }) + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Update an existing pet", tags={ "pet", }) + public void updatePet(Pet body); + + @POST + @Path("/pet/{petId}") + @Consumes({ "application/x-www-form-urlencoded" }) + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Updates a pet in the store with form data", tags={ "pet", }) + public void updatePetWithForm(@PathParam("petId") Long petId, @Multipart(value = "name", required = false) String name, @Multipart(value = "status", required = false) String status); + + @POST + @Path("/pet/{petId}/uploadImage") + @Consumes({ "multipart/form-data" }) + @Produces({ "application/json" }) + @ApiOperation(value = "uploads an image", tags={ "pet" }) + public ModelApiResponse uploadFile(@PathParam("petId") Long petId, @Multipart(value = "additionalMetadata", required = false) String additionalMetadata, @Multipart(value = "file" , required = false) Attachment fileDetail); +} + diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/StoreApi.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/StoreApi.java index 50f1b618273..2ed25e0a0d0 100644 --- a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/StoreApi.java @@ -1,46 +1,47 @@ -package io.swagger.api; - -import java.util.Map; -import io.swagger.model.Order; - -import java.io.InputStream; -import java.io.OutputStream; -import java.util.List; -import java.util.Map; -import javax.ws.rs.*; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.MediaType; -import org.apache.cxf.jaxrs.ext.multipart.*; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; - -@Path("/") -@Api(value = "/", description = "") -public interface StoreApi { - - @DELETE - @Path("/store/order/{orderId}") - @Produces({ "application/xml", "application/json" }) - @ApiOperation(value = "Delete purchase order by ID", tags={ "store", }) - public void deleteOrder(@PathParam("orderId") String orderId); - - @GET - @Path("/store/inventory") - @Produces({ "application/json" }) - @ApiOperation(value = "Returns pet inventories by status", tags={ "store", }) - public Map getInventory(); - - @GET - @Path("/store/order/{orderId}") - @Produces({ "application/xml", "application/json" }) - @ApiOperation(value = "Find purchase order by ID", tags={ "store", }) - public Order getOrderById(@PathParam("orderId") Long orderId); - - @POST - @Path("/store/order") - @Produces({ "application/xml", "application/json" }) - @ApiOperation(value = "Place an order for a pet", tags={ "store" }) - public Order placeOrder(Order body); -} - +package io.swagger.api; + +import java.util.Map; +import io.swagger.model.Order; + +import java.io.InputStream; +import java.io.OutputStream; +import java.util.List; +import java.util.Map; +import javax.ws.rs.*; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.MediaType; +import org.apache.cxf.jaxrs.ext.multipart.*; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import javax.validation.constraints.*; + +@Path("/") +@Api(value = "/", description = "") +public interface StoreApi { + + @DELETE + @Path("/store/order/{orderId}") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Delete purchase order by ID", tags={ "store", }) + public void deleteOrder(@PathParam("orderId") String orderId); + + @GET + @Path("/store/inventory") + @Produces({ "application/json" }) + @ApiOperation(value = "Returns pet inventories by status", tags={ "store", }) + public Map getInventory(); + + @GET + @Path("/store/order/{orderId}") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Find purchase order by ID", tags={ "store", }) + public Order getOrderById(@PathParam("orderId") Long orderId); + + @POST + @Path("/store/order") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Place an order for a pet", tags={ "store" }) + public Order placeOrder(Order body); +} + diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/UserApi.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/UserApi.java index 20347b8650c..81f0f470fe1 100644 --- a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/UserApi.java +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/UserApi.java @@ -1,70 +1,71 @@ -package io.swagger.api; - -import java.util.List; -import io.swagger.model.User; - -import java.io.InputStream; -import java.io.OutputStream; -import java.util.List; -import java.util.Map; -import javax.ws.rs.*; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.MediaType; -import org.apache.cxf.jaxrs.ext.multipart.*; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; - -@Path("/") -@Api(value = "/", description = "") -public interface UserApi { - - @POST - @Path("/user") - @Produces({ "application/xml", "application/json" }) - @ApiOperation(value = "Create user", tags={ "user", }) - public void createUser(User body); - - @POST - @Path("/user/createWithArray") - @Produces({ "application/xml", "application/json" }) - @ApiOperation(value = "Creates list of users with given input array", tags={ "user", }) - public void createUsersWithArrayInput(List body); - - @POST - @Path("/user/createWithList") - @Produces({ "application/xml", "application/json" }) - @ApiOperation(value = "Creates list of users with given input array", tags={ "user", }) - public void createUsersWithListInput(List body); - - @DELETE - @Path("/user/{username}") - @Produces({ "application/xml", "application/json" }) - @ApiOperation(value = "Delete user", tags={ "user", }) - public void deleteUser(@PathParam("username") String username); - - @GET - @Path("/user/{username}") - @Produces({ "application/xml", "application/json" }) - @ApiOperation(value = "Get user by user name", tags={ "user", }) - public User getUserByName(@PathParam("username") String username); - - @GET - @Path("/user/login") - @Produces({ "application/xml", "application/json" }) - @ApiOperation(value = "Logs user into the system", tags={ "user", }) - public String loginUser(@QueryParam("username")String username, @QueryParam("password")String password); - - @GET - @Path("/user/logout") - @Produces({ "application/xml", "application/json" }) - @ApiOperation(value = "Logs out current logged in user session", tags={ "user", }) - public void logoutUser(); - - @PUT - @Path("/user/{username}") - @Produces({ "application/xml", "application/json" }) - @ApiOperation(value = "Updated user", tags={ "user" }) - public void updateUser(@PathParam("username") String username, User body); -} - +package io.swagger.api; + +import java.util.List; +import io.swagger.model.User; + +import java.io.InputStream; +import java.io.OutputStream; +import java.util.List; +import java.util.Map; +import javax.ws.rs.*; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.MediaType; +import org.apache.cxf.jaxrs.ext.multipart.*; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import javax.validation.constraints.*; + +@Path("/") +@Api(value = "/", description = "") +public interface UserApi { + + @POST + @Path("/user") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Create user", tags={ "user", }) + public void createUser(User body); + + @POST + @Path("/user/createWithArray") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Creates list of users with given input array", tags={ "user", }) + public void createUsersWithArrayInput(List body); + + @POST + @Path("/user/createWithList") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Creates list of users with given input array", tags={ "user", }) + public void createUsersWithListInput(List body); + + @DELETE + @Path("/user/{username}") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Delete user", tags={ "user", }) + public void deleteUser(@PathParam("username") String username); + + @GET + @Path("/user/{username}") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Get user by user name", tags={ "user", }) + public User getUserByName(@PathParam("username") String username); + + @GET + @Path("/user/login") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Logs user into the system", tags={ "user", }) + public String loginUser(@QueryParam("username") @NotNull String username, @QueryParam("password") @NotNull String password); + + @GET + @Path("/user/logout") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Logs out current logged in user session", tags={ "user", }) + public void logoutUser(); + + @PUT + @Path("/user/{username}") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Updated user", tags={ "user" }) + public void updateUser(@PathParam("username") String username, User body); +} + diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Category.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Category.java index 591a6e22a69..5bb5125cdf2 100644 --- a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Category.java +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Category.java @@ -1,6 +1,7 @@ package io.swagger.model; import io.swagger.annotations.ApiModel; +import javax.validation.constraints.*; import io.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlElement; diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/ModelApiResponse.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/ModelApiResponse.java index f3c6f56cfc4..ef86bf6fcac 100644 --- a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/ModelApiResponse.java +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/ModelApiResponse.java @@ -1,6 +1,7 @@ package io.swagger.model; import io.swagger.annotations.ApiModel; +import javax.validation.constraints.*; import io.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlElement; diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Order.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Order.java index af6f5e0e38e..af7e097fef9 100644 --- a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Order.java +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Order.java @@ -1,6 +1,7 @@ package io.swagger.model; import io.swagger.annotations.ApiModel; +import javax.validation.constraints.*; import io.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlElement; diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Pet.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Pet.java index 0cfc0a30ee0..41e2469ef35 100644 --- a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Pet.java +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Pet.java @@ -5,6 +5,7 @@ import io.swagger.model.Category; import io.swagger.model.Tag; import java.util.ArrayList; import java.util.List; +import javax.validation.constraints.*; import io.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlElement; @@ -88,6 +89,7 @@ public enum StatusEnum { * Get name * @return name **/ + @NotNull public String getName() { return name; } @@ -98,6 +100,7 @@ public enum StatusEnum { * Get photoUrls * @return photoUrls **/ + @NotNull public List getPhotoUrls() { return photoUrls; } diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Tag.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Tag.java index 4eb99ad2fc1..9b214f241b7 100644 --- a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Tag.java +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Tag.java @@ -1,6 +1,7 @@ package io.swagger.model; import io.swagger.annotations.ApiModel; +import javax.validation.constraints.*; import io.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlElement; diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/User.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/User.java index 005d9aa8c74..4b2ae67fb37 100644 --- a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/User.java +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/User.java @@ -1,6 +1,7 @@ package io.swagger.model; import io.swagger.annotations.ApiModel; +import javax.validation.constraints.*; import io.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlElement; diff --git a/samples/server/petstore/jaxrs-resteasy/default/pom.xml b/samples/server/petstore/jaxrs-resteasy/default/pom.xml index 0a25c0159b3..fb583c63f23 100644 --- a/samples/server/petstore/jaxrs-resteasy/default/pom.xml +++ b/samples/server/petstore/jaxrs-resteasy/default/pom.xml @@ -108,10 +108,10 @@ 2.7 - io.swagger - swagger-jaxrs - ${swagger-core-version} - + io.swagger + swagger-jaxrs + ${swagger-core-version} + junit junit @@ -138,6 +138,14 @@ + + + javax.validation + validation-api + 1.1.0.Final + provided + + diff --git a/samples/server/petstore/jaxrs-resteasy/default/src/gen/java/io/swagger/api/StoreApi.java b/samples/server/petstore/jaxrs-resteasy/default/src/gen/java/io/swagger/api/StoreApi.java index d0d5bf43537..01600f2b0d8 100644 --- a/samples/server/petstore/jaxrs-resteasy/default/src/gen/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/jaxrs-resteasy/default/src/gen/java/io/swagger/api/StoreApi.java @@ -29,7 +29,7 @@ public class StoreApi { @Path("/order/{orderId}") @Produces({ "application/xml", "application/json" }) - public Response deleteOrder( @Min(1) @PathParam("orderId") String orderId,@Context SecurityContext securityContext) + public Response deleteOrder( @PathParam("orderId") String orderId,@Context SecurityContext securityContext) throws NotFoundException { return delegate.deleteOrder(orderId,securityContext); } diff --git a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/api/PetApi.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/api/PetApi.java index bbe6add41d6..f19581bb7e6 100644 --- a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/api/PetApi.java @@ -1,156 +1,156 @@ -package io.swagger.api; - -import java.io.File; -import io.swagger.model.ModelApiResponse; -import io.swagger.model.Pet; - -import javax.ws.rs.*; -import javax.ws.rs.core.Response; - -import io.swagger.annotations.*; - -import java.util.List; -import javax.validation.constraints.*; - -@Path("/pet") - -@Api(description = "the pet API") - - - - -public class PetApi { - - @POST - - @Consumes({ "application/json", "application/xml" }) - @Produces({ "application/xml", "application/json" }) - @ApiOperation(value = "Add a new pet to the store", 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 = 405, message = "Invalid input", response = void.class) }) - public Response addPet(Pet body) { - return Response.ok().entity("magic!").build(); - } - - @DELETE - @Path("/{petId}") - - @Produces({ "application/xml", "application/json" }) - @ApiOperation(value = "Deletes a pet", 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 = 400, message = "Invalid pet value", response = void.class) }) - public Response deletePet(@PathParam("petId") @ApiParam("Pet id to delete") Long petId,@HeaderParam("api_key") String apiKey) { - return Response.ok().entity("magic!").build(); - } - - @GET - @Path("/findByStatus") - - @Produces({ "application/xml", "application/json" }) - @ApiOperation(value = "Finds Pets by status", notes = "Multiple status values can be provided with comma separated strings", response = Pet.class, responseContainer = "List", 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 = Pet.class, responseContainer = "List"), - @ApiResponse(code = 400, message = "Invalid status value", response = Pet.class, responseContainer = "List") }) - public Response findPetsByStatus(@QueryParam("status") @NotNull List status) { - return Response.ok().entity("magic!").build(); - } - - @GET - @Path("/findByTags") - - @Produces({ "application/xml", "application/json" }) - @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 = { - @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 = Pet.class, responseContainer = "List"), - @ApiResponse(code = 400, message = "Invalid tag value", response = Pet.class, responseContainer = "List") }) - public Response findPetsByTags(@QueryParam("tags") @NotNull List tags) { - return Response.ok().entity("magic!").build(); - } - - @GET - @Path("/{petId}") - - @Produces({ "application/xml", "application/json" }) - @ApiOperation(value = "Find pet by ID", notes = "Returns a single pet", response = Pet.class, authorizations = { - @Authorization(value = "api_key") - }, tags={ "pet", }) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation", response = Pet.class), - @ApiResponse(code = 400, message = "Invalid ID supplied", response = Pet.class), - @ApiResponse(code = 404, message = "Pet not found", response = Pet.class) }) - public Response getPetById(@PathParam("petId") @ApiParam("ID of pet to return") Long petId) { - return Response.ok().entity("magic!").build(); - } - - @PUT - - @Consumes({ "application/json", "application/xml" }) - @Produces({ "application/xml", "application/json" }) - @ApiOperation(value = "Update an existing pet", 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 = 400, message = "Invalid ID supplied", response = void.class), - @ApiResponse(code = 404, message = "Pet not found", response = void.class), - @ApiResponse(code = 405, message = "Validation exception", response = void.class) }) - public Response updatePet(Pet body) { - return Response.ok().entity("magic!").build(); - } - - @POST - @Path("/{petId}") - @Consumes({ "application/x-www-form-urlencoded" }) - @Produces({ "application/xml", "application/json" }) - @ApiOperation(value = "Updates a pet in the store with form data", 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 = 405, message = "Invalid input", response = void.class) }) - public Response updatePetWithForm(@PathParam("petId") @ApiParam("ID of pet that needs to be updated") Long petId,@FormParam(value = "name") String name,@FormParam(value = "status") String status) { - return Response.ok().entity("magic!").build(); - } - - @POST - @Path("/{petId}/uploadImage") - @Consumes({ "multipart/form-data" }) - @Produces({ "application/json" }) - @ApiOperation(value = "uploads an image", notes = "", response = ModelApiResponse.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) }) - public Response uploadFile(@PathParam("petId") @ApiParam("ID of pet to update") Long petId,@FormParam(value = "additionalMetadata") String additionalMetadata, @FormParam(value = "file") InputStream fileInputStream, - @FormParam(value = "file") Attachment fileDetail) { - return Response.ok().entity("magic!").build(); - } -} - +package io.swagger.api; + +import java.io.File; +import io.swagger.model.ModelApiResponse; +import io.swagger.model.Pet; + +import javax.ws.rs.*; +import javax.ws.rs.core.Response; + +import io.swagger.annotations.*; + +import java.util.List; +import javax.validation.constraints.*; + +@Path("/pet") + +@Api(description = "the pet API") + + + + +public class PetApi { + + @POST + + @Consumes({ "application/json", "application/xml" }) + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Add a new pet to the store", 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 = 405, message = "Invalid input", response = void.class) }) + public Response addPet(Pet body) { + return Response.ok().entity("magic!").build(); + } + + @DELETE + @Path("/{petId}") + + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Deletes a pet", 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 = 400, message = "Invalid pet value", response = void.class) }) + public Response deletePet(@PathParam("petId") @ApiParam("Pet id to delete") Long petId,@HeaderParam("api_key") String apiKey) { + return Response.ok().entity("magic!").build(); + } + + @GET + @Path("/findByStatus") + + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Finds Pets by status", notes = "Multiple status values can be provided with comma separated strings", response = Pet.class, responseContainer = "List", 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 = Pet.class, responseContainer = "List"), + @ApiResponse(code = 400, message = "Invalid status value", response = Pet.class, responseContainer = "List") }) + public Response findPetsByStatus(@QueryParam("status") @NotNull List status) { + return Response.ok().entity("magic!").build(); + } + + @GET + @Path("/findByTags") + + @Produces({ "application/xml", "application/json" }) + @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 = { + @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 = Pet.class, responseContainer = "List"), + @ApiResponse(code = 400, message = "Invalid tag value", response = Pet.class, responseContainer = "List") }) + public Response findPetsByTags(@QueryParam("tags") @NotNull List tags) { + return Response.ok().entity("magic!").build(); + } + + @GET + @Path("/{petId}") + + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Find pet by ID", notes = "Returns a single pet", response = Pet.class, authorizations = { + @Authorization(value = "api_key") + }, tags={ "pet", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Pet.class), + @ApiResponse(code = 400, message = "Invalid ID supplied", response = Pet.class), + @ApiResponse(code = 404, message = "Pet not found", response = Pet.class) }) + public Response getPetById(@PathParam("petId") @ApiParam("ID of pet to return") Long petId) { + return Response.ok().entity("magic!").build(); + } + + @PUT + + @Consumes({ "application/json", "application/xml" }) + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Update an existing pet", 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 = 400, message = "Invalid ID supplied", response = void.class), + @ApiResponse(code = 404, message = "Pet not found", response = void.class), + @ApiResponse(code = 405, message = "Validation exception", response = void.class) }) + public Response updatePet(Pet body) { + return Response.ok().entity("magic!").build(); + } + + @POST + @Path("/{petId}") + @Consumes({ "application/x-www-form-urlencoded" }) + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Updates a pet in the store with form data", 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 = 405, message = "Invalid input", response = void.class) }) + public Response updatePetWithForm(@PathParam("petId") @ApiParam("ID of pet that needs to be updated") Long petId,@FormParam(value = "name") String name,@FormParam(value = "status") String status) { + return Response.ok().entity("magic!").build(); + } + + @POST + @Path("/{petId}/uploadImage") + @Consumes({ "multipart/form-data" }) + @Produces({ "application/json" }) + @ApiOperation(value = "uploads an image", notes = "", response = ModelApiResponse.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) }) + public Response uploadFile(@PathParam("petId") @ApiParam("ID of pet to update") Long petId,@FormParam(value = "additionalMetadata") String additionalMetadata, @FormParam(value = "file") InputStream fileInputStream, + @FormParam(value = "file") Attachment fileDetail) { + return Response.ok().entity("magic!").build(); + } +} + diff --git a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/api/StoreApi.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/api/StoreApi.java index e8ff3d49e80..0b0522fad8e 100644 --- a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/api/StoreApi.java @@ -1,73 +1,73 @@ -package io.swagger.api; - -import java.util.Map; -import io.swagger.model.Order; - -import javax.ws.rs.*; -import javax.ws.rs.core.Response; - -import io.swagger.annotations.*; - -import java.util.List; -import javax.validation.constraints.*; - -@Path("/store") - -@Api(description = "the store API") - - - - -public class StoreApi { - - @DELETE - @Path("/order/{orderId}") - - @Produces({ "application/xml", "application/json" }) - @ApiOperation(value = "Delete purchase order by ID", notes = "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", response = void.class, tags={ "store", }) - @ApiResponses(value = { - @ApiResponse(code = 400, message = "Invalid ID supplied", response = void.class), - @ApiResponse(code = 404, message = "Order not found", response = void.class) }) - public Response deleteOrder(@PathParam("orderId") @Min(1) @ApiParam("ID of the order that needs to be deleted") String orderId) { - return Response.ok().entity("magic!").build(); - } - - @GET - @Path("/inventory") - - @Produces({ "application/json" }) - @ApiOperation(value = "Returns pet inventories by status", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map", authorizations = { - @Authorization(value = "api_key") - }, tags={ "store", }) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation", response = Integer.class, responseContainer = "Map") }) - public Response getInventory() { - return Response.ok().entity("magic!").build(); - } - - @GET - @Path("/order/{orderId}") - - @Produces({ "application/xml", "application/json" }) - @ApiOperation(value = "Find purchase order by ID", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation", response = Order.class), - @ApiResponse(code = 400, message = "Invalid ID supplied", response = Order.class), - @ApiResponse(code = 404, message = "Order not found", response = Order.class) }) - public Response getOrderById(@PathParam("orderId") @Min(1) @Max(5) @ApiParam("ID of pet that needs to be fetched") Long orderId) { - return Response.ok().entity("magic!").build(); - } - - @POST - @Path("/order") - - @Produces({ "application/xml", "application/json" }) - @ApiOperation(value = "Place an order for a pet", notes = "", response = Order.class, tags={ "store" }) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation", response = Order.class), - @ApiResponse(code = 400, message = "Invalid Order", response = Order.class) }) - public Response placeOrder(Order body) { - return Response.ok().entity("magic!").build(); - } -} - +package io.swagger.api; + +import java.util.Map; +import io.swagger.model.Order; + +import javax.ws.rs.*; +import javax.ws.rs.core.Response; + +import io.swagger.annotations.*; + +import java.util.List; +import javax.validation.constraints.*; + +@Path("/store") + +@Api(description = "the store API") + + + + +public class StoreApi { + + @DELETE + @Path("/order/{orderId}") + + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Delete purchase order by ID", notes = "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", response = void.class, tags={ "store", }) + @ApiResponses(value = { + @ApiResponse(code = 400, message = "Invalid ID supplied", response = void.class), + @ApiResponse(code = 404, message = "Order not found", response = void.class) }) + public Response deleteOrder(@PathParam("orderId") @ApiParam("ID of the order that needs to be deleted") String orderId) { + return Response.ok().entity("magic!").build(); + } + + @GET + @Path("/inventory") + + @Produces({ "application/json" }) + @ApiOperation(value = "Returns pet inventories by status", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map", authorizations = { + @Authorization(value = "api_key") + }, tags={ "store", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Integer.class, responseContainer = "Map") }) + public Response getInventory() { + return Response.ok().entity("magic!").build(); + } + + @GET + @Path("/order/{orderId}") + + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Find purchase order by ID", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Order.class), + @ApiResponse(code = 400, message = "Invalid ID supplied", response = Order.class), + @ApiResponse(code = 404, message = "Order not found", response = Order.class) }) + public Response getOrderById(@PathParam("orderId") @Min(1) @Max(5) @ApiParam("ID of pet that needs to be fetched") Long orderId) { + return Response.ok().entity("magic!").build(); + } + + @POST + @Path("/order") + + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Place an order for a pet", notes = "", response = Order.class, tags={ "store" }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Order.class), + @ApiResponse(code = 400, message = "Invalid Order", response = Order.class) }) + public Response placeOrder(Order body) { + return Response.ok().entity("magic!").build(); + } +} + diff --git a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/api/UserApi.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/api/UserApi.java index fb6b92e2514..55a323774b8 100644 --- a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/api/UserApi.java +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/api/UserApi.java @@ -1,116 +1,116 @@ -package io.swagger.api; - -import java.util.List; -import io.swagger.model.User; - -import javax.ws.rs.*; -import javax.ws.rs.core.Response; - -import io.swagger.annotations.*; - -import java.util.List; -import javax.validation.constraints.*; - -@Path("/user") - -@Api(description = "the user API") - - - - -public class UserApi { - - @POST - - - @Produces({ "application/xml", "application/json" }) - @ApiOperation(value = "Create user", notes = "This can only be done by the logged in user.", response = void.class, tags={ "user", }) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation", response = void.class) }) - public Response createUser(User body) { - return Response.ok().entity("magic!").build(); - } - - @POST - @Path("/createWithArray") - - @Produces({ "application/xml", "application/json" }) - @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) }) - public Response createUsersWithArrayInput(List body) { - return Response.ok().entity("magic!").build(); - } - - @POST - @Path("/createWithList") - - @Produces({ "application/xml", "application/json" }) - @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) }) - public Response createUsersWithListInput(List body) { - return Response.ok().entity("magic!").build(); - } - - @DELETE - @Path("/{username}") - - @Produces({ "application/xml", "application/json" }) - @ApiOperation(value = "Delete user", notes = "This can only be done by the logged in user.", response = void.class, tags={ "user", }) - @ApiResponses(value = { - @ApiResponse(code = 400, message = "Invalid username supplied", response = void.class), - @ApiResponse(code = 404, message = "User not found", response = void.class) }) - public Response deleteUser(@PathParam("username") @ApiParam("The name that needs to be deleted") String username) { - return Response.ok().entity("magic!").build(); - } - - @GET - @Path("/{username}") - - @Produces({ "application/xml", "application/json" }) - @ApiOperation(value = "Get user by user name", notes = "", response = User.class, tags={ "user", }) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation", response = User.class), - @ApiResponse(code = 400, message = "Invalid username supplied", response = User.class), - @ApiResponse(code = 404, message = "User not found", response = User.class) }) - public Response getUserByName(@PathParam("username") @ApiParam("The name that needs to be fetched. Use user1 for testing. ") String username) { - return Response.ok().entity("magic!").build(); - } - - @GET - @Path("/login") - - @Produces({ "application/xml", "application/json" }) - @ApiOperation(value = "Logs user into the system", notes = "", response = String.class, tags={ "user", }) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation", response = String.class), - @ApiResponse(code = 400, message = "Invalid username/password supplied", response = String.class) }) - public Response loginUser(@QueryParam("username") @NotNull String username,@QueryParam("password") @NotNull String password) { - return Response.ok().entity("magic!").build(); - } - - @GET - @Path("/logout") - - @Produces({ "application/xml", "application/json" }) - @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) }) - public Response logoutUser() { - return Response.ok().entity("magic!").build(); - } - - @PUT - @Path("/{username}") - - @Produces({ "application/xml", "application/json" }) - @ApiOperation(value = "Updated user", notes = "This can only be done by the logged in user.", response = void.class, tags={ "user" }) - @ApiResponses(value = { - @ApiResponse(code = 400, message = "Invalid user supplied", response = void.class), - @ApiResponse(code = 404, message = "User not found", response = void.class) }) - public Response updateUser(@PathParam("username") @ApiParam("name that need to be deleted") String username,User body) { - return Response.ok().entity("magic!").build(); - } -} - +package io.swagger.api; + +import java.util.List; +import io.swagger.model.User; + +import javax.ws.rs.*; +import javax.ws.rs.core.Response; + +import io.swagger.annotations.*; + +import java.util.List; +import javax.validation.constraints.*; + +@Path("/user") + +@Api(description = "the user API") + + + + +public class UserApi { + + @POST + + + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Create user", notes = "This can only be done by the logged in user.", response = void.class, tags={ "user", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = void.class) }) + public Response createUser(User body) { + return Response.ok().entity("magic!").build(); + } + + @POST + @Path("/createWithArray") + + @Produces({ "application/xml", "application/json" }) + @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) }) + public Response createUsersWithArrayInput(List body) { + return Response.ok().entity("magic!").build(); + } + + @POST + @Path("/createWithList") + + @Produces({ "application/xml", "application/json" }) + @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) }) + public Response createUsersWithListInput(List body) { + return Response.ok().entity("magic!").build(); + } + + @DELETE + @Path("/{username}") + + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Delete user", notes = "This can only be done by the logged in user.", response = void.class, tags={ "user", }) + @ApiResponses(value = { + @ApiResponse(code = 400, message = "Invalid username supplied", response = void.class), + @ApiResponse(code = 404, message = "User not found", response = void.class) }) + public Response deleteUser(@PathParam("username") @ApiParam("The name that needs to be deleted") String username) { + return Response.ok().entity("magic!").build(); + } + + @GET + @Path("/{username}") + + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Get user by user name", notes = "", response = User.class, tags={ "user", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = User.class), + @ApiResponse(code = 400, message = "Invalid username supplied", response = User.class), + @ApiResponse(code = 404, message = "User not found", response = User.class) }) + public Response getUserByName(@PathParam("username") @ApiParam("The name that needs to be fetched. Use user1 for testing. ") String username) { + return Response.ok().entity("magic!").build(); + } + + @GET + @Path("/login") + + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Logs user into the system", notes = "", response = String.class, tags={ "user", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = String.class), + @ApiResponse(code = 400, message = "Invalid username/password supplied", response = String.class) }) + public Response loginUser(@QueryParam("username") @NotNull String username,@QueryParam("password") @NotNull String password) { + return Response.ok().entity("magic!").build(); + } + + @GET + @Path("/logout") + + @Produces({ "application/xml", "application/json" }) + @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) }) + public Response logoutUser() { + return Response.ok().entity("magic!").build(); + } + + @PUT + @Path("/{username}") + + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Updated user", notes = "This can only be done by the logged in user.", response = void.class, tags={ "user" }) + @ApiResponses(value = { + @ApiResponse(code = 400, message = "Invalid user supplied", response = void.class), + @ApiResponse(code = 404, message = "User not found", response = void.class) }) + public Response updateUser(@PathParam("username") @ApiParam("name that need to be deleted") String username,User body) { + return Response.ok().entity("magic!").build(); + } +} + diff --git a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Category.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Category.java index a382801bdba..90cf7f96de3 100644 --- a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Category.java +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Category.java @@ -1,91 +1,91 @@ -package io.swagger.model; - -import io.swagger.annotations.ApiModel; -import javax.validation.constraints.*; - - -/** - * A category for a pet - **/ -import io.swagger.annotations.*; -import java.util.Objects; -@ApiModel(description = "A category for a pet") - -public class Category { - - private Long id = null; - private String name = null; - - /** - **/ - public Category id(Long id) { - this.id = id; - return this; - } - - - @ApiModelProperty(example = "null", value = "") - public Long getId() { - return id; - } - public void setId(Long id) { - this.id = id; - } - - /** - **/ - public Category name(String name) { - this.name = name; - return this; - } - - - @ApiModelProperty(example = "null", value = "") - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Category category = (Category) o; - return Objects.equals(id, category.id) && - Objects.equals(name, category.name); - } - - @Override - public int hashCode() { - return Objects.hash(id, name); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Category {\n"); - - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} +package io.swagger.model; + +import io.swagger.annotations.ApiModel; +import javax.validation.constraints.*; + + +/** + * A category for a pet + **/ +import io.swagger.annotations.*; +import java.util.Objects; +@ApiModel(description = "A category for a pet") + +public class Category { + + private Long id = null; + private String name = null; + + /** + **/ + public Category id(Long id) { + this.id = id; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + + /** + **/ + public Category name(String name) { + this.name = name; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Category category = (Category) o; + return Objects.equals(id, category.id) && + Objects.equals(name, category.name); + } + + @Override + public int hashCode() { + return Objects.hash(id, name); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Category {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/ModelApiResponse.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/ModelApiResponse.java index 20e0effb560..92eed163547 100644 --- a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/ModelApiResponse.java +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/ModelApiResponse.java @@ -1,110 +1,110 @@ -package io.swagger.model; - -import io.swagger.annotations.ApiModel; -import javax.validation.constraints.*; - - -/** - * Describes the result of uploading an image resource - **/ -import io.swagger.annotations.*; -import java.util.Objects; -@ApiModel(description = "Describes the result of uploading an image resource") - -public class ModelApiResponse { - - private Integer code = null; - private String type = null; - private String message = null; - - /** - **/ - public ModelApiResponse code(Integer code) { - this.code = code; - return this; - } - - - @ApiModelProperty(example = "null", value = "") - public Integer getCode() { - return code; - } - public void setCode(Integer code) { - this.code = code; - } - - /** - **/ - public ModelApiResponse type(String type) { - this.type = type; - return this; - } - - - @ApiModelProperty(example = "null", value = "") - public String getType() { - return type; - } - public void setType(String type) { - this.type = type; - } - - /** - **/ - public ModelApiResponse message(String message) { - this.message = message; - return this; - } - - - @ApiModelProperty(example = "null", value = "") - public String getMessage() { - return message; - } - public void setMessage(String message) { - this.message = message; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ModelApiResponse _apiResponse = (ModelApiResponse) o; - return Objects.equals(code, _apiResponse.code) && - Objects.equals(type, _apiResponse.type) && - Objects.equals(message, _apiResponse.message); - } - - @Override - public int hashCode() { - return Objects.hash(code, type, message); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ModelApiResponse {\n"); - - sb.append(" code: ").append(toIndentedString(code)).append("\n"); - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" message: ").append(toIndentedString(message)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} +package io.swagger.model; + +import io.swagger.annotations.ApiModel; +import javax.validation.constraints.*; + + +/** + * Describes the result of uploading an image resource + **/ +import io.swagger.annotations.*; +import java.util.Objects; +@ApiModel(description = "Describes the result of uploading an image resource") + +public class ModelApiResponse { + + private Integer code = null; + private String type = null; + private String message = null; + + /** + **/ + public ModelApiResponse code(Integer code) { + this.code = code; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public Integer getCode() { + return code; + } + public void setCode(Integer code) { + this.code = code; + } + + /** + **/ + public ModelApiResponse type(String type) { + this.type = type; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + + /** + **/ + public ModelApiResponse message(String message) { + this.message = message; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public String getMessage() { + return message; + } + public void setMessage(String message) { + this.message = message; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelApiResponse _apiResponse = (ModelApiResponse) o; + return Objects.equals(code, _apiResponse.code) && + Objects.equals(type, _apiResponse.type) && + Objects.equals(message, _apiResponse.message); + } + + @Override + public int hashCode() { + return Objects.hash(code, type, message); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelApiResponse {\n"); + + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Order.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Order.java index be4f4c54b69..88fc3028936 100644 --- a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Order.java +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Order.java @@ -1,199 +1,199 @@ -package io.swagger.model; - -import io.swagger.annotations.ApiModel; -import javax.validation.constraints.*; - - -/** - * An order for a pets from the pet store - **/ -import io.swagger.annotations.*; -import java.util.Objects; -@ApiModel(description = "An order for a pets from the pet store") - -public class Order { - - private Long id = null; - private Long petId = null; - private Integer quantity = null; - private javax.xml.datatype.XMLGregorianCalendar shipDate = null; - -public enum StatusEnum { - - PLACED(String.valueOf("placed")), APPROVED(String.valueOf("approved")), DELIVERED(String.valueOf("delivered")); - - - private String value; - - StatusEnum (String v) { - value = v; - } - - public String value() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } - - public static StatusEnum fromValue(String v) { - for (StatusEnum b : StatusEnum.values()) { - if (String.valueOf(b.value).equals(v)) { - return b; - } - } - return null; - } -} - - private StatusEnum status = null; - private Boolean complete = false; - - /** - **/ - public Order id(Long id) { - this.id = id; - return this; - } - - - @ApiModelProperty(example = "null", value = "") - public Long getId() { - return id; - } - public void setId(Long id) { - this.id = id; - } - - /** - **/ - public Order petId(Long petId) { - this.petId = petId; - return this; - } - - - @ApiModelProperty(example = "null", value = "") - public Long getPetId() { - return petId; - } - public void setPetId(Long petId) { - this.petId = petId; - } - - /** - **/ - public Order quantity(Integer quantity) { - this.quantity = quantity; - return this; - } - - - @ApiModelProperty(example = "null", value = "") - public Integer getQuantity() { - return quantity; - } - public void setQuantity(Integer quantity) { - this.quantity = quantity; - } - - /** - **/ - public Order shipDate(javax.xml.datatype.XMLGregorianCalendar shipDate) { - this.shipDate = shipDate; - return this; - } - - - @ApiModelProperty(example = "null", value = "") - public javax.xml.datatype.XMLGregorianCalendar getShipDate() { - return shipDate; - } - public void setShipDate(javax.xml.datatype.XMLGregorianCalendar shipDate) { - this.shipDate = shipDate; - } - - /** - * Order Status - **/ - public Order status(StatusEnum status) { - this.status = status; - return this; - } - - - @ApiModelProperty(example = "null", value = "Order Status") - public StatusEnum getStatus() { - return status; - } - public void setStatus(StatusEnum status) { - this.status = status; - } - - /** - **/ - public Order complete(Boolean complete) { - this.complete = complete; - return this; - } - - - @ApiModelProperty(example = "null", value = "") - public Boolean getComplete() { - return complete; - } - public void setComplete(Boolean complete) { - this.complete = complete; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Order order = (Order) o; - return Objects.equals(id, order.id) && - Objects.equals(petId, order.petId) && - Objects.equals(quantity, order.quantity) && - Objects.equals(shipDate, order.shipDate) && - Objects.equals(status, order.status) && - Objects.equals(complete, order.complete); - } - - @Override - public int hashCode() { - return Objects.hash(id, petId, quantity, shipDate, status, complete); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Order {\n"); - - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" petId: ").append(toIndentedString(petId)).append("\n"); - sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); - sb.append(" shipDate: ").append(toIndentedString(shipDate)).append("\n"); - sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append(" complete: ").append(toIndentedString(complete)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} +package io.swagger.model; + +import io.swagger.annotations.ApiModel; +import javax.validation.constraints.*; + + +/** + * An order for a pets from the pet store + **/ +import io.swagger.annotations.*; +import java.util.Objects; +@ApiModel(description = "An order for a pets from the pet store") + +public class Order { + + private Long id = null; + private Long petId = null; + private Integer quantity = null; + private javax.xml.datatype.XMLGregorianCalendar shipDate = null; + +public enum StatusEnum { + + PLACED(String.valueOf("placed")), APPROVED(String.valueOf("approved")), DELIVERED(String.valueOf("delivered")); + + + private String value; + + StatusEnum (String v) { + value = v; + } + + public String value() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StatusEnum fromValue(String v) { + for (StatusEnum b : StatusEnum.values()) { + if (String.valueOf(b.value).equals(v)) { + return b; + } + } + return null; + } +} + + private StatusEnum status = null; + private Boolean complete = false; + + /** + **/ + public Order id(Long id) { + this.id = id; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + + /** + **/ + public Order petId(Long petId) { + this.petId = petId; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public Long getPetId() { + return petId; + } + public void setPetId(Long petId) { + this.petId = petId; + } + + /** + **/ + public Order quantity(Integer quantity) { + this.quantity = quantity; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public Integer getQuantity() { + return quantity; + } + public void setQuantity(Integer quantity) { + this.quantity = quantity; + } + + /** + **/ + public Order shipDate(javax.xml.datatype.XMLGregorianCalendar shipDate) { + this.shipDate = shipDate; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public javax.xml.datatype.XMLGregorianCalendar getShipDate() { + return shipDate; + } + public void setShipDate(javax.xml.datatype.XMLGregorianCalendar shipDate) { + this.shipDate = shipDate; + } + + /** + * Order Status + **/ + public Order status(StatusEnum status) { + this.status = status; + return this; + } + + + @ApiModelProperty(example = "null", value = "Order Status") + public StatusEnum getStatus() { + return status; + } + public void setStatus(StatusEnum status) { + this.status = status; + } + + /** + **/ + public Order complete(Boolean complete) { + this.complete = complete; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public Boolean getComplete() { + return complete; + } + public void setComplete(Boolean complete) { + this.complete = complete; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Order order = (Order) o; + return Objects.equals(id, order.id) && + Objects.equals(petId, order.petId) && + Objects.equals(quantity, order.quantity) && + Objects.equals(shipDate, order.shipDate) && + Objects.equals(status, order.status) && + Objects.equals(complete, order.complete); + } + + @Override + public int hashCode() { + return Objects.hash(id, petId, quantity, shipDate, status, complete); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Order {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" petId: ").append(toIndentedString(petId)).append("\n"); + sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); + sb.append(" shipDate: ").append(toIndentedString(shipDate)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" complete: ").append(toIndentedString(complete)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Pet.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Pet.java index 30114aa1817..e3d3384df3b 100644 --- a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Pet.java +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Pet.java @@ -1,205 +1,205 @@ -package io.swagger.model; - -import io.swagger.annotations.ApiModel; -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 - **/ -import io.swagger.annotations.*; -import java.util.Objects; -@ApiModel(description = "A pet for sale in the pet store") - -public class Pet { - - private Long id = null; - private Category category = null; - private String name = null; - private List photoUrls = new ArrayList(); - private List tags = new ArrayList(); - -public enum StatusEnum { - - AVAILABLE(String.valueOf("available")), PENDING(String.valueOf("pending")), SOLD(String.valueOf("sold")); - - - private String value; - - StatusEnum (String v) { - value = v; - } - - public String value() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } - - public static StatusEnum fromValue(String v) { - for (StatusEnum b : StatusEnum.values()) { - if (String.valueOf(b.value).equals(v)) { - return b; - } - } - return null; - } -} - - private StatusEnum status = null; - - /** - **/ - public Pet id(Long id) { - this.id = id; - return this; - } - - - @ApiModelProperty(example = "null", value = "") - public Long getId() { - return id; - } - public void setId(Long id) { - this.id = id; - } - - /** - **/ - public Pet category(Category category) { - this.category = category; - return this; - } - - - @ApiModelProperty(example = "null", value = "") - public Category getCategory() { - return category; - } - public void setCategory(Category category) { - this.category = category; - } - - /** - **/ - public Pet name(String name) { - this.name = name; - return this; - } - - - @ApiModelProperty(example = "doggie", required = true, value = "") - @NotNull - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } - - /** - **/ - public Pet photoUrls(List photoUrls) { - this.photoUrls = photoUrls; - return this; - } - - - @ApiModelProperty(example = "null", required = true, value = "") - @NotNull - public List getPhotoUrls() { - return photoUrls; - } - public void setPhotoUrls(List photoUrls) { - this.photoUrls = photoUrls; - } - - /** - **/ - public Pet tags(List tags) { - this.tags = tags; - return this; - } - - - @ApiModelProperty(example = "null", value = "") - public List getTags() { - return tags; - } - public void setTags(List tags) { - this.tags = tags; - } - - /** - * pet status in the store - **/ - public Pet status(StatusEnum status) { - this.status = status; - return this; - } - - - @ApiModelProperty(example = "null", value = "pet status in the store") - public StatusEnum getStatus() { - return status; - } - public void setStatus(StatusEnum status) { - this.status = status; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Pet pet = (Pet) o; - return Objects.equals(id, pet.id) && - Objects.equals(category, pet.category) && - Objects.equals(name, pet.name) && - Objects.equals(photoUrls, pet.photoUrls) && - Objects.equals(tags, pet.tags) && - Objects.equals(status, pet.status); - } - - @Override - public int hashCode() { - return Objects.hash(id, category, name, photoUrls, tags, status); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Pet {\n"); - - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" category: ").append(toIndentedString(category)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); - sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); - sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} +package io.swagger.model; + +import io.swagger.annotations.ApiModel; +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 + **/ +import io.swagger.annotations.*; +import java.util.Objects; +@ApiModel(description = "A pet for sale in the pet store") + +public class Pet { + + private Long id = null; + private Category category = null; + private String name = null; + private List photoUrls = new ArrayList(); + private List tags = new ArrayList(); + +public enum StatusEnum { + + AVAILABLE(String.valueOf("available")), PENDING(String.valueOf("pending")), SOLD(String.valueOf("sold")); + + + private String value; + + StatusEnum (String v) { + value = v; + } + + public String value() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StatusEnum fromValue(String v) { + for (StatusEnum b : StatusEnum.values()) { + if (String.valueOf(b.value).equals(v)) { + return b; + } + } + return null; + } +} + + private StatusEnum status = null; + + /** + **/ + public Pet id(Long id) { + this.id = id; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + + /** + **/ + public Pet category(Category category) { + this.category = category; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public Category getCategory() { + return category; + } + public void setCategory(Category category) { + this.category = category; + } + + /** + **/ + public Pet name(String name) { + this.name = name; + return this; + } + + + @ApiModelProperty(example = "doggie", required = true, value = "") + @NotNull + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + /** + **/ + public Pet photoUrls(List photoUrls) { + this.photoUrls = photoUrls; + return this; + } + + + @ApiModelProperty(example = "null", required = true, value = "") + @NotNull + public List getPhotoUrls() { + return photoUrls; + } + public void setPhotoUrls(List photoUrls) { + this.photoUrls = photoUrls; + } + + /** + **/ + public Pet tags(List tags) { + this.tags = tags; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public List getTags() { + return tags; + } + public void setTags(List tags) { + this.tags = tags; + } + + /** + * pet status in the store + **/ + public Pet status(StatusEnum status) { + this.status = status; + return this; + } + + + @ApiModelProperty(example = "null", value = "pet status in the store") + public StatusEnum getStatus() { + return status; + } + public void setStatus(StatusEnum status) { + this.status = status; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Pet pet = (Pet) o; + return Objects.equals(id, pet.id) && + Objects.equals(category, pet.category) && + Objects.equals(name, pet.name) && + Objects.equals(photoUrls, pet.photoUrls) && + Objects.equals(tags, pet.tags) && + Objects.equals(status, pet.status); + } + + @Override + public int hashCode() { + return Objects.hash(id, category, name, photoUrls, tags, status); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Pet {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); + sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Tag.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Tag.java index d99f85caac0..c7810381126 100644 --- a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Tag.java +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Tag.java @@ -1,91 +1,91 @@ -package io.swagger.model; - -import io.swagger.annotations.ApiModel; -import javax.validation.constraints.*; - - -/** - * A tag for a pet - **/ -import io.swagger.annotations.*; -import java.util.Objects; -@ApiModel(description = "A tag for a pet") - -public class Tag { - - private Long id = null; - private String name = null; - - /** - **/ - public Tag id(Long id) { - this.id = id; - return this; - } - - - @ApiModelProperty(example = "null", value = "") - public Long getId() { - return id; - } - public void setId(Long id) { - this.id = id; - } - - /** - **/ - public Tag name(String name) { - this.name = name; - return this; - } - - - @ApiModelProperty(example = "null", value = "") - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Tag tag = (Tag) o; - return Objects.equals(id, tag.id) && - Objects.equals(name, tag.name); - } - - @Override - public int hashCode() { - return Objects.hash(id, name); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Tag {\n"); - - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} +package io.swagger.model; + +import io.swagger.annotations.ApiModel; +import javax.validation.constraints.*; + + +/** + * A tag for a pet + **/ +import io.swagger.annotations.*; +import java.util.Objects; +@ApiModel(description = "A tag for a pet") + +public class Tag { + + private Long id = null; + private String name = null; + + /** + **/ + public Tag id(Long id) { + this.id = id; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + + /** + **/ + public Tag name(String name) { + this.name = name; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Tag tag = (Tag) o; + return Objects.equals(id, tag.id) && + Objects.equals(name, tag.name); + } + + @Override + public int hashCode() { + return Objects.hash(id, name); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Tag {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/User.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/User.java index b249ee61027..e2b0e7e2bb1 100644 --- a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/User.java +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/User.java @@ -1,206 +1,206 @@ -package io.swagger.model; - -import io.swagger.annotations.ApiModel; -import javax.validation.constraints.*; - - -/** - * A User who is purchasing from the pet store - **/ -import io.swagger.annotations.*; -import java.util.Objects; -@ApiModel(description = "A User who is purchasing from the pet store") - -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; - - /** - **/ - public User id(Long id) { - this.id = id; - return this; - } - - - @ApiModelProperty(example = "null", value = "") - public Long getId() { - return id; - } - public void setId(Long id) { - this.id = id; - } - - /** - **/ - public User username(String username) { - this.username = username; - return this; - } - - - @ApiModelProperty(example = "null", value = "") - public String getUsername() { - return username; - } - public void setUsername(String username) { - this.username = username; - } - - /** - **/ - public User firstName(String firstName) { - this.firstName = firstName; - return this; - } - - - @ApiModelProperty(example = "null", value = "") - public String getFirstName() { - return firstName; - } - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - /** - **/ - public User lastName(String lastName) { - this.lastName = lastName; - return this; - } - - - @ApiModelProperty(example = "null", value = "") - public String getLastName() { - return lastName; - } - public void setLastName(String lastName) { - this.lastName = lastName; - } - - /** - **/ - public User email(String email) { - this.email = email; - return this; - } - - - @ApiModelProperty(example = "null", value = "") - public String getEmail() { - return email; - } - public void setEmail(String email) { - this.email = email; - } - - /** - **/ - public User password(String password) { - this.password = password; - return this; - } - - - @ApiModelProperty(example = "null", value = "") - public String getPassword() { - return password; - } - public void setPassword(String password) { - this.password = password; - } - - /** - **/ - public User phone(String phone) { - this.phone = phone; - return this; - } - - - @ApiModelProperty(example = "null", value = "") - public String getPhone() { - return phone; - } - public void setPhone(String phone) { - this.phone = phone; - } - - /** - * User Status - **/ - public User userStatus(Integer userStatus) { - this.userStatus = userStatus; - return this; - } - - - @ApiModelProperty(example = "null", value = "User Status") - public Integer getUserStatus() { - return userStatus; - } - public void setUserStatus(Integer userStatus) { - this.userStatus = userStatus; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - User user = (User) o; - return Objects.equals(id, user.id) && - Objects.equals(username, user.username) && - Objects.equals(firstName, user.firstName) && - Objects.equals(lastName, user.lastName) && - Objects.equals(email, user.email) && - Objects.equals(password, user.password) && - Objects.equals(phone, user.phone) && - Objects.equals(userStatus, user.userStatus); - } - - @Override - public int hashCode() { - return Objects.hash(id, username, firstName, lastName, email, password, phone, userStatus); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class User {\n"); - - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" username: ").append(toIndentedString(username)).append("\n"); - sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n"); - sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n"); - sb.append(" email: ").append(toIndentedString(email)).append("\n"); - sb.append(" password: ").append(toIndentedString(password)).append("\n"); - sb.append(" phone: ").append(toIndentedString(phone)).append("\n"); - sb.append(" userStatus: ").append(toIndentedString(userStatus)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} +package io.swagger.model; + +import io.swagger.annotations.ApiModel; +import javax.validation.constraints.*; + + +/** + * A User who is purchasing from the pet store + **/ +import io.swagger.annotations.*; +import java.util.Objects; +@ApiModel(description = "A User who is purchasing from the pet store") + +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; + + /** + **/ + public User id(Long id) { + this.id = id; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + + /** + **/ + public User username(String username) { + this.username = username; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public String getUsername() { + return username; + } + public void setUsername(String username) { + this.username = username; + } + + /** + **/ + public User firstName(String firstName) { + this.firstName = firstName; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public String getFirstName() { + return firstName; + } + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + /** + **/ + public User lastName(String lastName) { + this.lastName = lastName; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public String getLastName() { + return lastName; + } + public void setLastName(String lastName) { + this.lastName = lastName; + } + + /** + **/ + public User email(String email) { + this.email = email; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public String getEmail() { + return email; + } + public void setEmail(String email) { + this.email = email; + } + + /** + **/ + public User password(String password) { + this.password = password; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public String getPassword() { + return password; + } + public void setPassword(String password) { + this.password = password; + } + + /** + **/ + public User phone(String phone) { + this.phone = phone; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public String getPhone() { + return phone; + } + public void setPhone(String phone) { + this.phone = phone; + } + + /** + * User Status + **/ + public User userStatus(Integer userStatus) { + this.userStatus = userStatus; + return this; + } + + + @ApiModelProperty(example = "null", value = "User Status") + public Integer getUserStatus() { + return userStatus; + } + public void setUserStatus(Integer userStatus) { + this.userStatus = userStatus; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + User user = (User) o; + return Objects.equals(id, user.id) && + Objects.equals(username, user.username) && + Objects.equals(firstName, user.firstName) && + Objects.equals(lastName, user.lastName) && + Objects.equals(email, user.email) && + Objects.equals(password, user.password) && + Objects.equals(phone, user.phone) && + Objects.equals(userStatus, user.userStatus); + } + + @Override + public int hashCode() { + return Objects.hash(id, username, firstName, lastName, email, password, phone, userStatus); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class User {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" username: ").append(toIndentedString(username)).append("\n"); + sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n"); + sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n"); + sb.append(" email: ").append(toIndentedString(email)).append("\n"); + sb.append(" password: ").append(toIndentedString(password)).append("\n"); + sb.append(" phone: ").append(toIndentedString(phone)).append("\n"); + sb.append(" userStatus: ").append(toIndentedString(userStatus)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/samples/server/petstore/jaxrs-spec/swagger.json b/samples/server/petstore/jaxrs-spec/swagger.json index a3adac3d4ac..c2b34d39d31 100644 --- a/samples/server/petstore/jaxrs-spec/swagger.json +++ b/samples/server/petstore/jaxrs-spec/swagger.json @@ -405,8 +405,7 @@ "in" : "path", "description" : "ID of the order that needs to be deleted", "required" : true, - "type" : "string", - "minimum" : 1 + "type" : "string" } ], "responses" : { "400" : { From 3ffc4bfa9d2c85fa822afe418ec2b02d335c924b Mon Sep 17 00:00:00 2001 From: Johannes Fiala Date: Mon, 23 Jan 2017 21:26:42 +0100 Subject: [PATCH 2/2] backport support DecimalMin/DecimalMax #4091 --- .../resources/Java/beanValidation.mustache | 25 ++++++++++--------- .../JavaJaxRS/cxf/beanValidation.mustache | 17 ++++++++++--- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/Java/beanValidation.mustache b/modules/swagger-codegen/src/main/resources/Java/beanValidation.mustache index 891a94b3ba1..079eab89d1a 100644 --- a/modules/swagger-codegen/src/main/resources/Java/beanValidation.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/beanValidation.mustache @@ -32,21 +32,22 @@ {{^minItems}} {{#maxItems}} @Size(max={{maxItems}}) - {{/maxItems}} - {{/minItems}} +{{/maxItems}} +{{/minItems}} +{{! check for integer / number=decimal type}} +{{#isInteger}} {{#minimum}} - {{#isInteger}} @Min({{minimum}}) - {{/isInteger}} - {{#isLong}} - @Min({{minimum}}) - {{/isLong}} {{/minimum}} {{#maximum}} - {{#isInteger}} @Max({{maximum}}) - {{/isInteger}} - {{#isLong}} - @Max({{maximum}}) - {{/isLong}} {{/maximum}} +{{/isInteger}} +{{^isInteger}} +{{#minimum}} + @DecimalMin("{{minimum}}") +{{/minimum}} +{{#maximum}} + @DecimalMax("{{maximum}}") +{{/maximum}} +{{/isInteger}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/beanValidation.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/beanValidation.mustache index f13ed596859..079eab89d1a 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/beanValidation.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/beanValidation.mustache @@ -32,11 +32,22 @@ {{^minItems}} {{#maxItems}} @Size(max={{maxItems}}) - {{/maxItems}} - {{/minItems}} +{{/maxItems}} +{{/minItems}} +{{! check for integer / number=decimal type}} +{{#isInteger}} {{#minimum}} @Min({{minimum}}) {{/minimum}} {{#maximum}} @Max({{maximum}}) -{{/maximum}} \ No newline at end of file +{{/maximum}} +{{/isInteger}} +{{^isInteger}} +{{#minimum}} + @DecimalMin("{{minimum}}") +{{/minimum}} +{{#maximum}} + @DecimalMax("{{maximum}}") +{{/maximum}} +{{/isInteger}} \ No newline at end of file