diff --git a/CI/pom.xml.circleci b/CI/pom.xml.circleci index b5dd34e4c9c..26296c47b1d 100644 --- a/CI/pom.xml.circleci +++ b/CI/pom.xml.circleci @@ -607,6 +607,19 @@ samples/server/petstore/jaxrs/jersey1 + + + jaxrs-jersey + + + env + java + + + + samples/server/petstore/jaxrs-jersey + + jaxrs-spec @@ -898,6 +911,7 @@ samples/client/petstore/kotlin-threetenbp/ samples/client/petstore/kotlin-string/ + samples/server/petstore/jaxrs-jersey samples/server/petstore/jaxrs-spec samples/server/petstore/jaxrs-spec-interface samples/server/petstore/jaxrs-spec-interface-response diff --git a/CI/pom.xml.circleci.java7 b/CI/pom.xml.circleci.java7 index ef34a78f420..56e6688a965 100644 --- a/CI/pom.xml.circleci.java7 +++ b/CI/pom.xml.circleci.java7 @@ -607,6 +607,19 @@ samples/server/petstore/jaxrs/jersey1 + + + jaxrs-jersey + + + env + java + + + + samples/server/petstore/jaxrs-jersey + + jaxrs-spec @@ -889,6 +902,7 @@ samples/client/petstore/java/google-api-client samples/client/petstore/kotlin/ + samples/server/petstore/jaxrs-jersey samples/server/petstore/jaxrs-spec samples/server/petstore/jaxrs-spec-interface samples/server/petstore/jaxrs-spec-interface-response diff --git a/bin/openapi3/jaxrs-jersey-petstore.sh b/bin/openapi3/jaxrs-jersey-petstore.sh new file mode 100644 index 00000000000..86487d172cc --- /dev/null +++ b/bin/openapi3/jaxrs-jersey-petstore.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +SCRIPT="$0" +echo "# START SCRIPT: $SCRIPT" + +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/openapi-generator-cli/target/openapi-generator-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 --artifact-id "openapiv3-jaxrs-jersey-petstore-server" -t modules/openapi-generator/src/main/resources/JavaJaxRS/ -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g jaxrs-jersey -o samples/server/petstore/jaxrs-jersey $@" + +java $JAVA_OPTS -jar $executable $ags diff --git a/pom.xml b/pom.xml index e30cd436b89..6756c1923d4 100644 --- a/pom.xml +++ b/pom.xml @@ -715,6 +715,19 @@ samples/server/petstore/jaxrs/jersey1 + + + jaxrs-jersey + + + env + java + + + + samples/server/petstore/jaxrs-jersey + + jaxrs-spec diff --git a/samples/server/petstore/jaxrs-jersey/.openapi-generator-ignore b/samples/server/petstore/jaxrs-jersey/.openapi-generator-ignore new file mode 100644 index 00000000000..7484ee590a3 --- /dev/null +++ b/samples/server/petstore/jaxrs-jersey/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/server/petstore/jaxrs-jersey/.openapi-generator/VERSION b/samples/server/petstore/jaxrs-jersey/.openapi-generator/VERSION new file mode 100644 index 00000000000..14900cee60e --- /dev/null +++ b/samples/server/petstore/jaxrs-jersey/.openapi-generator/VERSION @@ -0,0 +1 @@ +3.2.1-SNAPSHOT \ No newline at end of file diff --git a/samples/server/petstore/jaxrs-jersey/README.md b/samples/server/petstore/jaxrs-jersey/README.md new file mode 100644 index 00000000000..ed004204491 --- /dev/null +++ b/samples/server/petstore/jaxrs-jersey/README.md @@ -0,0 +1,23 @@ +# Swagger Jersey generated server + +## Overview +This server was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the +[OpenAPI-Spec](https://openapis.org) from a remote server, you can easily generate a server stub. This +is an example of building a OpenAPI-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/openapi.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-jersey/pom.xml b/samples/server/petstore/jaxrs-jersey/pom.xml new file mode 100644 index 00000000000..973329638f0 --- /dev/null +++ b/samples/server/petstore/jaxrs-jersey/pom.xml @@ -0,0 +1,193 @@ + + 4.0.0 + org.openapitools + openapiv3-jaxrs-jersey-petstore-server + jar + openapiv3-jaxrs-jersey-petstore-server + 1.0.0 + + + + Unlicense + http://www.apache.org/licenses/LICENSE-2.0.html + repo + + + + + src/main/java + + + org.apache.maven.plugins + maven-war-plugin + 3.1.0 + + + maven-failsafe-plugin + 2.6 + + + + integration-test + verify + + + + + + org.eclipse.jetty + jetty-maven-plugin + ${jetty-version} + + + / + + target/${project.artifactId}-${project.version} + 8079 + stopit + 10 + + 8080 + 60000 + + + + + javax.validation + validation-api + ${beanvalidation-version} + + + + + start-jetty + pre-integration-test + + start + + + 0 + true + + + + stop-jetty + post-integration-test + + stop + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.9.1 + + + add-source + generate-sources + + add-source + + + + src/gen/java + + + + + + + + + + io.swagger + swagger-jersey2-jaxrs + compile + ${swagger-core-version} + + + ch.qos.logback + logback-classic + ${logback-version} + compile + + + ch.qos.logback + logback-core + ${logback-version} + compile + + + junit + junit + ${junit-version} + test + + + javax.servlet + servlet-api + ${servlet-api-version} + + + org.glassfish.jersey.containers + jersey-container-servlet-core + ${jersey2-version} + + + org.glassfish.jersey.media + jersey-media-multipart + ${jersey2-version} + + + com.fasterxml.jackson.datatype + jackson-datatype-joda + ${jackson-version} + + + com.fasterxml.jackson.jaxrs + jackson-jaxrs-json-provider + ${jackson-version} + + + + com.brsanthu + migbase64 + 2.2 + + + + + + javax.validation + validation-api + ${beanvalidation-version} + provided + + + + + + sonatype-snapshots + https://oss.sonatype.org/content/repositories/snapshots + + true + + + + + 1.7 + ${java.version} + ${java.version} + 1.5.18 + 1.1.0.Final + 9.2.9.v20150224 + 2.22.2 + 2.8.9 + 4.12 + 1.1.7 + 2.5 + UTF-8 + + diff --git a/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/ApiException.java b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/ApiException.java new file mode 100644 index 00000000000..2d2990bc7f0 --- /dev/null +++ b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/ApiException.java @@ -0,0 +1,10 @@ +package org.openapitools.api; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", date = "2018-08-10T15:02:11.723+09:00[Asia/Tokyo]") +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-jersey/src/gen/java/org/openapitools/api/ApiOriginFilter.java b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/ApiOriginFilter.java new file mode 100644 index 00000000000..96f2e348300 --- /dev/null +++ b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/ApiOriginFilter.java @@ -0,0 +1,22 @@ +package org.openapitools.api; + +import java.io.IOException; + +import javax.servlet.*; +import javax.servlet.http.HttpServletResponse; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", date = "2018-08-10T15:02:11.723+09:00[Asia/Tokyo]") +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-jersey/src/gen/java/org/openapitools/api/ApiResponseMessage.java b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/ApiResponseMessage.java new file mode 100644 index 00000000000..d25a2f4d834 --- /dev/null +++ b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/ApiResponseMessage.java @@ -0,0 +1,69 @@ +package org.openapitools.api; + +import javax.xml.bind.annotation.XmlTransient; + +@javax.xml.bind.annotation.XmlRootElement +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", date = "2018-08-10T15:02:11.723+09:00[Asia/Tokyo]") +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-jersey/src/gen/java/org/openapitools/api/JacksonJsonProvider.java b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/JacksonJsonProvider.java new file mode 100644 index 00000000000..d41d7a1e255 --- /dev/null +++ b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/JacksonJsonProvider.java @@ -0,0 +1,29 @@ +package org.openapitools.api; + +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; + +import com.fasterxml.jackson.datatype.joda.*; + +import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider; + +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.ext.Provider; + +@Provider +@Produces({MediaType.APPLICATION_JSON}) +public class JacksonJsonProvider extends JacksonJaxbJsonProvider { + + public JacksonJsonProvider() { + + ObjectMapper objectMapper = new ObjectMapper() + .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) + .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) + .registerModule(new JodaModule()) + .setDateFormat(new RFC3339DateFormat()); + + setMapper(objectMapper); + } +} \ No newline at end of file diff --git a/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/NotFoundException.java b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/NotFoundException.java new file mode 100644 index 00000000000..edfc4e392a8 --- /dev/null +++ b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/NotFoundException.java @@ -0,0 +1,10 @@ +package org.openapitools.api; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", date = "2018-08-10T15:02:11.723+09:00[Asia/Tokyo]") +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-jersey/src/gen/java/org/openapitools/api/PetApi.java b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/PetApi.java new file mode 100644 index 00000000000..c65b8d422e2 --- /dev/null +++ b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/PetApi.java @@ -0,0 +1,211 @@ +package org.openapitools.api; + +import org.openapitools.model.*; +import org.openapitools.api.PetApiService; +import org.openapitools.api.factories.PetApiServiceFactory; + +import io.swagger.annotations.ApiParam; +import io.swagger.jaxrs.*; + +import java.io.File; +import org.openapitools.model.ModelApiResponse; +import org.openapitools.model.Pet; + +import java.util.Map; +import java.util.List; +import org.openapitools.api.NotFoundException; + +import java.io.InputStream; + +import org.glassfish.jersey.media.multipart.FormDataContentDisposition; +import org.glassfish.jersey.media.multipart.FormDataParam; + +import javax.servlet.ServletConfig; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.SecurityContext; +import javax.ws.rs.*; +import javax.validation.constraints.*; + +@Path("/pet") + + +@io.swagger.annotations.Api(description = "the pet API") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", date = "2018-08-10T15:02:11.723+09:00[Asia/Tokyo]") +public class PetApi { + private final PetApiService delegate; + + public PetApi(@Context ServletConfig servletContext) { + PetApiService delegate = null; + + if (servletContext != null) { + String implClass = servletContext.getInitParameter("PetApi.implementation"); + if (implClass != null && !"".equals(implClass.trim())) { + try { + delegate = (PetApiService) Class.forName(implClass).newInstance(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } + + if (delegate == null) { + delegate = PetApiServiceFactory.getPetApi(); + } + + this.delegate = delegate; + } + + @POST + + @Consumes({ "application/json", "application/xml" }) + + @io.swagger.annotations.ApiOperation(value = "Add a new pet to the store", notes = "", response = Void.class, authorizations = { + @io.swagger.annotations.Authorization(value = "petstore_auth", scopes = { + @io.swagger.annotations.AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), + @io.swagger.annotations.AuthorizationScope(scope = "read:pets", description = "read your pets") + }) + }, tags={ "pet", }) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 405, message = "Invalid input", response = Void.class) }) + public Response addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true) Pet pet +,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.addPet(pet,securityContext); + } + @DELETE + @Path("/{petId}") + + + @io.swagger.annotations.ApiOperation(value = "Deletes a pet", notes = "", response = Void.class, authorizations = { + @io.swagger.annotations.Authorization(value = "petstore_auth", scopes = { + @io.swagger.annotations.AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), + @io.swagger.annotations.AuthorizationScope(scope = "read:pets", description = "read your pets") + }) + }, tags={ "pet", }) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid pet value", response = Void.class) }) + public Response deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathParam("petId") Long petId +,@ApiParam(value = "" )@HeaderParam("api_key") String apiKey +,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.deletePet(petId,apiKey,securityContext); + } + @GET + @Path("/findByStatus") + + @Produces({ "application/xml", "application/json" }) + @io.swagger.annotations.ApiOperation(value = "Finds Pets by status", notes = "Multiple status values can be provided with comma separated strings", response = Pet.class, responseContainer = "List", authorizations = { + @io.swagger.annotations.Authorization(value = "petstore_auth", scopes = { + @io.swagger.annotations.AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), + @io.swagger.annotations.AuthorizationScope(scope = "read:pets", description = "read your pets") + }) + }, tags={ "pet", }) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"), + + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid status value", response = Void.class) }) + public Response findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter",required=true, allowableValues="available, pending, sold") @QueryParam("status") List status +,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.findPetsByStatus(status,securityContext); + } + @GET + @Path("/findByTags") + + @Produces({ "application/xml", "application/json" }) + @io.swagger.annotations.ApiOperation(value = "Finds Pets by tags", notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List", authorizations = { + @io.swagger.annotations.Authorization(value = "petstore_auth", scopes = { + @io.swagger.annotations.AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), + @io.swagger.annotations.AuthorizationScope(scope = "read:pets", description = "read your pets") + }) + }, tags={ "pet", }) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"), + + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid tag value", response = Void.class) }) + public Response findPetsByTags(@ApiParam(value = "Tags to filter by",required=true) @QueryParam("tags") List tags +,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.findPetsByTags(tags,securityContext); + } + @GET + @Path("/{petId}") + + @Produces({ "application/xml", "application/json" }) + @io.swagger.annotations.ApiOperation(value = "Find pet by ID", notes = "Returns a single pet", response = Pet.class, authorizations = { + @io.swagger.annotations.Authorization(value = "api_key") + }, tags={ "pet", }) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Pet.class), + + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied", response = Void.class), + + @io.swagger.annotations.ApiResponse(code = 404, message = "Pet not found", response = Void.class) }) + public Response getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathParam("petId") Long petId +,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.getPetById(petId,securityContext); + } + @PUT + + @Consumes({ "application/json", "application/xml" }) + + @io.swagger.annotations.ApiOperation(value = "Update an existing pet", notes = "", response = Void.class, authorizations = { + @io.swagger.annotations.Authorization(value = "petstore_auth", scopes = { + @io.swagger.annotations.AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), + @io.swagger.annotations.AuthorizationScope(scope = "read:pets", description = "read your pets") + }) + }, tags={ "pet", }) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied", response = Void.class), + + @io.swagger.annotations.ApiResponse(code = 404, message = "Pet not found", response = Void.class), + + @io.swagger.annotations.ApiResponse(code = 405, message = "Validation exception", response = Void.class) }) + public Response updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true) Pet pet +,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.updatePet(pet,securityContext); + } + @POST + @Path("/{petId}") + @Consumes({ "application/x-www-form-urlencoded" }) + + @io.swagger.annotations.ApiOperation(value = "Updates a pet in the store with form data", notes = "", response = Void.class, authorizations = { + @io.swagger.annotations.Authorization(value = "petstore_auth", scopes = { + @io.swagger.annotations.AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), + @io.swagger.annotations.AuthorizationScope(scope = "read:pets", description = "read your pets") + }) + }, tags={ "pet", }) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 405, message = "Invalid input", response = Void.class) }) + public Response updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathParam("petId") Long petId +,@ApiParam(value = "Updated name of the pet", defaultValue="null") @DefaultValue("null") @FormParam("name") String name +,@ApiParam(value = "Updated status of the pet", defaultValue="null") @DefaultValue("null") @FormParam("status") String status +,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.updatePetWithForm(petId,name,status,securityContext); + } + @POST + @Path("/{petId}/uploadImage") + @Consumes({ "multipart/form-data" }) + @Produces({ "application/json" }) + @io.swagger.annotations.ApiOperation(value = "uploads an image", notes = "", response = ModelApiResponse.class, authorizations = { + @io.swagger.annotations.Authorization(value = "petstore_auth", scopes = { + @io.swagger.annotations.AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), + @io.swagger.annotations.AuthorizationScope(scope = "read:pets", description = "read your pets") + }) + }, tags={ "pet", }) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.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 +,@ApiParam(value = "Additional data to pass to server", defaultValue="null")@FormDataParam("additionalMetadata") String additionalMetadata +, + @FormDataParam("file") InputStream fileInputStream, + @FormDataParam("file") FormDataContentDisposition fileDetail +,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.uploadFile(petId,additionalMetadata,fileInputStream, fileDetail,securityContext); + } +} diff --git a/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/PetApiService.java b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/PetApiService.java new file mode 100644 index 00000000000..95bf11d9b09 --- /dev/null +++ b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/PetApiService.java @@ -0,0 +1,30 @@ +package org.openapitools.api; + +import org.openapitools.api.*; +import org.openapitools.model.*; + +import org.glassfish.jersey.media.multipart.FormDataContentDisposition; + +import java.io.File; +import org.openapitools.model.ModelApiResponse; +import org.openapitools.model.Pet; + +import java.util.List; +import org.openapitools.api.NotFoundException; + +import java.io.InputStream; + +import javax.ws.rs.core.Response; +import javax.ws.rs.core.SecurityContext; +import javax.validation.constraints.*; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", date = "2018-08-10T15:02:11.723+09:00[Asia/Tokyo]") +public abstract class PetApiService { + public abstract Response addPet(Pet pet,SecurityContext securityContext) throws NotFoundException; + public abstract Response deletePet(Long petId,String apiKey,SecurityContext securityContext) throws NotFoundException; + public abstract Response findPetsByStatus( @NotNull List status,SecurityContext securityContext) throws NotFoundException; + public abstract Response findPetsByTags( @NotNull List tags,SecurityContext securityContext) throws NotFoundException; + public abstract Response getPetById(Long petId,SecurityContext securityContext) throws NotFoundException; + public abstract Response updatePet(Pet pet,SecurityContext securityContext) throws NotFoundException; + public abstract Response updatePetWithForm(Long petId,String name,String status,SecurityContext securityContext) throws NotFoundException; + public abstract Response uploadFile(Long petId,String additionalMetadata,InputStream fileInputStream, FormDataContentDisposition fileDetail,SecurityContext securityContext) throws NotFoundException; +} diff --git a/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/RFC3339DateFormat.java b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/RFC3339DateFormat.java new file mode 100644 index 00000000000..b471837701d --- /dev/null +++ b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/RFC3339DateFormat.java @@ -0,0 +1,19 @@ +package org.openapitools.api; + +import com.fasterxml.jackson.databind.util.ISO8601DateFormat; +import com.fasterxml.jackson.databind.util.ISO8601Utils; + +import java.text.FieldPosition; +import java.util.Date; + +public class RFC3339DateFormat extends ISO8601DateFormat { + + // Same as ISO8601DateFormat but serializing milliseconds. + @Override + public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { + String value = ISO8601Utils.format(date, true); + toAppendTo.append(value); + return toAppendTo; + } + +} \ No newline at end of file diff --git a/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/StoreApi.java b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/StoreApi.java new file mode 100644 index 00000000000..d0f12395db8 --- /dev/null +++ b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/StoreApi.java @@ -0,0 +1,115 @@ +package org.openapitools.api; + +import org.openapitools.model.*; +import org.openapitools.api.StoreApiService; +import org.openapitools.api.factories.StoreApiServiceFactory; + +import io.swagger.annotations.ApiParam; +import io.swagger.jaxrs.*; + +import java.util.Map; +import org.openapitools.model.Order; + +import java.util.Map; +import java.util.List; +import org.openapitools.api.NotFoundException; + +import java.io.InputStream; + +import org.glassfish.jersey.media.multipart.FormDataContentDisposition; +import org.glassfish.jersey.media.multipart.FormDataParam; + +import javax.servlet.ServletConfig; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.SecurityContext; +import javax.ws.rs.*; +import javax.validation.constraints.*; + +@Path("/store") + + +@io.swagger.annotations.Api(description = "the store API") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", date = "2018-08-10T15:02:11.723+09:00[Asia/Tokyo]") +public class StoreApi { + private final StoreApiService delegate; + + public StoreApi(@Context ServletConfig servletContext) { + StoreApiService delegate = null; + + if (servletContext != null) { + String implClass = servletContext.getInitParameter("StoreApi.implementation"); + if (implClass != null && !"".equals(implClass.trim())) { + try { + delegate = (StoreApiService) Class.forName(implClass).newInstance(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } + + if (delegate == null) { + delegate = StoreApiServiceFactory.getStoreApi(); + } + + this.delegate = delegate; + } + + @DELETE + @Path("/order/{orderId}") + + + @io.swagger.annotations.ApiOperation(value = "Delete purchase order by ID", notes = "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", response = Void.class, tags={ "store", }) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied", response = Void.class), + + @io.swagger.annotations.ApiResponse(code = 404, message = "Order not found", response = Void.class) }) + public Response deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathParam("orderId") String orderId +,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.deleteOrder(orderId,securityContext); + } + @GET + @Path("/inventory") + + @Produces({ "application/json" }) + @io.swagger.annotations.ApiOperation(value = "Returns pet inventories by status", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map", authorizations = { + @io.swagger.annotations.Authorization(value = "api_key") + }, tags={ "store", }) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") }) + public Response getInventory(@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.getInventory(securityContext); + } + @GET + @Path("/order/{orderId}") + + @Produces({ "application/xml", "application/json" }) + @io.swagger.annotations.ApiOperation(value = "Find purchase order by ID", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", }) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Order.class), + + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied", response = Void.class), + + @io.swagger.annotations.ApiResponse(code = 404, message = "Order not found", response = Void.class) }) + public Response getOrderById(@ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathParam("orderId") Long orderId +,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.getOrderById(orderId,securityContext); + } + @POST + @Path("/order") + @Consumes({ "application/json" }) + @Produces({ "application/xml", "application/json" }) + @io.swagger.annotations.ApiOperation(value = "Place an order for a pet", notes = "", response = Order.class, tags={ "store", }) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Order.class), + + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid Order", response = Void.class) }) + public Response placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true) Order order +,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.placeOrder(order,securityContext); + } +} diff --git a/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/StoreApiService.java b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/StoreApiService.java new file mode 100644 index 00000000000..13698d783a9 --- /dev/null +++ b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/StoreApiService.java @@ -0,0 +1,25 @@ +package org.openapitools.api; + +import org.openapitools.api.*; +import org.openapitools.model.*; + +import org.glassfish.jersey.media.multipart.FormDataContentDisposition; + +import java.util.Map; +import org.openapitools.model.Order; + +import java.util.List; +import org.openapitools.api.NotFoundException; + +import java.io.InputStream; + +import javax.ws.rs.core.Response; +import javax.ws.rs.core.SecurityContext; +import javax.validation.constraints.*; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", date = "2018-08-10T15:02:11.723+09:00[Asia/Tokyo]") +public abstract class StoreApiService { + public abstract Response deleteOrder(String orderId,SecurityContext securityContext) throws NotFoundException; + public abstract Response getInventory(SecurityContext securityContext) throws NotFoundException; + public abstract Response getOrderById( @Min(1L) @Max(5L)Long orderId,SecurityContext securityContext) throws NotFoundException; + public abstract Response placeOrder(Order order,SecurityContext securityContext) throws NotFoundException; +} diff --git a/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/StringUtil.java b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/StringUtil.java new file mode 100644 index 00000000000..8810d4383bd --- /dev/null +++ b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/StringUtil.java @@ -0,0 +1,42 @@ +package org.openapitools.api; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", date = "2018-08-10T15:02:11.723+09:00[Asia/Tokyo]") +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-jersey/src/gen/java/org/openapitools/api/UserApi.java b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/UserApi.java new file mode 100644 index 00000000000..2c5625c2fe4 --- /dev/null +++ b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/UserApi.java @@ -0,0 +1,165 @@ +package org.openapitools.api; + +import org.openapitools.model.*; +import org.openapitools.api.UserApiService; +import org.openapitools.api.factories.UserApiServiceFactory; + +import io.swagger.annotations.ApiParam; +import io.swagger.jaxrs.*; + +import java.util.List; +import org.openapitools.model.User; + +import java.util.Map; +import java.util.List; +import org.openapitools.api.NotFoundException; + +import java.io.InputStream; + +import org.glassfish.jersey.media.multipart.FormDataContentDisposition; +import org.glassfish.jersey.media.multipart.FormDataParam; + +import javax.servlet.ServletConfig; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.SecurityContext; +import javax.ws.rs.*; +import javax.validation.constraints.*; + +@Path("/user") + + +@io.swagger.annotations.Api(description = "the user API") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", date = "2018-08-10T15:02:11.723+09:00[Asia/Tokyo]") +public class UserApi { + private final UserApiService delegate; + + public UserApi(@Context ServletConfig servletContext) { + UserApiService delegate = null; + + if (servletContext != null) { + String implClass = servletContext.getInitParameter("UserApi.implementation"); + if (implClass != null && !"".equals(implClass.trim())) { + try { + delegate = (UserApiService) Class.forName(implClass).newInstance(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } + + if (delegate == null) { + delegate = UserApiServiceFactory.getUserApi(); + } + + this.delegate = delegate; + } + + @POST + + @Consumes({ "application/json" }) + + @io.swagger.annotations.ApiOperation(value = "Create user", notes = "This can only be done by the logged in user.", response = Void.class, tags={ "user", }) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Void.class) }) + public Response createUser(@ApiParam(value = "Created user object" ,required=true) User user +,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.createUser(user,securityContext); + } + @POST + @Path("/createWithArray") + @Consumes({ "application/json" }) + + @io.swagger.annotations.ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class, tags={ "user", }) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Void.class) }) + public Response createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true) List user +,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.createUsersWithArrayInput(user,securityContext); + } + @POST + @Path("/createWithList") + @Consumes({ "application/json" }) + + @io.swagger.annotations.ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class, tags={ "user", }) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Void.class) }) + public Response createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true) List user +,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.createUsersWithListInput(user,securityContext); + } + @DELETE + @Path("/{username}") + + + @io.swagger.annotations.ApiOperation(value = "Delete user", notes = "This can only be done by the logged in user.", response = Void.class, tags={ "user", }) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username supplied", response = Void.class), + + @io.swagger.annotations.ApiResponse(code = 404, message = "User not found", response = Void.class) }) + public Response deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathParam("username") String username +,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.deleteUser(username,securityContext); + } + @GET + @Path("/{username}") + + @Produces({ "application/xml", "application/json" }) + @io.swagger.annotations.ApiOperation(value = "Get user by user name", notes = "", response = User.class, tags={ "user", }) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = User.class), + + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username supplied", response = Void.class), + + @io.swagger.annotations.ApiResponse(code = 404, message = "User not found", response = Void.class) }) + public Response getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.",required=true) @PathParam("username") String username +,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.getUserByName(username,securityContext); + } + @GET + @Path("/login") + + @Produces({ "application/xml", "application/json" }) + @io.swagger.annotations.ApiOperation(value = "Logs user into the system", notes = "", response = String.class, tags={ "user", }) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = String.class), + + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username/password supplied", response = Void.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 +,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.loginUser(username,password,securityContext); + } + @GET + @Path("/logout") + + + @io.swagger.annotations.ApiOperation(value = "Logs out current logged in user session", notes = "", response = Void.class, tags={ "user", }) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Void.class) }) + public Response logoutUser(@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.logoutUser(securityContext); + } + @PUT + @Path("/{username}") + @Consumes({ "application/json" }) + + @io.swagger.annotations.ApiOperation(value = "Updated user", notes = "This can only be done by the logged in user.", response = Void.class, tags={ "user", }) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid user supplied", response = Void.class), + + @io.swagger.annotations.ApiResponse(code = 404, message = "User not found", response = Void.class) }) + public Response updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathParam("username") String username +,@ApiParam(value = "Updated user object" ,required=true) User user +,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.updateUser(username,user,securityContext); + } +} diff --git a/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/UserApiService.java b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/UserApiService.java new file mode 100644 index 00000000000..e5919ae31cb --- /dev/null +++ b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/UserApiService.java @@ -0,0 +1,29 @@ +package org.openapitools.api; + +import org.openapitools.api.*; +import org.openapitools.model.*; + +import org.glassfish.jersey.media.multipart.FormDataContentDisposition; + +import java.util.List; +import org.openapitools.model.User; + +import java.util.List; +import org.openapitools.api.NotFoundException; + +import java.io.InputStream; + +import javax.ws.rs.core.Response; +import javax.ws.rs.core.SecurityContext; +import javax.validation.constraints.*; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", date = "2018-08-10T15:02:11.723+09:00[Asia/Tokyo]") +public abstract class UserApiService { + public abstract Response createUser(User user,SecurityContext securityContext) throws NotFoundException; + public abstract Response createUsersWithArrayInput(List user,SecurityContext securityContext) throws NotFoundException; + public abstract Response createUsersWithListInput(List user,SecurityContext securityContext) throws NotFoundException; + public abstract Response deleteUser(String username,SecurityContext securityContext) throws NotFoundException; + public abstract Response getUserByName(String username,SecurityContext securityContext) throws NotFoundException; + public abstract Response loginUser( @NotNull String username, @NotNull String password,SecurityContext securityContext) throws NotFoundException; + public abstract Response logoutUser(SecurityContext securityContext) throws NotFoundException; + public abstract Response updateUser(String username,User user,SecurityContext securityContext) throws NotFoundException; +} diff --git a/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/Category.java b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/Category.java new file mode 100644 index 00000000000..76cf0f87956 --- /dev/null +++ b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/Category.java @@ -0,0 +1,115 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; + +/** + * A category for a pet + */ +@ApiModel(description = "A category for a pet") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", date = "2018-08-10T15:02:11.723+09:00[Asia/Tokyo]") +public class Category { + @JsonProperty("id") + private Long id = null; + + @JsonProperty("name") + private String name = null; + + public Category id(Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + @JsonProperty("id") + @ApiModelProperty(value = "") + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Category name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @JsonProperty("name") + @ApiModelProperty(value = "") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Category category = (Category) o; + return Objects.equals(this.id, category.id) && + Objects.equals(this.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(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/ModelApiResponse.java b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/ModelApiResponse.java new file mode 100644 index 00000000000..45069447901 --- /dev/null +++ b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/ModelApiResponse.java @@ -0,0 +1,139 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; + +/** + * Describes the result of uploading an image resource + */ +@ApiModel(description = "Describes the result of uploading an image resource") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", date = "2018-08-10T15:02:11.723+09:00[Asia/Tokyo]") +public class ModelApiResponse { + @JsonProperty("code") + private Integer code = null; + + @JsonProperty("type") + private String type = null; + + @JsonProperty("message") + private String message = null; + + public ModelApiResponse code(Integer code) { + this.code = code; + return this; + } + + /** + * Get code + * @return code + **/ + @JsonProperty("code") + @ApiModelProperty(value = "") + public Integer getCode() { + return code; + } + + public void setCode(Integer code) { + this.code = code; + } + + public ModelApiResponse type(String type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + @JsonProperty("type") + @ApiModelProperty(value = "") + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public ModelApiResponse message(String message) { + this.message = message; + return this; + } + + /** + * Get message + * @return message + **/ + @JsonProperty("message") + @ApiModelProperty(value = "") + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelApiResponse _apiResponse = (ModelApiResponse) o; + return Objects.equals(this.code, _apiResponse.code) && + Objects.equals(this.type, _apiResponse.type) && + Objects.equals(this.message, _apiResponse.message); + } + + @Override + public int hashCode() { + return Objects.hash(code, type, message); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelApiResponse {\n"); + + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/Order.java b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/Order.java new file mode 100644 index 00000000000..1f1c23188d1 --- /dev/null +++ b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/Order.java @@ -0,0 +1,246 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.Date; +import javax.validation.constraints.*; + +/** + * An order for a pets from the pet store + */ +@ApiModel(description = "An order for a pets from the pet store") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", date = "2018-08-10T15:02:11.723+09:00[Asia/Tokyo]") +public class Order { + @JsonProperty("id") + private Long id = null; + + @JsonProperty("petId") + private Long petId = null; + + @JsonProperty("quantity") + private Integer quantity = null; + + @JsonProperty("shipDate") + private Date shipDate = null; + + /** + * Order Status + */ + public enum StatusEnum { + PLACED("placed"), + + APPROVED("approved"), + + DELIVERED("delivered"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @Override + @JsonValue + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static StatusEnum fromValue(String text) { + for (StatusEnum b : StatusEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + text + "'"); + } + } + + @JsonProperty("status") + private StatusEnum status = null; + + @JsonProperty("complete") + private Boolean complete = false; + + public Order id(Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + @JsonProperty("id") + @ApiModelProperty(value = "") + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Order petId(Long petId) { + this.petId = petId; + return this; + } + + /** + * Get petId + * @return petId + **/ + @JsonProperty("petId") + @ApiModelProperty(value = "") + public Long getPetId() { + return petId; + } + + public void setPetId(Long petId) { + this.petId = petId; + } + + public Order quantity(Integer quantity) { + this.quantity = quantity; + return this; + } + + /** + * Get quantity + * @return quantity + **/ + @JsonProperty("quantity") + @ApiModelProperty(value = "") + public Integer getQuantity() { + return quantity; + } + + public void setQuantity(Integer quantity) { + this.quantity = quantity; + } + + public Order shipDate(Date shipDate) { + this.shipDate = shipDate; + return this; + } + + /** + * Get shipDate + * @return shipDate + **/ + @JsonProperty("shipDate") + @ApiModelProperty(value = "") + public Date getShipDate() { + return shipDate; + } + + public void setShipDate(Date shipDate) { + this.shipDate = shipDate; + } + + public Order status(StatusEnum status) { + this.status = status; + return this; + } + + /** + * Order Status + * @return status + **/ + @JsonProperty("status") + @ApiModelProperty(value = "Order Status") + public StatusEnum getStatus() { + return status; + } + + public void setStatus(StatusEnum status) { + this.status = status; + } + + public Order complete(Boolean complete) { + this.complete = complete; + return this; + } + + /** + * Get complete + * @return complete + **/ + @JsonProperty("complete") + @ApiModelProperty(value = "") + public Boolean getComplete() { + return complete; + } + + public void setComplete(Boolean complete) { + this.complete = complete; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Order order = (Order) o; + return Objects.equals(this.id, order.id) && + Objects.equals(this.petId, order.petId) && + Objects.equals(this.quantity, order.quantity) && + Objects.equals(this.shipDate, order.shipDate) && + Objects.equals(this.status, order.status) && + Objects.equals(this.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(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/Pet.java b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/Pet.java new file mode 100644 index 00000000000..96271292913 --- /dev/null +++ b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/Pet.java @@ -0,0 +1,264 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.ArrayList; +import java.util.List; +import org.openapitools.model.Category; +import org.openapitools.model.Tag; +import javax.validation.constraints.*; + +/** + * A pet for sale in the pet store + */ +@ApiModel(description = "A pet for sale in the pet store") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", date = "2018-08-10T15:02:11.723+09:00[Asia/Tokyo]") +public class Pet { + @JsonProperty("id") + private Long id = null; + + @JsonProperty("category") + private Category category = null; + + @JsonProperty("name") + private String name = null; + + @JsonProperty("photoUrls") + private List photoUrls = new ArrayList(); + + @JsonProperty("tags") + private List tags = null; + + /** + * pet status in the store + */ + public enum StatusEnum { + AVAILABLE("available"), + + PENDING("pending"), + + SOLD("sold"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @Override + @JsonValue + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static StatusEnum fromValue(String text) { + for (StatusEnum b : StatusEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + text + "'"); + } + } + + @JsonProperty("status") + private StatusEnum status = null; + + public Pet id(Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + @JsonProperty("id") + @ApiModelProperty(value = "") + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Pet category(Category category) { + this.category = category; + return this; + } + + /** + * Get category + * @return category + **/ + @JsonProperty("category") + @ApiModelProperty(value = "") + public Category getCategory() { + return category; + } + + public void setCategory(Category category) { + this.category = category; + } + + public Pet name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @JsonProperty("name") + @ApiModelProperty(example = "doggie", required = true, value = "") + @NotNull + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Pet photoUrls(List photoUrls) { + this.photoUrls = photoUrls; + return this; + } + + public Pet addPhotoUrlsItem(String photoUrlsItem) { + this.photoUrls.add(photoUrlsItem); + return this; + } + + /** + * Get photoUrls + * @return photoUrls + **/ + @JsonProperty("photoUrls") + @ApiModelProperty(required = true, value = "") + @NotNull + public List getPhotoUrls() { + return photoUrls; + } + + public void setPhotoUrls(List photoUrls) { + this.photoUrls = photoUrls; + } + + public Pet tags(List tags) { + this.tags = tags; + return this; + } + + public Pet addTagsItem(Tag tagsItem) { + if (this.tags == null) { + this.tags = new ArrayList(); + } + this.tags.add(tagsItem); + return this; + } + + /** + * Get tags + * @return tags + **/ + @JsonProperty("tags") + @ApiModelProperty(value = "") + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + public Pet status(StatusEnum status) { + this.status = status; + return this; + } + + /** + * pet status in the store + * @return status + **/ + @JsonProperty("status") + @ApiModelProperty(value = "pet status in the store") + public StatusEnum getStatus() { + return status; + } + + public void setStatus(StatusEnum status) { + this.status = status; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Pet pet = (Pet) o; + return Objects.equals(this.id, pet.id) && + Objects.equals(this.category, pet.category) && + Objects.equals(this.name, pet.name) && + Objects.equals(this.photoUrls, pet.photoUrls) && + Objects.equals(this.tags, pet.tags) && + Objects.equals(this.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(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/Tag.java b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/Tag.java new file mode 100644 index 00000000000..5d78706d8f4 --- /dev/null +++ b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/Tag.java @@ -0,0 +1,115 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; + +/** + * A tag for a pet + */ +@ApiModel(description = "A tag for a pet") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", date = "2018-08-10T15:02:11.723+09:00[Asia/Tokyo]") +public class Tag { + @JsonProperty("id") + private Long id = null; + + @JsonProperty("name") + private String name = null; + + public Tag id(Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + @JsonProperty("id") + @ApiModelProperty(value = "") + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Tag name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @JsonProperty("name") + @ApiModelProperty(value = "") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Tag tag = (Tag) o; + return Objects.equals(this.id, tag.id) && + Objects.equals(this.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(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/User.java b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/User.java new file mode 100644 index 00000000000..3709c050508 --- /dev/null +++ b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/User.java @@ -0,0 +1,259 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; + +/** + * A User who is purchasing from the pet store + */ +@ApiModel(description = "A User who is purchasing from the pet store") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", date = "2018-08-10T15:02:11.723+09:00[Asia/Tokyo]") +public class User { + @JsonProperty("id") + private Long id = null; + + @JsonProperty("username") + private String username = null; + + @JsonProperty("firstName") + private String firstName = null; + + @JsonProperty("lastName") + private String lastName = null; + + @JsonProperty("email") + private String email = null; + + @JsonProperty("password") + private String password = null; + + @JsonProperty("phone") + private String phone = null; + + @JsonProperty("userStatus") + private Integer userStatus = null; + + public User id(Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + @JsonProperty("id") + @ApiModelProperty(value = "") + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public User username(String username) { + this.username = username; + return this; + } + + /** + * Get username + * @return username + **/ + @JsonProperty("username") + @ApiModelProperty(value = "") + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public User firstName(String firstName) { + this.firstName = firstName; + return this; + } + + /** + * Get firstName + * @return firstName + **/ + @JsonProperty("firstName") + @ApiModelProperty(value = "") + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public User lastName(String lastName) { + this.lastName = lastName; + return this; + } + + /** + * Get lastName + * @return lastName + **/ + @JsonProperty("lastName") + @ApiModelProperty(value = "") + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public User email(String email) { + this.email = email; + return this; + } + + /** + * Get email + * @return email + **/ + @JsonProperty("email") + @ApiModelProperty(value = "") + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public User password(String password) { + this.password = password; + return this; + } + + /** + * Get password + * @return password + **/ + @JsonProperty("password") + @ApiModelProperty(value = "") + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public User phone(String phone) { + this.phone = phone; + return this; + } + + /** + * Get phone + * @return phone + **/ + @JsonProperty("phone") + @ApiModelProperty(value = "") + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public User userStatus(Integer userStatus) { + this.userStatus = userStatus; + return this; + } + + /** + * User Status + * @return userStatus + **/ + @JsonProperty("userStatus") + @ApiModelProperty(value = "User Status") + public Integer getUserStatus() { + return userStatus; + } + + public void setUserStatus(Integer userStatus) { + this.userStatus = userStatus; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + User user = (User) o; + return Objects.equals(this.id, user.id) && + Objects.equals(this.username, user.username) && + Objects.equals(this.firstName, user.firstName) && + Objects.equals(this.lastName, user.lastName) && + Objects.equals(this.email, user.email) && + Objects.equals(this.password, user.password) && + Objects.equals(this.phone, user.phone) && + Objects.equals(this.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(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/jaxrs-jersey/src/main/java/org/openapitools/api/Bootstrap.java b/samples/server/petstore/jaxrs-jersey/src/main/java/org/openapitools/api/Bootstrap.java new file mode 100644 index 00000000000..2856cda2f37 --- /dev/null +++ b/samples/server/petstore/jaxrs-jersey/src/main/java/org/openapitools/api/Bootstrap.java @@ -0,0 +1,31 @@ +package org.openapitools.api; + +import io.swagger.jaxrs.config.SwaggerContextService; +import io.swagger.models.*; + +import io.swagger.models.auth.*; + +import javax.servlet.http.HttpServlet; +import javax.servlet.ServletContext; +import javax.servlet.ServletConfig; +import javax.servlet.ServletException; + +public class Bootstrap extends HttpServlet { + @Override + public void init(ServletConfig config) throws ServletException { + Info info = new Info() + .title("OpenAPI Server") + .description("This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.") + .termsOfService("") + .contact(new Contact() + .email("")) + .license(new License() + .name("Apache-2.0") + .url("http://www.apache.org/licenses/LICENSE-2.0.html")); + + ServletContext context = config.getServletContext(); + Swagger swagger = new Swagger().info(info); + + new SwaggerContextService().withServletConfig(config).updateSwagger(swagger); + } +} diff --git a/samples/server/petstore/jaxrs-jersey/src/main/java/org/openapitools/api/factories/PetApiServiceFactory.java b/samples/server/petstore/jaxrs-jersey/src/main/java/org/openapitools/api/factories/PetApiServiceFactory.java new file mode 100644 index 00000000000..5bd95e5f1c0 --- /dev/null +++ b/samples/server/petstore/jaxrs-jersey/src/main/java/org/openapitools/api/factories/PetApiServiceFactory.java @@ -0,0 +1,13 @@ +package org.openapitools.api.factories; + +import org.openapitools.api.PetApiService; +import org.openapitools.api.impl.PetApiServiceImpl; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", date = "2018-08-10T15:02:11.723+09:00[Asia/Tokyo]") +public class PetApiServiceFactory { + private final static PetApiService service = new PetApiServiceImpl(); + + public static PetApiService getPetApi() { + return service; + } +} diff --git a/samples/server/petstore/jaxrs-jersey/src/main/java/org/openapitools/api/factories/StoreApiServiceFactory.java b/samples/server/petstore/jaxrs-jersey/src/main/java/org/openapitools/api/factories/StoreApiServiceFactory.java new file mode 100644 index 00000000000..3a9ab3531af --- /dev/null +++ b/samples/server/petstore/jaxrs-jersey/src/main/java/org/openapitools/api/factories/StoreApiServiceFactory.java @@ -0,0 +1,13 @@ +package org.openapitools.api.factories; + +import org.openapitools.api.StoreApiService; +import org.openapitools.api.impl.StoreApiServiceImpl; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", date = "2018-08-10T15:02:11.723+09:00[Asia/Tokyo]") +public class StoreApiServiceFactory { + private final static StoreApiService service = new StoreApiServiceImpl(); + + public static StoreApiService getStoreApi() { + return service; + } +} diff --git a/samples/server/petstore/jaxrs-jersey/src/main/java/org/openapitools/api/factories/UserApiServiceFactory.java b/samples/server/petstore/jaxrs-jersey/src/main/java/org/openapitools/api/factories/UserApiServiceFactory.java new file mode 100644 index 00000000000..12540d9364c --- /dev/null +++ b/samples/server/petstore/jaxrs-jersey/src/main/java/org/openapitools/api/factories/UserApiServiceFactory.java @@ -0,0 +1,13 @@ +package org.openapitools.api.factories; + +import org.openapitools.api.UserApiService; +import org.openapitools.api.impl.UserApiServiceImpl; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", date = "2018-08-10T15:02:11.723+09:00[Asia/Tokyo]") +public class UserApiServiceFactory { + private final static UserApiService service = new UserApiServiceImpl(); + + public static UserApiService getUserApi() { + return service; + } +} diff --git a/samples/server/petstore/jaxrs-jersey/src/main/java/org/openapitools/api/impl/PetApiServiceImpl.java b/samples/server/petstore/jaxrs-jersey/src/main/java/org/openapitools/api/impl/PetApiServiceImpl.java new file mode 100644 index 00000000000..3ef3488fe8f --- /dev/null +++ b/samples/server/petstore/jaxrs-jersey/src/main/java/org/openapitools/api/impl/PetApiServiceImpl.java @@ -0,0 +1,62 @@ +package org.openapitools.api.impl; + +import org.openapitools.api.*; +import org.openapitools.model.*; + +import java.io.File; +import org.openapitools.model.ModelApiResponse; +import org.openapitools.model.Pet; + +import java.util.List; +import org.openapitools.api.NotFoundException; + +import java.io.InputStream; + +import org.glassfish.jersey.media.multipart.FormDataContentDisposition; + +import javax.ws.rs.core.Response; +import javax.ws.rs.core.SecurityContext; +import javax.validation.constraints.*; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", date = "2018-08-10T15:02:11.723+09:00[Asia/Tokyo]") +public class PetApiServiceImpl extends PetApiService { + @Override + public Response addPet(Pet pet, 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 findPetsByStatus( @NotNull List status, SecurityContext securityContext) throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + @Override + public Response findPetsByTags( @NotNull 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 updatePet(Pet pet, SecurityContext securityContext) throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + @Override + public Response updatePetWithForm(Long 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 uploadFile(Long petId, String additionalMetadata, InputStream fileInputStream, FormDataContentDisposition fileDetail, SecurityContext securityContext) throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } +} diff --git a/samples/server/petstore/jaxrs-jersey/src/main/java/org/openapitools/api/impl/StoreApiServiceImpl.java b/samples/server/petstore/jaxrs-jersey/src/main/java/org/openapitools/api/impl/StoreApiServiceImpl.java new file mode 100644 index 00000000000..b4be886cf0c --- /dev/null +++ b/samples/server/petstore/jaxrs-jersey/src/main/java/org/openapitools/api/impl/StoreApiServiceImpl.java @@ -0,0 +1,41 @@ +package org.openapitools.api.impl; + +import org.openapitools.api.*; +import org.openapitools.model.*; + +import java.util.Map; +import org.openapitools.model.Order; + +import java.util.List; +import org.openapitools.api.NotFoundException; + +import java.io.InputStream; + +import org.glassfish.jersey.media.multipart.FormDataContentDisposition; + +import javax.ws.rs.core.Response; +import javax.ws.rs.core.SecurityContext; +import javax.validation.constraints.*; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", date = "2018-08-10T15:02:11.723+09:00[Asia/Tokyo]") +public class StoreApiServiceImpl extends StoreApiService { + @Override + public Response deleteOrder(String orderId, SecurityContext securityContext) throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + @Override + public Response getInventory(SecurityContext securityContext) throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + @Override + public Response getOrderById( @Min(1L) @Max(5L)Long orderId, SecurityContext securityContext) throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + @Override + public Response placeOrder(Order order, SecurityContext securityContext) throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } +} diff --git a/samples/server/petstore/jaxrs-jersey/src/main/java/org/openapitools/api/impl/UserApiServiceImpl.java b/samples/server/petstore/jaxrs-jersey/src/main/java/org/openapitools/api/impl/UserApiServiceImpl.java new file mode 100644 index 00000000000..fb2e323efc6 --- /dev/null +++ b/samples/server/petstore/jaxrs-jersey/src/main/java/org/openapitools/api/impl/UserApiServiceImpl.java @@ -0,0 +1,61 @@ +package org.openapitools.api.impl; + +import org.openapitools.api.*; +import org.openapitools.model.*; + +import java.util.List; +import org.openapitools.model.User; + +import java.util.List; +import org.openapitools.api.NotFoundException; + +import java.io.InputStream; + +import org.glassfish.jersey.media.multipart.FormDataContentDisposition; + +import javax.ws.rs.core.Response; +import javax.ws.rs.core.SecurityContext; +import javax.validation.constraints.*; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", date = "2018-08-10T15:02:11.723+09:00[Asia/Tokyo]") +public class UserApiServiceImpl extends UserApiService { + @Override + public Response createUser(User user, SecurityContext securityContext) throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + @Override + public Response createUsersWithArrayInput(List user, SecurityContext securityContext) throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + @Override + public Response createUsersWithListInput(List user, 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(); + } + @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 loginUser( @NotNull String username, @NotNull 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 updateUser(String username, User user, SecurityContext securityContext) throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } +} diff --git a/samples/server/petstore/jaxrs-jersey/src/main/webapp/WEB-INF/web.xml b/samples/server/petstore/jaxrs-jersey/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 00000000000..78aae0f4424 --- /dev/null +++ b/samples/server/petstore/jaxrs-jersey/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,63 @@ + + + + + jersey + org.glassfish.jersey.servlet.ServletContainer + + jersey.config.server.provider.packages + + io.swagger.jaxrs.listing, + io.swagger.sample.resource, + org.openapitools.api + + + + jersey.config.server.provider.classnames + org.glassfish.jersey.media.multipart.MultiPartFeature + + + jersey.config.server.wadl.disableWadl + true + + 1 + + + + Jersey2Config + io.swagger.jersey.config.JerseyJaxrsConfig + + api.version + 1.0.0 + + + swagger.api.title + OpenAPI Server + + + swagger.api.basepath + http://petstore.swagger.io/v2 + + + 2 + + + Bootstrap + org.openapitools.api.Bootstrap + 2 + + + jersey + /v2/* + + + ApiOriginFilter + org.openapitools.api.ApiOriginFilter + + + ApiOriginFilter + /* + +