diff --git a/bin/jaxrs-resteasy-petstore-server.sh b/bin/jaxrs-resteasy-petstore-server.sh new file mode 100644 index 00000000000..ca214b53a16 --- /dev/null +++ b/bin/jaxrs-resteasy-petstore-server.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +SCRIPT="$0" + +while [ -h "$SCRIPT" ] ; do + ls=`ls -ld "$SCRIPT"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + SCRIPT="$link" + else + SCRIPT=`dirname "$SCRIPT"`/"$link" + fi +done + +if [ ! -d "${APP_DIR}" ]; then + APP_DIR=`dirname "$SCRIPT"`/.. + APP_DIR=`cd "${APP_DIR}"; pwd` +fi + +executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar" + +if [ ! -f "$executable" ] +then + mvn clean package +fi + +# if you've executed sbt assembly previously it will use that instead. +export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" +ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaJaxRS -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l jaxrs-resteasy -o samples/server/petstore/jaxrs-resteasy" + +java $JAVA_OPTS -jar $executable $ags 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 a49fd15d5b9..91bce545e28 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 @@ -219,10 +219,19 @@ public class JavaResteasyServerCodegen extends JavaClientCodegen implements Code @Override public Map postProcessOperations(Map objs) { + Map operations = (Map) objs.get("operations"); if (operations != null) { List ops = (List) operations.get("operation"); for (CodegenOperation operation : ops) { + if (operation.hasConsumes == Boolean.TRUE) { + Map firstType = operation.consumes.get(0); + if (firstType != null) { + if ("multipart/form-data".equals(firstType.get("mediaType"))) { + operation.isMultipart = Boolean.TRUE; + } + } + } List responses = operation.responses; if (responses != null) { for (CodegenResponse resp : responses) { diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/resteasy/api.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/resteasy/api.mustache index 34bd16e3804..d83facaf646 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/resteasy/api.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/resteasy/api.mustache @@ -16,7 +16,8 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.Response; import javax.ws.rs.core.SecurityContext; import javax.ws.rs.*; - +{{#operations}}{{#operation}}{{#isMultipart}}import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput; +{{/isMultipart}}{{/operation}}{{/operations}} @Path("/{{baseName}}") {{#hasConsumes}}@Consumes({ {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}} {{#hasProduces}}@Produces({ {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}} @@ -30,10 +31,9 @@ public class {{classname}} { {{#subresourceOperation}}@Path("{{path}}"){{/subresourceOperation}} {{#hasConsumes}}@Consumes({ {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}} {{#hasProduces}}@Produces({ {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}} - - public Response {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}},{{/allParams}}@Context SecurityContext securityContext) + public Response {{nickname}}({{#isMultipart}}MultipartFormDataInput input,{{/isMultipart}}{{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{^isMultipart}}{{>formParams}},{{/isMultipart}}{{#isMultipart}}{{^isFormParam}},{{/isFormParam}}{{/isMultipart}}{{/allParams}}@Context SecurityContext securityContext) throws NotFoundException { - return delegate.{{nickname}}({{#allParams}}{{#isFile}}fileDetail{{/isFile}}{{^isFile}}{{paramName}}{{/isFile}},{{/allParams}}securityContext); + return delegate.{{nickname}}({{#isMultipart}}input,{{/isMultipart}}{{#allParams}}{{^isMultipart}}{{paramName}},{{/isMultipart}}{{#isMultipart}}{{^isFormParam}}{{paramName}},{{/isFormParam}}{{/isMultipart}}{{/allParams}}securityContext); } {{/operation}} } diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/resteasy/apiService.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/resteasy/apiService.mustache index be611237b7e..21915e68ebc 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/resteasy/apiService.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/resteasy/apiService.mustache @@ -2,6 +2,8 @@ package {{package}}; import {{package}}.*; import {{modelPackage}}.*; +{{#operations}}{{#operation}}{{#isMultipart}}import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput; +{{/isMultipart}}{{/operation}}{{/operations}} {{#imports}}import {{import}}; {{/imports}} @@ -18,7 +20,7 @@ import javax.ws.rs.core.SecurityContext; {{#operations}} public abstract class {{classname}}Service { {{#operation}} - public abstract Response {{nickname}}({{#allParams}}{{>serviceQueryParams}}{{>servicePathParams}}{{>serviceHeaderParams}}{{>serviceBodyParams}}{{>serviceFormParams}},{{/allParams}}SecurityContext securityContext) + public abstract Response {{nickname}}({{#isMultipart}}MultipartFormDataInput input,{{/isMultipart}}{{#allParams}}{{>serviceQueryParams}}{{>servicePathParams}}{{>serviceHeaderParams}}{{>serviceBodyParams}}{{^isMultipart}}{{>serviceFormParams}},{{/isMultipart}}{{#isMultipart}}{{^isFormParam}},{{/isFormParam}}{{/isMultipart}}{{/allParams}}SecurityContext securityContext) throws NotFoundException; {{/operation}} } diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/resteasy/apiServiceImpl.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/resteasy/apiServiceImpl.mustache index e2ee7c09fbb..bc7e896e4b0 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/resteasy/apiServiceImpl.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/resteasy/apiServiceImpl.mustache @@ -2,6 +2,8 @@ package {{package}}.impl; import {{package}}.*; import {{modelPackage}}.*; +{{#operations}}{{#operation}}{{#isMultipart}}import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput; +{{/isMultipart}}{{/operation}}{{/operations}} {{#imports}}import {{import}}; {{/imports}} @@ -19,7 +21,7 @@ import javax.ws.rs.core.SecurityContext; public class {{classname}}ServiceImpl extends {{classname}}Service { {{#operation}} @Override - public Response {{nickname}}({{#allParams}}{{>serviceQueryParams}}{{>servicePathParams}}{{>serviceHeaderParams}}{{>serviceBodyParams}}{{>serviceFormParams}},{{/allParams}}SecurityContext securityContext) + public Response {{nickname}}({{#isMultipart}}MultipartFormDataInput input,{{/isMultipart}}{{#allParams}}{{>serviceQueryParams}}{{>servicePathParams}}{{>serviceHeaderParams}}{{>serviceBodyParams}}{{^isMultipart}}{{>serviceFormParams}},{{/isMultipart}}{{#isMultipart}}{{^isFormParam}},{{/isFormParam}}{{/isMultipart}}{{/allParams}}SecurityContext securityContext) throws NotFoundException { // do some magic! return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/resteasy/formParams.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/resteasy/formParams.mustache index c7a3108f5c7..7494e6a00ad 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/resteasy/formParams.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/resteasy/formParams.mustache @@ -1,2 +1 @@ -{{#isFormParam}}{{#notFile}}@FormParam("{{paramName}}") {{{dataType}}} {{paramName}}{{/notFile}}{{#isFile}} @FormDataParam("file") InputStream inputStream, - @FormDataParam("file") FormDataContentDisposition fileDetail{{/isFile}}{{/isFormParam}} \ No newline at end of file +{{#isFormParam}}{{#notFile}}@FormParam("{{paramName}}") {{{dataType}}} {{paramName}}{{/notFile}}{{/isFormParam}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/resteasy/gradle.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/resteasy/gradle.mustache index 9c17c29da73..b5d7e2378ef 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/resteasy/gradle.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/resteasy/gradle.mustache @@ -11,6 +11,7 @@ dependencies { providedCompile 'org.jboss.resteasy:resteasy-jaxrs:3.0.11.Final' providedCompile 'org.jboss.resteasy:jaxrs-api:3.0.11.Final' providedCompile 'org.jboss.resteasy:resteasy-validator-provider-11:3.0.11.Final' + providedCompile 'org.jboss.resteasy:resteasy-multipart-provider:3.0.11.Final' providedCompile 'javax.annotation:javax.annotation-api:1.2' providedCompile 'org.jboss.spec.javax.servlet:jboss-servlet-api_3.0_spec:1.0.0.Final' compile 'org.jboss.resteasy:resteasy-jackson2-provider:3.0.11.Final' diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/resteasy/pom.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/resteasy/pom.mustache index f6ee1eec9c2..a686eaf8f29 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/resteasy/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/resteasy/pom.mustache @@ -79,6 +79,12 @@ ${resteasy-version} provided + + org.jboss.resteasy + resteasy-multipart-provider + ${resteasy-version} + provided + org.jboss.resteasy resteasy-jackson2-provider diff --git a/samples/server/petstore/jaxrs-resteasy/README.md b/samples/server/petstore/jaxrs-resteasy/README.md new file mode 100644 index 00000000000..cc011c37ee5 --- /dev/null +++ b/samples/server/petstore/jaxrs-resteasy/README.md @@ -0,0 +1,23 @@ +# Swagger generated server + +## Overview +This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the +[OpenAPI-Spec](https://github.com/swagger-api/swagger-core/wiki) from a remote server, you can easily generate a server stub. This +is an example of building a swagger-enabled JAX-RS server. + +This example uses the [JAX-RS](https://jax-rs-spec.java.net/) framework. + +To run the server, please execute the following: + +``` +mvn clean package jetty:run +``` + +You can then view the swagger listing here: + +``` +http://localhost:8080/v2/swagger.json +``` + +Note that if you have configured the `host` to be something other than localhost, the calls through +swagger-ui will be directed to that host and not localhost! \ No newline at end of file diff --git a/samples/server/petstore/jaxrs-resteasy/build.gradle b/samples/server/petstore/jaxrs-resteasy/build.gradle new file mode 100644 index 00000000000..d7afa6c5222 --- /dev/null +++ b/samples/server/petstore/jaxrs-resteasy/build.gradle @@ -0,0 +1,32 @@ +apply plugin: 'war' + +project.version = "1.0.0" +project.group = "io.swagger" + +repositories { + mavenCentral() +} + +dependencies { + providedCompile 'org.jboss.resteasy:resteasy-jaxrs:3.0.11.Final' + providedCompile 'org.jboss.resteasy:jaxrs-api:3.0.11.Final' + providedCompile 'org.jboss.resteasy:resteasy-validator-provider-11:3.0.11.Final' + providedCompile 'org.jboss.resteasy:resteasy-multipart-provider:3.0.11.Final' + providedCompile 'javax.annotation:javax.annotation-api:1.2' + providedCompile 'org.jboss.spec.javax.servlet:jboss-servlet-api_3.0_spec:1.0.0.Final' + compile 'org.jboss.resteasy:resteasy-jackson2-provider:3.0.11.Final' + +// compile 'com.fasterxml.jackson.datatype:jackson-datatype-joda:2.4.1' +// compile 'joda-time:joda-time:2.7' + + testCompile 'junit:junit:4.12', + 'org.hamcrest:hamcrest-core:1.3' +} + +sourceSets { + main { + java { + srcDir 'src/gen/java' + } + } +} diff --git a/samples/server/petstore/jaxrs-resteasy/pom.xml b/samples/server/petstore/jaxrs-resteasy/pom.xml new file mode 100644 index 00000000000..7b27de2594f --- /dev/null +++ b/samples/server/petstore/jaxrs-resteasy/pom.xml @@ -0,0 +1,155 @@ + + 4.0.0 + io.swagger + swagger-jaxrs-resteasy-server + war + swagger-jaxrs-resteasy-server + 1.0.0 + + src/main/java + + + org.apache.maven.plugins + maven-war-plugin + 2.1.1 + + + maven-failsafe-plugin + 2.6 + + + + integration-test + verify + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.9.1 + + + add-source + generate-sources + + add-source + + + + + src/gen/java + + + + + + + + + + org.slf4j + slf4j-log4j12 + ${slf4j-version} + + + javax.servlet + servlet-api + ${servlet-api-version} + provided + + + + org.jboss.resteasy + resteasy-jaxrs + ${resteasy-version} + provided + + + org.jboss.resteasy + jaxrs-api + ${resteasy-version} + provided + + + org.jboss.resteasy + resteasy-validator-provider-11 + ${resteasy-version} + provided + + + org.jboss.resteasy + resteasy-multipart-provider + ${resteasy-version} + provided + + + org.jboss.resteasy + resteasy-jackson2-provider + ${resteasy-version} + + + javax.annotation + javax.annotation-api + 1.2 + provided + + + + com.fasterxml.jackson.datatype + jackson-datatype-joda + 2.4.1 + + + joda-time + joda-time + 2.7 + + + + junit + junit + ${junit-version} + test + + + org.testng + testng + 6.8.8 + test + + + junit + junit + + + snakeyaml + org.yaml + + + bsh + org.beanshell + + + + + + + sonatype-snapshots + https://oss.sonatype.org/content/repositories/snapshots + + true + + + + + 1.5.4 + 9.2.9.v20150224 + 3.0.11.Final + 1.6.3 + 4.8.1 + 2.5 + + \ No newline at end of file diff --git a/samples/server/petstore/jaxrs-resteasy/settings.gradle b/samples/server/petstore/jaxrs-resteasy/settings.gradle new file mode 100644 index 00000000000..6392b5011e0 --- /dev/null +++ b/samples/server/petstore/jaxrs-resteasy/settings.gradle @@ -0,0 +1 @@ +rootProject.name = "swagger-jaxrs-resteasy-server" \ No newline at end of file diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiException.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiException.java new file mode 100644 index 00000000000..98c42b54565 --- /dev/null +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiException.java @@ -0,0 +1,10 @@ +package io.swagger.api; + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-02-04T01:58:20.368+07:00") +public class ApiException extends Exception{ + private int code; + public ApiException (int code, String msg) { + super(msg); + this.code = code; + } +} diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiOriginFilter.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiOriginFilter.java new file mode 100644 index 00000000000..80cf57bb0b3 --- /dev/null +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiOriginFilter.java @@ -0,0 +1,22 @@ +package io.swagger.api; + +import java.io.IOException; + +import javax.servlet.*; +import javax.servlet.http.HttpServletResponse; + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-02-04T01:58:20.368+07:00") +public class ApiOriginFilter implements javax.servlet.Filter { + public void doFilter(ServletRequest request, ServletResponse response, + FilterChain chain) throws IOException, ServletException { + HttpServletResponse res = (HttpServletResponse) response; + res.addHeader("Access-Control-Allow-Origin", "*"); + res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT"); + res.addHeader("Access-Control-Allow-Headers", "Content-Type"); + chain.doFilter(request, response); + } + + public void destroy() {} + + public void init(FilterConfig filterConfig) throws ServletException {} +} \ No newline at end of file diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiResponseMessage.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiResponseMessage.java new file mode 100644 index 00000000000..06f9706c04b --- /dev/null +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiResponseMessage.java @@ -0,0 +1,69 @@ +package io.swagger.api; + +import javax.xml.bind.annotation.XmlTransient; + +@javax.xml.bind.annotation.XmlRootElement +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-02-04T01:58:20.368+07:00") +public class ApiResponseMessage { + public static final int ERROR = 1; + public static final int WARNING = 2; + public static final int INFO = 3; + public static final int OK = 4; + public static final int TOO_BUSY = 5; + + int code; + String type; + String message; + + public ApiResponseMessage(){} + + public ApiResponseMessage(int code, String message){ + this.code = code; + switch(code){ + case ERROR: + setType("error"); + break; + case WARNING: + setType("warning"); + break; + case INFO: + setType("info"); + break; + case OK: + setType("ok"); + break; + case TOO_BUSY: + setType("too busy"); + break; + default: + setType("unknown"); + break; + } + this.message = message; + } + + @XmlTransient + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/NotFoundException.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/NotFoundException.java new file mode 100644 index 00000000000..6b3581fa559 --- /dev/null +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/NotFoundException.java @@ -0,0 +1,10 @@ +package io.swagger.api; + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-02-04T01:58:20.368+07:00") +public class NotFoundException extends ApiException { + private int code; + public NotFoundException (int code, String msg) { + super(code, msg); + this.code = code; + } +} diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PetApi.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PetApi.java new file mode 100644 index 00000000000..c87f9f8e25f --- /dev/null +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PetApi.java @@ -0,0 +1,113 @@ +package io.swagger.api; + +import io.swagger.model.*; +import io.swagger.api.PetApiService; +import io.swagger.api.factories.PetApiServiceFactory; + +import io.swagger.model.Pet; +import java.io.File; + + +import java.util.List; +import io.swagger.api.NotFoundException; + +import java.io.InputStream; + +import javax.ws.rs.core.Context; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.SecurityContext; +import javax.ws.rs.*; +import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput; + +@Path("/pet") + + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-02-04T01:58:20.368+07:00") + +public class PetApi { + private final PetApiService delegate = PetApiServiceFactory.getPetApi(); + + + @PUT + + @Consumes({ "application/json", "application/xml" }) + @Produces({ "application/json", "application/xml" }) + public Response updatePet( Pet body,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.updatePet(body,securityContext); + } + + @POST + + @Consumes({ "application/json", "application/xml" }) + @Produces({ "application/json", "application/xml" }) + public Response addPet( Pet body,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.addPet(body,securityContext); + } + + @GET + @Path("/findByStatus") + + @Produces({ "application/json", "application/xml" }) + public Response findPetsByStatus( @QueryParam("status") List status,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.findPetsByStatus(status,securityContext); + } + + @GET + @Path("/findByTags") + + @Produces({ "application/json", "application/xml" }) + public Response findPetsByTags( @QueryParam("tags") List tags,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.findPetsByTags(tags,securityContext); + } + + @GET + @Path("/{petId}") + + @Produces({ "application/json", "application/xml" }) + public Response getPetById( @PathParam("petId") Long petId,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.getPetById(petId,securityContext); + } + + @POST + @Path("/{petId}") + @Consumes({ "application/x-www-form-urlencoded" }) + @Produces({ "application/json", "application/xml" }) + public Response updatePetWithForm( @PathParam("petId") String petId,@FormParam("name") String name,@FormParam("status") String status,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.updatePetWithForm(petId,name,status,securityContext); + } + + @DELETE + @Path("/{petId}") + + @Produces({ "application/json", "application/xml" }) + public Response deletePet( @PathParam("petId") Long petId,@HeaderParam("api_key") String apiKey,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.deletePet(petId,apiKey,securityContext); + } + + @POST + @Path("/{petId}/uploadImage") + @Consumes({ "multipart/form-data" }) + @Produces({ "application/json", "application/xml" }) + public Response uploadFile(MultipartFormDataInput input, @PathParam("petId") Long petId,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.uploadFile(input,petId,securityContext); + } + + @GET + @Path("/{petId}?testing_byte_array=true") + + @Produces({ "application/json", "application/xml" }) + public Response getPetByIdWithByteArray( @PathParam("petId") Long petId,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.getPetByIdWithByteArray(petId,securityContext); + } + +} + diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PetApiService.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PetApiService.java new file mode 100644 index 00000000000..485ef63212a --- /dev/null +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PetApiService.java @@ -0,0 +1,52 @@ +package io.swagger.api; + +import io.swagger.api.*; +import io.swagger.model.*; +import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput; + + +import io.swagger.model.Pet; +import java.io.File; + + +import java.util.List; +import io.swagger.api.NotFoundException; + +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.JavaResteasyServerCodegen", date = "2016-02-04T01:58:20.368+07:00") + +public abstract class PetApiService { + + public abstract Response updatePet(Pet body,SecurityContext securityContext) + throws NotFoundException; + + public abstract Response addPet(Pet body,SecurityContext securityContext) + throws NotFoundException; + + public abstract Response findPetsByStatus(List status,SecurityContext securityContext) + throws NotFoundException; + + public abstract Response findPetsByTags(List tags,SecurityContext securityContext) + throws NotFoundException; + + public abstract Response getPetById(Long petId,SecurityContext securityContext) + throws NotFoundException; + + public abstract Response updatePetWithForm(String petId,String name,String status,SecurityContext securityContext) + throws NotFoundException; + + public abstract Response deletePet(Long petId,String apiKey,SecurityContext securityContext) + throws NotFoundException; + + public abstract Response uploadFile(MultipartFormDataInput input,Long petId,SecurityContext securityContext) + throws NotFoundException; + + public abstract Response getPetByIdWithByteArray(Long petId,SecurityContext securityContext) + throws NotFoundException; + +} + diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PettestingByteArraytrueApi.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PettestingByteArraytrueApi.java new file mode 100644 index 00000000000..e85fcfbe42c --- /dev/null +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PettestingByteArraytrueApi.java @@ -0,0 +1,38 @@ +package io.swagger.api; + +import io.swagger.model.*; +import io.swagger.api.PettestingByteArraytrueApiService; +import io.swagger.api.factories.PettestingByteArraytrueApiServiceFactory; + + + +import java.util.List; +import io.swagger.api.NotFoundException; + +import java.io.InputStream; + +import javax.ws.rs.core.Context; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.SecurityContext; +import javax.ws.rs.*; + +@Path("/pet?testing_byte_array=true") + + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-02-04T01:58:20.368+07:00") + +public class PettestingByteArraytrueApi { + private final PettestingByteArraytrueApiService delegate = PettestingByteArraytrueApiServiceFactory.getPettestingByteArraytrueApi(); + + + @POST + + @Consumes({ "application/json", "application/xml" }) + @Produces({ "application/json", "application/xml" }) + public Response addPetUsingByteArray( byte[] body,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.addPetUsingByteArray(body,securityContext); + } + +} + diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PettestingByteArraytrueApiService.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PettestingByteArraytrueApiService.java new file mode 100644 index 00000000000..553cf5743e4 --- /dev/null +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PettestingByteArraytrueApiService.java @@ -0,0 +1,25 @@ +package io.swagger.api; + +import io.swagger.api.*; +import io.swagger.model.*; + + + + +import java.util.List; +import io.swagger.api.NotFoundException; + +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.JavaResteasyServerCodegen", date = "2016-02-04T01:58:20.368+07:00") + +public abstract class PettestingByteArraytrueApiService { + + public abstract Response addPetUsingByteArray(byte[] body,SecurityContext securityContext) + throws NotFoundException; + +} + diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/RestApplication.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/RestApplication.java new file mode 100644 index 00000000000..24aa63ce824 --- /dev/null +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/RestApplication.java @@ -0,0 +1,9 @@ +package io.swagger.api; + +import javax.ws.rs.ApplicationPath; +import javax.ws.rs.core.Application; + +@ApplicationPath("/") +public class RestApplication extends Application { + +} \ No newline at end of file diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StoreApi.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StoreApi.java new file mode 100644 index 00000000000..52f513318c8 --- /dev/null +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StoreApi.java @@ -0,0 +1,67 @@ +package io.swagger.api; + +import io.swagger.model.*; +import io.swagger.api.StoreApiService; +import io.swagger.api.factories.StoreApiServiceFactory; + +import java.util.Map; +import io.swagger.model.Order; + + +import java.util.List; +import io.swagger.api.NotFoundException; + +import java.io.InputStream; + +import javax.ws.rs.core.Context; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.SecurityContext; +import javax.ws.rs.*; + +@Path("/store") + + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-02-04T01:58:20.368+07:00") + +public class StoreApi { + private final StoreApiService delegate = StoreApiServiceFactory.getStoreApi(); + + + @GET + @Path("/inventory") + + @Produces({ "application/json", "application/xml" }) + public Response getInventory(@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.getInventory(securityContext); + } + + @POST + @Path("/order") + + @Produces({ "application/json", "application/xml" }) + public Response placeOrder( Order body,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.placeOrder(body,securityContext); + } + + @GET + @Path("/order/{orderId}") + + @Produces({ "application/json", "application/xml" }) + public Response getOrderById( @PathParam("orderId") String orderId,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.getOrderById(orderId,securityContext); + } + + @DELETE + @Path("/order/{orderId}") + + @Produces({ "application/json", "application/xml" }) + public Response deleteOrder( @PathParam("orderId") String orderId,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.deleteOrder(orderId,securityContext); + } + +} + diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StoreApiService.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StoreApiService.java new file mode 100644 index 00000000000..f0857c1cab6 --- /dev/null +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StoreApiService.java @@ -0,0 +1,36 @@ +package io.swagger.api; + +import io.swagger.api.*; +import io.swagger.model.*; + + +import java.util.Map; +import io.swagger.model.Order; + + +import java.util.List; +import io.swagger.api.NotFoundException; + +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.JavaResteasyServerCodegen", date = "2016-02-04T01:58:20.368+07:00") + +public abstract class StoreApiService { + + public abstract Response getInventory(SecurityContext securityContext) + throws NotFoundException; + + public abstract Response placeOrder(Order body,SecurityContext securityContext) + throws NotFoundException; + + public abstract Response getOrderById(String orderId,SecurityContext securityContext) + throws NotFoundException; + + public abstract Response deleteOrder(String orderId,SecurityContext securityContext) + throws NotFoundException; + +} + diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StringUtil.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StringUtil.java new file mode 100644 index 00000000000..2747ff81082 --- /dev/null +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StringUtil.java @@ -0,0 +1,42 @@ +package io.swagger.api; + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-02-04T01:58:20.368+07:00") +public class StringUtil { + /** + * Check if the given array contains the given value (with case-insensitive comparison). + * + * @param array The array + * @param value The value to search + * @return true if the array contains the value + */ + public static boolean containsIgnoreCase(String[] array, String value) { + for (String str : array) { + if (value == null && str == null) return true; + if (value != null && value.equalsIgnoreCase(str)) return true; + } + return false; + } + + /** + * Join an array of strings with the given separator. + *

+ * Note: This might be replaced by utility method from commons-lang or guava someday + * if one of those libraries is added as dependency. + *

+ * + * @param array The array of strings + * @param separator The separator + * @return the resulting string + */ + public static String join(String[] array, String separator) { + int len = array.length; + if (len == 0) return ""; + + StringBuilder out = new StringBuilder(); + out.append(array[0]); + for (int i = 1; i < len; i++) { + out.append(separator).append(array[i]); + } + return out.toString(); + } +} diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/UserApi.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/UserApi.java new file mode 100644 index 00000000000..2841e06a7d7 --- /dev/null +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/UserApi.java @@ -0,0 +1,103 @@ +package io.swagger.api; + +import io.swagger.model.*; +import io.swagger.api.UserApiService; +import io.swagger.api.factories.UserApiServiceFactory; + +import io.swagger.model.User; +import java.util.*; + + +import java.util.List; +import io.swagger.api.NotFoundException; + +import java.io.InputStream; + +import javax.ws.rs.core.Context; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.SecurityContext; +import javax.ws.rs.*; + +@Path("/user") + + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-02-04T01:58:20.368+07:00") + +public class UserApi { + private final UserApiService delegate = UserApiServiceFactory.getUserApi(); + + + @POST + + + @Produces({ "application/json", "application/xml" }) + public Response createUser( User body,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.createUser(body,securityContext); + } + + @POST + @Path("/createWithArray") + + @Produces({ "application/json", "application/xml" }) + public Response createUsersWithArrayInput( List body,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.createUsersWithArrayInput(body,securityContext); + } + + @POST + @Path("/createWithList") + + @Produces({ "application/json", "application/xml" }) + public Response createUsersWithListInput( List body,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.createUsersWithListInput(body,securityContext); + } + + @GET + @Path("/login") + + @Produces({ "application/json", "application/xml" }) + public Response loginUser( @QueryParam("username") String username, @QueryParam("password") String password,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.loginUser(username,password,securityContext); + } + + @GET + @Path("/logout") + + @Produces({ "application/json", "application/xml" }) + public Response logoutUser(@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.logoutUser(securityContext); + } + + @GET + @Path("/{username}") + + @Produces({ "application/json", "application/xml" }) + public Response getUserByName( @PathParam("username") String username,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.getUserByName(username,securityContext); + } + + @PUT + @Path("/{username}") + + @Produces({ "application/json", "application/xml" }) + public Response updateUser( @PathParam("username") String username, User body,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.updateUser(username,body,securityContext); + } + + @DELETE + @Path("/{username}") + + @Produces({ "application/json", "application/xml" }) + public Response deleteUser( @PathParam("username") String username,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.deleteUser(username,securityContext); + } + +} + diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/UserApiService.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/UserApiService.java new file mode 100644 index 00000000000..09ac506294a --- /dev/null +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/UserApiService.java @@ -0,0 +1,48 @@ +package io.swagger.api; + +import io.swagger.api.*; +import io.swagger.model.*; + + +import io.swagger.model.User; +import java.util.*; + + +import java.util.List; +import io.swagger.api.NotFoundException; + +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.JavaResteasyServerCodegen", date = "2016-02-04T01:58:20.368+07:00") + +public abstract class UserApiService { + + public abstract Response createUser(User body,SecurityContext securityContext) + throws NotFoundException; + + public abstract Response createUsersWithArrayInput(List body,SecurityContext securityContext) + throws NotFoundException; + + public abstract Response createUsersWithListInput(List body,SecurityContext securityContext) + throws NotFoundException; + + public abstract Response loginUser(String username,String password,SecurityContext securityContext) + throws NotFoundException; + + public abstract Response logoutUser(SecurityContext securityContext) + throws NotFoundException; + + public abstract Response getUserByName(String username,SecurityContext securityContext) + throws NotFoundException; + + public abstract Response updateUser(String username,User body,SecurityContext securityContext) + throws NotFoundException; + + public abstract Response deleteUser(String username,SecurityContext securityContext) + throws NotFoundException; + +} + diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Category.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Category.java new file mode 100644 index 00000000000..473b212ab2e --- /dev/null +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Category.java @@ -0,0 +1,86 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; + + + + + + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-02-04T01:58:20.368+07:00") +public class Category { + + private Long id = null; + private String name = null; + + + /** + **/ + + @JsonProperty("id") + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + + + /** + **/ + + @JsonProperty("name") + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + + + @Override + public 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-resteasy/src/gen/java/io/swagger/model/Order.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Order.java new file mode 100644 index 00000000000..acd23dfd33c --- /dev/null +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Order.java @@ -0,0 +1,168 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Date; + + + + + + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-02-04T01:58:20.368+07:00") +public class Order { + + private Long id = null; + private Long petId = null; + private Integer quantity = null; + private Date shipDate = null; + + + public enum StatusEnum { + PLACED("placed"), + APPROVED("approved"), + DELIVERED("delivered"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @Override + @JsonValue + public String toString() { + return value; + } + } + + private StatusEnum status = null; + private Boolean complete = null; + + + /** + **/ + + @JsonProperty("id") + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + + + /** + **/ + + @JsonProperty("petId") + public Long getPetId() { + return petId; + } + public void setPetId(Long petId) { + this.petId = petId; + } + + + /** + **/ + + @JsonProperty("quantity") + public Integer getQuantity() { + return quantity; + } + public void setQuantity(Integer quantity) { + this.quantity = quantity; + } + + + /** + **/ + + @JsonProperty("shipDate") + public Date getShipDate() { + return shipDate; + } + public void setShipDate(Date shipDate) { + this.shipDate = shipDate; + } + + + /** + * Order Status + **/ + + @JsonProperty("status") + public StatusEnum getStatus() { + return status; + } + public void setStatus(StatusEnum status) { + this.status = status; + } + + + /** + **/ + + @JsonProperty("complete") + public Boolean getComplete() { + return complete; + } + public void setComplete(Boolean complete) { + this.complete = complete; + } + + + + @Override + public 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-resteasy/src/gen/java/io/swagger/model/Pet.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Pet.java new file mode 100644 index 00000000000..efc60c75bbe --- /dev/null +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Pet.java @@ -0,0 +1,170 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.model.Category; +import io.swagger.model.Tag; +import java.util.*; + + + + + + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-02-04T01:58:20.368+07:00") +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("available"), + PENDING("pending"), + SOLD("sold"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @Override + @JsonValue + public String toString() { + return value; + } + } + + private StatusEnum status = null; + + + /** + **/ + + @JsonProperty("id") + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + + + /** + **/ + + @JsonProperty("category") + public Category getCategory() { + return category; + } + public void setCategory(Category category) { + this.category = category; + } + + + /** + **/ + + @JsonProperty("name") + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + + /** + **/ + + @JsonProperty("photoUrls") + public List getPhotoUrls() { + return photoUrls; + } + public void setPhotoUrls(List photoUrls) { + this.photoUrls = photoUrls; + } + + + /** + **/ + + @JsonProperty("tags") + public List getTags() { + return tags; + } + public void setTags(List tags) { + this.tags = tags; + } + + + /** + * pet status in the store + **/ + + @JsonProperty("status") + public StatusEnum getStatus() { + return status; + } + public void setStatus(StatusEnum status) { + this.status = status; + } + + + + @Override + public 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-resteasy/src/gen/java/io/swagger/model/Tag.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Tag.java new file mode 100644 index 00000000000..e3756279b4d --- /dev/null +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Tag.java @@ -0,0 +1,86 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; + + + + + + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-02-04T01:58:20.368+07:00") +public class Tag { + + private Long id = null; + private String name = null; + + + /** + **/ + + @JsonProperty("id") + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + + + /** + **/ + + @JsonProperty("name") + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + + + @Override + public 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-resteasy/src/gen/java/io/swagger/model/User.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/User.java new file mode 100644 index 00000000000..1df990a8163 --- /dev/null +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/User.java @@ -0,0 +1,177 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; + + + + + + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-02-04T01:58:20.368+07:00") +public class User { + + private Long id = null; + private String username = null; + private String firstName = null; + private String lastName = null; + private String email = null; + private String password = null; + private String phone = null; + private Integer userStatus = null; + + + /** + **/ + + @JsonProperty("id") + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + + + /** + **/ + + @JsonProperty("username") + public String getUsername() { + return username; + } + public void setUsername(String username) { + this.username = username; + } + + + /** + **/ + + @JsonProperty("firstName") + public String getFirstName() { + return firstName; + } + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + + /** + **/ + + @JsonProperty("lastName") + public String getLastName() { + return lastName; + } + public void setLastName(String lastName) { + this.lastName = lastName; + } + + + /** + **/ + + @JsonProperty("email") + public String getEmail() { + return email; + } + public void setEmail(String email) { + this.email = email; + } + + + /** + **/ + + @JsonProperty("password") + public String getPassword() { + return password; + } + public void setPassword(String password) { + this.password = password; + } + + + /** + **/ + + @JsonProperty("phone") + public String getPhone() { + return phone; + } + public void setPhone(String phone) { + this.phone = phone; + } + + + /** + * User Status + **/ + + @JsonProperty("userStatus") + public Integer getUserStatus() { + return userStatus; + } + public void setUserStatus(Integer userStatus) { + this.userStatus = userStatus; + } + + + + @Override + public 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-resteasy/src/main/java/io/swagger/api/factories/PetApiServiceFactory.java b/samples/server/petstore/jaxrs-resteasy/src/main/java/io/swagger/api/factories/PetApiServiceFactory.java new file mode 100644 index 00000000000..5b59c799d83 --- /dev/null +++ b/samples/server/petstore/jaxrs-resteasy/src/main/java/io/swagger/api/factories/PetApiServiceFactory.java @@ -0,0 +1,15 @@ +package io.swagger.api.factories; + +import io.swagger.api.PetApiService; +import io.swagger.api.impl.PetApiServiceImpl; + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-02-04T01:58:20.368+07:00") +public class PetApiServiceFactory { + + private final static PetApiService service = new PetApiServiceImpl(); + + public static PetApiService getPetApi() + { + return service; + } +} diff --git a/samples/server/petstore/jaxrs-resteasy/src/main/java/io/swagger/api/factories/PettestingByteArraytrueApiServiceFactory.java b/samples/server/petstore/jaxrs-resteasy/src/main/java/io/swagger/api/factories/PettestingByteArraytrueApiServiceFactory.java new file mode 100644 index 00000000000..42f4715fad4 --- /dev/null +++ b/samples/server/petstore/jaxrs-resteasy/src/main/java/io/swagger/api/factories/PettestingByteArraytrueApiServiceFactory.java @@ -0,0 +1,15 @@ +package io.swagger.api.factories; + +import io.swagger.api.PettestingByteArraytrueApiService; +import io.swagger.api.impl.PettestingByteArraytrueApiServiceImpl; + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-02-04T01:58:20.368+07:00") +public class PettestingByteArraytrueApiServiceFactory { + + private final static PettestingByteArraytrueApiService service = new PettestingByteArraytrueApiServiceImpl(); + + public static PettestingByteArraytrueApiService getPettestingByteArraytrueApi() + { + return service; + } +} diff --git a/samples/server/petstore/jaxrs-resteasy/src/main/java/io/swagger/api/factories/StoreApiServiceFactory.java b/samples/server/petstore/jaxrs-resteasy/src/main/java/io/swagger/api/factories/StoreApiServiceFactory.java new file mode 100644 index 00000000000..d24f09ed8fc --- /dev/null +++ b/samples/server/petstore/jaxrs-resteasy/src/main/java/io/swagger/api/factories/StoreApiServiceFactory.java @@ -0,0 +1,15 @@ +package io.swagger.api.factories; + +import io.swagger.api.StoreApiService; +import io.swagger.api.impl.StoreApiServiceImpl; + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-02-04T01:58:20.368+07:00") +public class StoreApiServiceFactory { + + private final static StoreApiService service = new StoreApiServiceImpl(); + + public static StoreApiService getStoreApi() + { + return service; + } +} diff --git a/samples/server/petstore/jaxrs-resteasy/src/main/java/io/swagger/api/factories/UserApiServiceFactory.java b/samples/server/petstore/jaxrs-resteasy/src/main/java/io/swagger/api/factories/UserApiServiceFactory.java new file mode 100644 index 00000000000..8a976ccd354 --- /dev/null +++ b/samples/server/petstore/jaxrs-resteasy/src/main/java/io/swagger/api/factories/UserApiServiceFactory.java @@ -0,0 +1,15 @@ +package io.swagger.api.factories; + +import io.swagger.api.UserApiService; +import io.swagger.api.impl.UserApiServiceImpl; + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-02-04T01:58:20.368+07:00") +public class UserApiServiceFactory { + + private final static UserApiService service = new UserApiServiceImpl(); + + public static UserApiService getUserApi() + { + return service; + } +} diff --git a/samples/server/petstore/jaxrs-resteasy/src/main/java/io/swagger/api/impl/PetApiServiceImpl.java b/samples/server/petstore/jaxrs-resteasy/src/main/java/io/swagger/api/impl/PetApiServiceImpl.java new file mode 100644 index 00000000000..9657e9b17cc --- /dev/null +++ b/samples/server/petstore/jaxrs-resteasy/src/main/java/io/swagger/api/impl/PetApiServiceImpl.java @@ -0,0 +1,88 @@ +package io.swagger.api.impl; + +import io.swagger.api.*; +import io.swagger.model.*; +import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput; + + +import io.swagger.model.Pet; +import java.io.File; + + +import java.util.List; +import io.swagger.api.NotFoundException; + +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.JavaResteasyServerCodegen", date = "2016-02-04T01:58:20.368+07:00") + +public class PetApiServiceImpl extends PetApiService { + + @Override + public Response updatePet(Pet body,SecurityContext securityContext) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response addPet(Pet body,SecurityContext securityContext) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response findPetsByStatus(List status,SecurityContext securityContext) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response findPetsByTags(List tags,SecurityContext securityContext) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response getPetById(Long petId,SecurityContext securityContext) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response updatePetWithForm(String petId,String name,String status,SecurityContext securityContext) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response deletePet(Long petId,String apiKey,SecurityContext securityContext) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response uploadFile(MultipartFormDataInput input,Long petId,SecurityContext securityContext) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response getPetByIdWithByteArray(Long petId,SecurityContext securityContext) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + +} + diff --git a/samples/server/petstore/jaxrs-resteasy/src/main/java/io/swagger/api/impl/PettestingByteArraytrueApiServiceImpl.java b/samples/server/petstore/jaxrs-resteasy/src/main/java/io/swagger/api/impl/PettestingByteArraytrueApiServiceImpl.java new file mode 100644 index 00000000000..5a3c2519b03 --- /dev/null +++ b/samples/server/petstore/jaxrs-resteasy/src/main/java/io/swagger/api/impl/PettestingByteArraytrueApiServiceImpl.java @@ -0,0 +1,29 @@ +package io.swagger.api.impl; + +import io.swagger.api.*; +import io.swagger.model.*; + + + + +import java.util.List; +import io.swagger.api.NotFoundException; + +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.JavaResteasyServerCodegen", date = "2016-02-04T01:58:20.368+07:00") + +public class PettestingByteArraytrueApiServiceImpl extends PettestingByteArraytrueApiService { + + @Override + public Response addPetUsingByteArray(byte[] body,SecurityContext securityContext) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + +} + diff --git a/samples/server/petstore/jaxrs-resteasy/src/main/java/io/swagger/api/impl/StoreApiServiceImpl.java b/samples/server/petstore/jaxrs-resteasy/src/main/java/io/swagger/api/impl/StoreApiServiceImpl.java new file mode 100644 index 00000000000..f8538681c49 --- /dev/null +++ b/samples/server/petstore/jaxrs-resteasy/src/main/java/io/swagger/api/impl/StoreApiServiceImpl.java @@ -0,0 +1,52 @@ +package io.swagger.api.impl; + +import io.swagger.api.*; +import io.swagger.model.*; + + +import java.util.Map; +import io.swagger.model.Order; + + +import java.util.List; +import io.swagger.api.NotFoundException; + +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.JavaResteasyServerCodegen", date = "2016-02-04T01:58:20.368+07:00") + +public class StoreApiServiceImpl extends StoreApiService { + + @Override + public Response getInventory(SecurityContext securityContext) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response placeOrder(Order body,SecurityContext securityContext) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response getOrderById(String orderId,SecurityContext securityContext) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response deleteOrder(String orderId,SecurityContext securityContext) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + +} + diff --git a/samples/server/petstore/jaxrs-resteasy/src/main/java/io/swagger/api/impl/UserApiServiceImpl.java b/samples/server/petstore/jaxrs-resteasy/src/main/java/io/swagger/api/impl/UserApiServiceImpl.java new file mode 100644 index 00000000000..2640ecd3121 --- /dev/null +++ b/samples/server/petstore/jaxrs-resteasy/src/main/java/io/swagger/api/impl/UserApiServiceImpl.java @@ -0,0 +1,80 @@ +package io.swagger.api.impl; + +import io.swagger.api.*; +import io.swagger.model.*; + + +import io.swagger.model.User; +import java.util.*; + + +import java.util.List; +import io.swagger.api.NotFoundException; + +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.JavaResteasyServerCodegen", date = "2016-02-04T01:58:20.368+07:00") + +public class UserApiServiceImpl extends UserApiService { + + @Override + public Response createUser(User body,SecurityContext securityContext) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response createUsersWithArrayInput(List body,SecurityContext securityContext) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response createUsersWithListInput(List body,SecurityContext securityContext) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response loginUser(String username,String password,SecurityContext securityContext) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response logoutUser(SecurityContext securityContext) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response getUserByName(String username,SecurityContext securityContext) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response updateUser(String username,User body,SecurityContext securityContext) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response deleteUser(String username,SecurityContext securityContext) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + +} + diff --git a/samples/server/petstore/jaxrs-resteasy/src/main/webapp/WEB-INF/jboss-web.xml b/samples/server/petstore/jaxrs-resteasy/src/main/webapp/WEB-INF/jboss-web.xml new file mode 100644 index 00000000000..9c05ed07b78 --- /dev/null +++ b/samples/server/petstore/jaxrs-resteasy/src/main/webapp/WEB-INF/jboss-web.xml @@ -0,0 +1,3 @@ + + /v2 + \ No newline at end of file diff --git a/samples/server/petstore/jaxrs-resteasy/src/main/webapp/WEB-INF/web.xml b/samples/server/petstore/jaxrs-resteasy/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 00000000000..52a89e92132 --- /dev/null +++ b/samples/server/petstore/jaxrs-resteasy/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,14 @@ + + + + + ApiOriginFilter + io.swagger.api.ApiOriginFilter + + + ApiOriginFilter + /* + +