[Jaxrs-cxf-cdi] Add beanvalidation annotations updated (#4615)

* add check for hideGenerationTimestamp #4091

* update generated sample with no generated timestamps #4091

* add beanvalidation to jaxrs-cxf-cdi #4091

* add beanvalidation to jaxrs-cxf-cdi #4091

* update crlf

* replace tabs

* add check for hideGenerationTimestamp #4091

* update generated sample with no generated timestamps #4091

* add beanvalidation to jaxrs-cxf-cdi #4091

* add beanvalidation to jaxrs-cxf-cdi #4091

* update crlf

* replace tabs

* re-generate samples after rebasing #4091

* fix handling of inner enum templates #4091

* fix InputStream/Multipart imports and fileInputStream variable #4091

* fix paramName for files #4091

* consolidate beanValidationParams #4091

* add paramNameDetail #4615

* fix indentation and regenerate samples #4615

* reset samples jaxrs-spec to master

* update generated samples

* adapt Min/Max/DecimalMin/DecimalMax handling for int/long/else

* add ModelApiResponse
This commit is contained in:
jfiala 2017-02-05 17:55:30 +01:00 committed by wing328
parent a83f8d0449
commit 38c879683a
34 changed files with 284 additions and 93 deletions

View File

@ -1128,11 +1128,11 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
}
public boolean convertPropertyToBoolean(String propertyKey) {
boolean booleanValue = false;
if (additionalProperties.containsKey(propertyKey)) {
booleanValue = Boolean.valueOf(additionalProperties.get(propertyKey).toString());
}
boolean booleanValue = false;
if (additionalProperties.containsKey(propertyKey)) {
booleanValue = Boolean.valueOf(additionalProperties.get(propertyKey).toString());
}
return booleanValue;
}

View File

@ -1,8 +1,10 @@
package io.swagger.codegen.languages;
import io.swagger.codegen.CliOption;
import io.swagger.codegen.CodegenModel;
import io.swagger.codegen.CodegenProperty;
import io.swagger.codegen.SupportingFile;
import io.swagger.codegen.languages.features.BeanValidationFeatures;
import java.io.File;
@ -13,7 +15,10 @@ import java.io.File;
* in /src/gen/java and a sample ServiceImpl in /src/main/java. The API uses CDI
* to get an instance of ServiceImpl that implements the Service interface.
*/
public class JavaJAXRSCXFCDIServerCodegen extends JavaJAXRSSpecServerCodegen {
public class JavaJAXRSCXFCDIServerCodegen extends JavaJAXRSSpecServerCodegen implements BeanValidationFeatures {
protected boolean useBeanValidation = true;
/**
* Default constructor
*/
@ -32,6 +37,8 @@ public class JavaJAXRSCXFCDIServerCodegen extends JavaJAXRSSpecServerCodegen {
// Updated template directory
embeddedTemplateDir = templateDir = JAXRS_TEMPLATE_DIRECTORY_NAME
+ File.separator + "cxf-cdi";
cliOptions.add(CliOption.newBoolean(USE_BEANVALIDATION, "Use BeanValidation API annotations"));
}
@Override
@ -43,6 +50,14 @@ public class JavaJAXRSCXFCDIServerCodegen extends JavaJAXRSSpecServerCodegen {
public void processOpts() {
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 means these files are only written if they don't already exist
@ -73,4 +88,7 @@ public class JavaJAXRSCXFCDIServerCodegen extends JavaJAXRSSpecServerCodegen {
+ "Apache CXF runtime and a Java EE runtime with CDI enabled.";
}
public void setUseBeanValidation(boolean useBeanValidation) {
this.useBeanValidation = useBeanValidation;
}
}

View File

@ -12,11 +12,15 @@ import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import io.swagger.annotations.*;
import java.io.InputStream;
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
import org.apache.cxf.jaxrs.ext.multipart.Multipart;
import java.util.List;
{{#useBeanValidation}}
import javax.validation.constraints.*;
{{/useBeanValidation}}
@Path("/{{baseName}}")
@RequestScoped
@ -48,7 +52,7 @@ public class {{classname}} {
@ApiResponses(value = { {{#responses}}
@ApiResponse(code = {{{code}}}, message = "{{{message}}}", response = {{{returnType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}){{#hasMore}},{{/hasMore}}{{/responses}} })
public Response {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {
return delegate.{{nickname}}({{#allParams}}{{#isFile}}inputStream, fileDetail{{/isFile}}{{^isFile}}{{paramName}}{{/isFile}}, {{/allParams}}securityContext);
return delegate.{{nickname}}({{#allParams}}{{#isFile}}{{paramName}}InputStream, {{paramName}}Detail{{/isFile}}{{^isFile}}{{paramName}}{{/isFile}}, {{/allParams}}securityContext);
}
{{/operation}}
}

View File

@ -4,6 +4,7 @@ import {{package}}.*;
import {{modelPackage}}.*;
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
import org.apache.cxf.jaxrs.ext.multipart.Multipart;
{{#imports}}import {{import}};
{{/imports}}

View File

@ -0,0 +1,63 @@
{{#required}}
@NotNull
{{/required}}
{{#pattern}}
@Pattern(regexp="{{pattern}}")
{{/pattern}}
{{#minLength}}
{{#maxLength}}
@Size(min={{minLength}},max={{maxLength}})
{{/maxLength}}
{{/minLength}}
{{#minLength}}
{{^maxLength}}
@Size(min={{minLength}})
{{/maxLength}}
{{/minLength}}
{{^minLength}}
{{#maxLength}}
@Size(max={{maxLength}})
{{/maxLength}}
{{/minLength}}
{{#minItems}}
{{#maxItems}}
@Size(min={{minItems}},max={{maxItems}})
{{/maxItems}}
{{/minItems}}
{{#minItems}}
{{^maxItems}}
@Size(min={{minItems}})
{{/maxItems}}
{{/minItems}}
{{^minItems}}
{{#maxItems}}
@Size(max={{maxItems}})
{{/maxItems}}
{{/minItems}}
{{! check for integer or long / all others=decimal type with @Decimal*}}
{{#isInteger}}
{{#minimum}}
@Min({{minimum}})
{{/minimum}}
{{#maximum}}
@Max({{maximum}})
{{/maximum}}
{{/isInteger}}
{{#isLong}}
{{#minimum}}
@Min({{minimum}})
{{/minimum}}
{{#maximum}}
@Max({{maximum}})
{{/maximum}}
{{/isLong}}
{{^isInteger}}
{{^isLong}}
{{#minimum}}
@DecimalMin("{{minimum}}")
{{/minimum}}
{{#maximum}}
@DecimalMax("{{maximum}}")
{{/maximum}}
{{/isLong}}
{{/isInteger}}

View File

@ -0,0 +1,3 @@
{{#pattern}} @Pattern(regexp="{{pattern}}"){{/pattern}}{{#minLength}}{{#maxLength}} @Size(min={{minLength}},max={{maxLength}}){{/maxLength}}{{/minLength}}{{#minLength}}{{^maxLength}} @Size(min={{minLength}}){{/maxLength}}{{/minLength}}{{^minLength}}{{#maxLength}} @Size(max={{maxLength}}){{/maxLength}}{{/minLength}}{{#minItems}}{{#maxItems}} @Size(min={{minItems}},max={{maxItems}}){{/maxItems}}{{/minItems}}{{#minItems}}{{^maxItems}} @Size(min={{minItems}}){{/maxItems}}{{/minItems}}{{^minItems}}{{#maxItems}} @Size(max={{maxItems}}){{/maxItems}}{{/minItems}}{{!
check for integer or long / all others=decimal type with @Decimal*
}}{{#isInteger}}{{#minimum}} @Min({{minimum}}){{/minimum}}{{#maximum}} @Max({{maximum}}){{/maximum}}{{/isInteger}}{{#isLong}}{{#minimum}} @Min({{minimum}}){{/minimum}}{{#maximum}} @Max({{maximum}}){{/maximum}}{{/isLong}}{{^isInteger}}{{^isLong}}{{#minimum}} @DecimalMin("{{minimum}}"){{/minimum}}{{#maximum}} @DecimalMax("{{maximum}}"){{/maximum}}{{/isLong}}{{/isInteger}}

View File

@ -0,0 +1 @@
{{! PathParam is always required, no @NotNull necessary }}{{>beanValidationParams}}

View File

@ -0,0 +1 @@
{{#required}} @NotNull{{/required}}{{>beanValidationParams}}

View File

@ -1,16 +1,33 @@
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlType;
@XmlType(name="{{datatypeWithEnum}}")
@XmlEnum({{datatype}}.class)
public enum {{datatypeWithEnum}} {
{{#allowableValues}}
{{#enumVars}}@XmlEnumValue({{{value}}}) {{name}}({{datatype}}.valueOf({{{value}}})){{^-last}}, {{/-last}}{{#-last}};{{/-last}}{{/enumVars}}
{{/allowableValues}}
private {{datatype}} value;
{{datatypeWithEnum}} ({{datatype}} v) {
value = v;
}
@XmlType(name="{{classname}}")
@XmlEnum
public enum {{classname}} {
{{#allowableValues}}{{.}}{{^-last}}, {{/-last}}{{#-last}};{{/-last}}{{/allowableValues}}
public String value() {
return name();
return value;
}
public static {{classname}} fromValue(String v) {
return valueOf(v);
@Override
public String toString() {
return String.valueOf(value);
}
}
public static {{datatypeWithEnum}} fromValue(String v) {
for ({{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) {
if (String.valueOf(b.value).equals(v)) {
return b;
}
}
return null;
}
}

View File

@ -1 +1 @@
@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}")
{{^hideGenerationTimestamp}}@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}"){{/hideGenerationTimestamp}}

View File

@ -2,7 +2,9 @@ package {{package}};
{{#imports}}import {{import}};
{{/imports}}
{{#useBeanValidation}}
import javax.validation.constraints.*;
{{/useBeanValidation}}
{{#models}}
{{#model}}{{#description}}
/**

View File

@ -1 +1 @@
{{#isPathParam}}@ApiParam(value = "{{{description}}}"{{#required}},required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @PathParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isPathParam}}
{{#isPathParam}}{{#useBeanValidation}}{{>beanValidationPathParams}}{{/useBeanValidation}}@ApiParam(value = "{{{description}}}"{{#required}},required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @PathParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isPathParam}}

View File

@ -1,5 +1,8 @@
import io.swagger.annotations.*;
import java.util.Objects;
import javax.xml.bind.annotation.*;
{{#description}}@ApiModel(description = "{{{description}}}"){{/description}}
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#serializableModel}}implements Serializable{{/serializableModel}} {
@ -24,7 +27,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
{{#vendorExtensions.extraAnnotation}}{{{vendorExtensions.extraAnnotation}}}{{/vendorExtensions.extraAnnotation}}
@ApiModelProperty({{#example}}example = "{{example}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}")
@JsonProperty("{{baseName}}")
public {{{datatypeWithEnum}}} {{getter}}() {
{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{getter}}() {
return {{name}};
}
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {

View File

@ -76,6 +76,16 @@
<artifactId>swagger-annotations</artifactId>
<version>[1.5.3,2)</version>
</dependency>
{{#useBeanValidation}}
<!-- Bean Validation API support -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
<scope>provided</scope>
</dependency>
{{/useBeanValidation}}
</dependencies>

View File

@ -1 +1 @@
{{#isQueryParam}}@ApiParam(value = "{{{description}}}"{{#required}},required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) {{#defaultValue}}@DefaultValue("{{{defaultValue}}}"){{/defaultValue}} @QueryParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isQueryParam}}
{{#isQueryParam}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}@ApiParam(value = "{{{description}}}"{{#required}},required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) {{#defaultValue}}@DefaultValue("{{{defaultValue}}}"){{/defaultValue}} @QueryParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isQueryParam}}

View File

@ -76,6 +76,14 @@
<artifactId>swagger-annotations</artifactId>
<version>[1.5.3,2)</version>
</dependency>
<!-- Bean Validation API support -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
<scope>provided</scope>
</dependency>
</dependencies>

View File

@ -13,18 +13,20 @@ import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import io.swagger.annotations.*;
import java.io.InputStream;
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
import org.apache.cxf.jaxrs.ext.multipart.Multipart;
import java.util.List;
import javax.validation.constraints.*;
@Path("/pet")
@RequestScoped
@Api(description = "the pet API")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJAXRSCXFCDIServerCodegen", date = "2016-11-17T08:53:42.205Z")
public class PetApi {
@ -78,7 +80,7 @@ public class PetApi {
@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(@ApiParam(value = "Status values that need to be considered for filter",required=true, allowableValues="available, pending, sold") @QueryParam("status") List<String> status) {
public Response findPetsByStatus( @NotNull @ApiParam(value = "Status values that need to be considered for filter",required=true, allowableValues="available, pending, sold") @QueryParam("status") List<String> status) {
return delegate.findPetsByStatus(status, securityContext);
}
@ -95,7 +97,7 @@ public class PetApi {
@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(@ApiParam(value = "Tags to filter by",required=true) @QueryParam("tags") List<String> tags) {
public Response findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by",required=true) @QueryParam("tags") List<String> tags) {
return delegate.findPetsByTags(tags, securityContext);
}
@ -161,6 +163,6 @@ public class PetApi {
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) })
public Response uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathParam("petId") Long petId, @Multipart(value = "additionalMetadata", required = false) String additionalMetadata, @Multipart(value = "file", required = false) InputStream fileInputStream, @Multipart(value = "file" , required = false) Attachment fileDetail) {
return delegate.uploadFile(petId, additionalMetadata, inputStream, fileDetail, securityContext);
return delegate.uploadFile(petId, additionalMetadata, fileInputStream, fileDetail, securityContext);
}
}

View File

@ -4,6 +4,7 @@ import io.swagger.api.*;
import io.swagger.model.*;
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
import org.apache.cxf.jaxrs.ext.multipart.Multipart;
import java.io.File;
import io.swagger.model.ModelApiResponse;
@ -16,7 +17,7 @@ import java.io.InputStream;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJAXRSCXFCDIServerCodegen", date = "2016-11-17T08:53:42.205Z")
public interface PetApiService {
public Response addPet(Pet body, SecurityContext securityContext);
public Response deletePet(Long petId, String apiKey, SecurityContext securityContext);

View File

@ -12,18 +12,20 @@ import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import io.swagger.annotations.*;
import java.io.InputStream;
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
import org.apache.cxf.jaxrs.ext.multipart.Multipart;
import java.util.List;
import javax.validation.constraints.*;
@Path("/store")
@RequestScoped
@Api(description = "the store API")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJAXRSCXFCDIServerCodegen", date = "2016-11-17T08:53:42.205Z")
public class StoreApi {
@ -66,7 +68,7 @@ public class StoreApi {
@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(@ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathParam("orderId") Long orderId) {
public Response getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathParam("orderId") Long orderId) {
return delegate.getOrderById(orderId, securityContext);
}

View File

@ -4,6 +4,7 @@ import io.swagger.api.*;
import io.swagger.model.*;
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
import org.apache.cxf.jaxrs.ext.multipart.Multipart;
import java.util.Map;
import io.swagger.model.Order;
@ -15,7 +16,7 @@ import java.io.InputStream;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJAXRSCXFCDIServerCodegen", date = "2016-11-17T08:53:42.205Z")
public interface StoreApiService {
public Response deleteOrder(String orderId, SecurityContext securityContext);
public Response getInventory(SecurityContext securityContext);

View File

@ -12,18 +12,20 @@ import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import io.swagger.annotations.*;
import java.io.InputStream;
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
import org.apache.cxf.jaxrs.ext.multipart.Multipart;
import java.util.List;
import javax.validation.constraints.*;
@Path("/user")
@RequestScoped
@Api(description = "the user API")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJAXRSCXFCDIServerCodegen", date = "2016-11-17T08:53:42.205Z")
public class UserApi {
@ -98,7 +100,7 @@ public class UserApi {
@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(@ApiParam(value = "The user name for login",required=true) @QueryParam("username") String username, @ApiParam(value = "The password for login in clear text",required=true) @QueryParam("password") String password) {
public Response loginUser( @NotNull @ApiParam(value = "The user name for login",required=true) @QueryParam("username") String username, @NotNull @ApiParam(value = "The password for login in clear text",required=true) @QueryParam("password") String password) {
return delegate.loginUser(username, password, securityContext);
}

View File

@ -4,6 +4,7 @@ import io.swagger.api.*;
import io.swagger.model.*;
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
import org.apache.cxf.jaxrs.ext.multipart.Multipart;
import java.util.List;
import io.swagger.model.User;
@ -15,7 +16,7 @@ import java.io.InputStream;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJAXRSCXFCDIServerCodegen", date = "2016-11-17T08:53:42.205Z")
public interface UserApiService {
public Response createUser(User body, SecurityContext securityContext);
public Response createUsersWithArrayInput(List<User> body, SecurityContext securityContext);

View File

@ -3,7 +3,7 @@ package io.swagger.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import javax.validation.constraints.*;
/**
* A category for a pet
@ -11,6 +11,9 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.*;
import java.util.Objects;
import javax.xml.bind.annotation.*;
@ApiModel(description = "A category for a pet")
public class Category {

View File

@ -3,7 +3,7 @@ package io.swagger.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import javax.validation.constraints.*;
/**
* Describes the result of uploading an image resource
@ -11,6 +11,9 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.*;
import java.util.Objects;
import javax.xml.bind.annotation.*;
@ApiModel(description = "Describes the result of uploading an image resource")
public class ModelApiResponse {

View File

@ -3,7 +3,7 @@ package io.swagger.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import javax.validation.constraints.*;
/**
* An order for a pets from the pet store
@ -11,6 +11,9 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.*;
import java.util.Objects;
import javax.xml.bind.annotation.*;
@ApiModel(description = "An order for a pets from the pet store")
public class Order {
@ -20,22 +23,38 @@ public class Order {
private Integer quantity = null;
private java.util.Date shipDate = null;
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlType;
@XmlType(name="StatusEnum")
@XmlEnum(String.class)
public enum StatusEnum {
@XmlType(name="Order")
@XmlEnum
public enum Order {
{values&#x3D;[placed, approved, delivered], enumVars&#x3D;[{name&#x3D;PLACED, value&#x3D;&quot;placed&quot;}, {name&#x3D;APPROVED, value&#x3D;&quot;approved&quot;}, {name&#x3D;DELIVERED, value&#x3D;&quot;delivered&quot;}]},
public String value() {
return name();
@XmlEnumValue("placed") PLACED(String.valueOf("placed")), @XmlEnumValue("approved") APPROVED(String.valueOf("approved")), @XmlEnumValue("delivered") DELIVERED(String.valueOf("delivered"));
private String value;
StatusEnum (String v) {
value = v;
}
public static Order fromValue(String v) {
return valueOf(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;

View File

@ -7,7 +7,7 @@ import io.swagger.model.Category;
import io.swagger.model.Tag;
import java.util.ArrayList;
import java.util.List;
import javax.validation.constraints.*;
/**
* A pet for sale in the pet store
@ -15,6 +15,9 @@ import java.util.List;
import io.swagger.annotations.*;
import java.util.Objects;
import javax.xml.bind.annotation.*;
@ApiModel(description = "A pet for sale in the pet store")
public class Pet {
@ -25,22 +28,38 @@ public class Pet {
private List<String> photoUrls = new ArrayList<String>();
private List<Tag> tags = new ArrayList<Tag>();
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlType;
@XmlType(name="StatusEnum")
@XmlEnum(String.class)
public enum StatusEnum {
@XmlType(name="Pet")
@XmlEnum
public enum Pet {
{values&#x3D;[available, pending, sold], enumVars&#x3D;[{name&#x3D;AVAILABLE, value&#x3D;&quot;available&quot;}, {name&#x3D;PENDING, value&#x3D;&quot;pending&quot;}, {name&#x3D;SOLD, value&#x3D;&quot;sold&quot;}]},
public String value() {
return name();
@XmlEnumValue("available") AVAILABLE(String.valueOf("available")), @XmlEnumValue("pending") PENDING(String.valueOf("pending")), @XmlEnumValue("sold") SOLD(String.valueOf("sold"));
private String value;
StatusEnum (String v) {
value = v;
}
public static Pet fromValue(String v) {
return valueOf(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;
/**
@ -87,6 +106,7 @@ public enum Pet {
@ApiModelProperty(example = "doggie", required = true, value = "")
@JsonProperty("name")
@NotNull
public String getName() {
return name;
}
@ -104,6 +124,7 @@ public enum Pet {
@ApiModelProperty(example = "null", required = true, value = "")
@JsonProperty("photoUrls")
@NotNull
public List<String> getPhotoUrls() {
return photoUrls;
}

View File

@ -3,7 +3,7 @@ package io.swagger.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import javax.validation.constraints.*;
/**
* A tag for a pet
@ -11,6 +11,9 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.*;
import java.util.Objects;
import javax.xml.bind.annotation.*;
@ApiModel(description = "A tag for a pet")
public class Tag {

View File

@ -3,7 +3,7 @@ package io.swagger.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import javax.validation.constraints.*;
/**
* A User who is purchasing from the pet store
@ -11,6 +11,9 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.*;
import java.util.Objects;
import javax.xml.bind.annotation.*;
@ApiModel(description = "A User who is purchasing from the pet store")
public class User {

View File

@ -1,9 +1,9 @@
package io.swagger.api;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
@ApplicationPath("/")
public class RestApplication extends Application {
// Add implementation-specific details here
package io.swagger.api;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
@ApplicationPath("/")
public class RestApplication extends Application {
// Add implementation-specific details here
}

View File

@ -18,7 +18,7 @@ import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
@RequestScoped
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJAXRSCXFCDIServerCodegen", date = "2016-11-17T08:53:42.205Z")
public class PetApiServiceImpl implements PetApiService {
@Override
public Response addPet(Pet body, SecurityContext securityContext) {

View File

@ -17,7 +17,7 @@ import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
@RequestScoped
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJAXRSCXFCDIServerCodegen", date = "2016-11-17T08:53:42.205Z")
public class StoreApiServiceImpl implements StoreApiService {
@Override
public Response deleteOrder(String orderId, SecurityContext securityContext) {

View File

@ -17,7 +17,7 @@ import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
@RequestScoped
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJAXRSCXFCDIServerCodegen", date = "2016-11-17T08:53:42.205Z")
public class UserApiServiceImpl implements UserApiService {
@Override
public Response createUser(User body, SecurityContext securityContext) {

View File

@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
<!--
This is just an empty file so that CDI archive scanning kicks in when
implicit archive scanning is disabled (such as on IBM Bluemix)
-->
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
<!--
This is just an empty file so that CDI archive scanning kicks in when
implicit archive scanning is disabled (such as on IBM Bluemix)
-->
</beans>

View File

@ -375,8 +375,8 @@
"description" : "ID of pet that needs to be fetched",
"required" : true,
"type" : "integer",
"maximum" : 5.0,
"minimum" : 1.0,
"maximum" : 5,
"minimum" : 1,
"format" : "int64"
} ],
"responses" : {
@ -405,8 +405,7 @@
"in" : "path",
"description" : "ID of the order that needs to be deleted",
"required" : true,
"type" : "string",
"minimum" : 1.0
"type" : "string"
} ],
"responses" : {
"400" : {