/samples/server/petstore/jaxrs/jersey2-useTags/src/gen/java/org/openapitools/api/PetApi.java

https://github.com/OpenAPITools/openapi-generator · Java · 240 lines · 208 code · 32 blank · 0 comment · 7 complexity · 5ea4f63f5de77f06df8bb330b549e3c3 MD5 · raw file

  1. package org.openapitools.api;
  2. import org.openapitools.model.*;
  3. import org.openapitools.api.PetApiService;
  4. import org.openapitools.api.factories.PetApiServiceFactory;
  5. import io.swagger.annotations.ApiParam;
  6. import io.swagger.jaxrs.*;
  7. import java.io.File;
  8. import org.openapitools.model.ModelApiResponse;
  9. import org.openapitools.model.Pet;
  10. import java.util.Set;
  11. import java.util.Map;
  12. import java.util.List;
  13. import org.openapitools.api.NotFoundException;
  14. import java.io.InputStream;
  15. import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
  16. import org.glassfish.jersey.media.multipart.FormDataParam;
  17. import javax.servlet.ServletConfig;
  18. import javax.ws.rs.core.Context;
  19. import javax.ws.rs.core.Response;
  20. import javax.ws.rs.core.SecurityContext;
  21. import javax.ws.rs.*;
  22. import javax.validation.constraints.*;
  23. import javax.validation.Valid;
  24. @Path("")
  25. @io.swagger.annotations.Api(description = "the Pet API")
  26. @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen")
  27. public class PetApi {
  28. private final PetApiService delegate;
  29. public PetApi(@Context ServletConfig servletContext) {
  30. PetApiService delegate = null;
  31. if (servletContext != null) {
  32. String implClass = servletContext.getInitParameter("PetApi.implementation");
  33. if (implClass != null && !"".equals(implClass.trim())) {
  34. try {
  35. delegate = (PetApiService) Class.forName(implClass).newInstance();
  36. } catch (Exception e) {
  37. throw new RuntimeException(e);
  38. }
  39. }
  40. }
  41. if (delegate == null) {
  42. delegate = PetApiServiceFactory.getPetApi();
  43. }
  44. this.delegate = delegate;
  45. }
  46. @POST
  47. @Path("/pet")
  48. @Consumes({ "application/json", "application/xml" })
  49. @io.swagger.annotations.ApiOperation(value = "Add a new pet to the store", notes = "", response = Void.class, authorizations = {
  50. @io.swagger.annotations.Authorization(value = "petstore_auth", scopes = {
  51. @io.swagger.annotations.AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
  52. @io.swagger.annotations.AuthorizationScope(scope = "read:pets", description = "read your pets")
  53. })
  54. }, tags={ "pet", })
  55. @io.swagger.annotations.ApiResponses(value = {
  56. @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Void.class),
  57. @io.swagger.annotations.ApiResponse(code = 405, message = "Invalid input", response = Void.class) })
  58. public Response addPet(@ApiParam(value = "Pet object that needs to be added to the store", required = true) @NotNull @Valid Pet body
  59. ,@Context SecurityContext securityContext)
  60. throws NotFoundException {
  61. return delegate.addPet(body, securityContext);
  62. }
  63. @DELETE
  64. @Path("/pet/{petId}")
  65. @io.swagger.annotations.ApiOperation(value = "Deletes a pet", notes = "", response = Void.class, authorizations = {
  66. @io.swagger.annotations.Authorization(value = "petstore_auth", scopes = {
  67. @io.swagger.annotations.AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
  68. @io.swagger.annotations.AuthorizationScope(scope = "read:pets", description = "read your pets")
  69. })
  70. }, tags={ "pet", })
  71. @io.swagger.annotations.ApiResponses(value = {
  72. @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Void.class),
  73. @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid pet value", response = Void.class) })
  74. public Response deletePet(@ApiParam(value = "Pet id to delete", required = true) @PathParam("petId") @NotNull Long petId
  75. ,@ApiParam(value = "" )@HeaderParam("api_key") String apiKey
  76. ,@Context SecurityContext securityContext)
  77. throws NotFoundException {
  78. return delegate.deletePet(petId, apiKey, securityContext);
  79. }
  80. @GET
  81. @Path("/pet/findByStatus")
  82. @Produces({ "application/xml", "application/json" })
  83. @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 = {
  84. @io.swagger.annotations.Authorization(value = "petstore_auth", scopes = {
  85. @io.swagger.annotations.AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
  86. @io.swagger.annotations.AuthorizationScope(scope = "read:pets", description = "read your pets")
  87. })
  88. }, tags={ "pet", })
  89. @io.swagger.annotations.ApiResponses(value = {
  90. @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"),
  91. @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid status value", response = Void.class) })
  92. public Response findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter", required = true) @QueryParam("status") @NotNull @Valid List<String> status
  93. ,@Context SecurityContext securityContext)
  94. throws NotFoundException {
  95. return delegate.findPetsByStatus(status, securityContext);
  96. }
  97. @GET
  98. @Path("/pet/findByTags")
  99. @Produces({ "application/xml", "application/json" })
  100. @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 = "Set", authorizations = {
  101. @io.swagger.annotations.Authorization(value = "petstore_auth", scopes = {
  102. @io.swagger.annotations.AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
  103. @io.swagger.annotations.AuthorizationScope(scope = "read:pets", description = "read your pets")
  104. })
  105. }, tags={ "pet", })
  106. @io.swagger.annotations.ApiResponses(value = {
  107. @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "Set"),
  108. @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid tag value", response = Void.class) })
  109. public Response findPetsByTags(@ApiParam(value = "Tags to filter by", required = true) @QueryParam("tags") @NotNull @Valid Set<String> tags
  110. ,@Context SecurityContext securityContext)
  111. throws NotFoundException {
  112. return delegate.findPetsByTags(tags, securityContext);
  113. }
  114. @GET
  115. @Path("/pet/{petId}")
  116. @Produces({ "application/xml", "application/json" })
  117. @io.swagger.annotations.ApiOperation(value = "Find pet by ID", notes = "Returns a single pet", response = Pet.class, authorizations = {
  118. @io.swagger.annotations.Authorization(value = "api_key")
  119. }, tags={ "pet", })
  120. @io.swagger.annotations.ApiResponses(value = {
  121. @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Pet.class),
  122. @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied", response = Void.class),
  123. @io.swagger.annotations.ApiResponse(code = 404, message = "Pet not found", response = Void.class) })
  124. public Response getPetById(@ApiParam(value = "ID of pet to return", required = true) @PathParam("petId") @NotNull Long petId
  125. ,@Context SecurityContext securityContext)
  126. throws NotFoundException {
  127. return delegate.getPetById(petId, securityContext);
  128. }
  129. @PUT
  130. @Path("/pet")
  131. @Consumes({ "application/json", "application/xml" })
  132. @io.swagger.annotations.ApiOperation(value = "Update an existing pet", notes = "", response = Void.class, authorizations = {
  133. @io.swagger.annotations.Authorization(value = "petstore_auth", scopes = {
  134. @io.swagger.annotations.AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
  135. @io.swagger.annotations.AuthorizationScope(scope = "read:pets", description = "read your pets")
  136. })
  137. }, tags={ "pet", })
  138. @io.swagger.annotations.ApiResponses(value = {
  139. @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Void.class),
  140. @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied", response = Void.class),
  141. @io.swagger.annotations.ApiResponse(code = 404, message = "Pet not found", response = Void.class),
  142. @io.swagger.annotations.ApiResponse(code = 405, message = "Validation exception", response = Void.class) })
  143. public Response updatePet(@ApiParam(value = "Pet object that needs to be added to the store", required = true) @NotNull @Valid Pet body
  144. ,@Context SecurityContext securityContext)
  145. throws NotFoundException {
  146. return delegate.updatePet(body, securityContext);
  147. }
  148. @POST
  149. @Path("/pet/{petId}")
  150. @Consumes({ "application/x-www-form-urlencoded" })
  151. @io.swagger.annotations.ApiOperation(value = "Updates a pet in the store with form data", notes = "", response = Void.class, authorizations = {
  152. @io.swagger.annotations.Authorization(value = "petstore_auth", scopes = {
  153. @io.swagger.annotations.AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
  154. @io.swagger.annotations.AuthorizationScope(scope = "read:pets", description = "read your pets")
  155. })
  156. }, tags={ "pet", })
  157. @io.swagger.annotations.ApiResponses(value = {
  158. @io.swagger.annotations.ApiResponse(code = 405, message = "Invalid input", response = Void.class) })
  159. public Response updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated", required = true) @PathParam("petId") @NotNull Long petId
  160. ,@ApiParam(value = "Updated name of the pet") @FormParam("name") String name
  161. ,@ApiParam(value = "Updated status of the pet") @FormParam("status") String status
  162. ,@Context SecurityContext securityContext)
  163. throws NotFoundException {
  164. return delegate.updatePetWithForm(petId, name, status, securityContext);
  165. }
  166. @POST
  167. @Path("/pet/{petId}/uploadImage")
  168. @Consumes({ "multipart/form-data" })
  169. @Produces({ "application/json" })
  170. @io.swagger.annotations.ApiOperation(value = "uploads an image", notes = "", response = ModelApiResponse.class, authorizations = {
  171. @io.swagger.annotations.Authorization(value = "petstore_auth", scopes = {
  172. @io.swagger.annotations.AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
  173. @io.swagger.annotations.AuthorizationScope(scope = "read:pets", description = "read your pets")
  174. })
  175. }, tags={ "pet", })
  176. @io.swagger.annotations.ApiResponses(value = {
  177. @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) })
  178. public Response uploadFile(@ApiParam(value = "ID of pet to update", required = true) @PathParam("petId") @NotNull Long petId
  179. ,@ApiParam(value = "Additional data to pass to server")@FormDataParam("additionalMetadata") String additionalMetadata
  180. ,
  181. @FormDataParam("file") InputStream fileInputStream,
  182. @FormDataParam("file") FormDataContentDisposition fileDetail
  183. ,@Context SecurityContext securityContext)
  184. throws NotFoundException {
  185. return delegate.uploadFile(petId, additionalMetadata, fileInputStream, fileDetail, securityContext);
  186. }
  187. @POST
  188. @Path("/fake/{petId}/uploadImageWithRequiredFile")
  189. @Consumes({ "multipart/form-data" })
  190. @Produces({ "application/json" })
  191. @io.swagger.annotations.ApiOperation(value = "uploads an image (required)", notes = "", response = ModelApiResponse.class, authorizations = {
  192. @io.swagger.annotations.Authorization(value = "petstore_auth", scopes = {
  193. @io.swagger.annotations.AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
  194. @io.swagger.annotations.AuthorizationScope(scope = "read:pets", description = "read your pets")
  195. })
  196. }, tags={ "pet", })
  197. @io.swagger.annotations.ApiResponses(value = {
  198. @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) })
  199. public Response uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update", required = true) @PathParam("petId") @NotNull Long petId
  200. ,
  201. @FormDataParam("requiredFile") InputStream requiredFileInputStream,
  202. @FormDataParam("requiredFile") FormDataContentDisposition requiredFileDetail
  203. ,@ApiParam(value = "Additional data to pass to server")@FormDataParam("additionalMetadata") String additionalMetadata
  204. ,@Context SecurityContext securityContext)
  205. throws NotFoundException {
  206. return delegate.uploadFileWithRequiredFile(petId, requiredFileInputStream, requiredFileDetail, additionalMetadata, securityContext);
  207. }
  208. }