From 67b24330c97290929626bf847d3b32fb9e76f824 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Wed, 24 Sep 2025 17:15:08 +0800 Subject: [PATCH] Add tests for jaxrs cxf swagger2 client (#22019) * add test for jaxrs cxf swagger2 client * revert --- .../workflows/samples-java-client-jdk11.yaml | 3 + bin/configs/jaxrs-cxf-client-swagger2.yaml | 8 + .../resources/JavaJaxRS/cxf/api_test.mustache | 2 + .../.openapi-generator-ignore | 23 ++ .../.openapi-generator/FILES | 10 + .../.openapi-generator/VERSION | 1 + .../jaxrs-cxf-client-swagger2/pom.xml | 197 ++++++++++++++ .../gen/java/org/openapitools/api/PetApi.java | 161 ++++++++++++ .../java/org/openapitools/api/StoreApi.java | 97 +++++++ .../java/org/openapitools/api/UserApi.java | 153 +++++++++++ .../java/org/openapitools/model/Category.java | 98 +++++++ .../openapitools/model/ModelApiResponse.java | 122 +++++++++ .../java/org/openapitools/model/Order.java | 231 +++++++++++++++++ .../gen/java/org/openapitools/model/Pet.java | 245 ++++++++++++++++++ .../gen/java/org/openapitools/model/Tag.java | 98 +++++++ .../gen/java/org/openapitools/model/User.java | 245 ++++++++++++++++++ .../java/org/openapitools/api/PetApiTest.java | 213 +++++++++++++++ .../org/openapitools/api/StoreApiTest.java | 133 ++++++++++ .../org/openapitools/api/UserApiTest.java | 208 +++++++++++++++ 19 files changed, 2248 insertions(+) create mode 100644 bin/configs/jaxrs-cxf-client-swagger2.yaml create mode 100644 samples/client/petstore/jaxrs-cxf-client-swagger2/.openapi-generator-ignore create mode 100644 samples/client/petstore/jaxrs-cxf-client-swagger2/.openapi-generator/FILES create mode 100644 samples/client/petstore/jaxrs-cxf-client-swagger2/.openapi-generator/VERSION create mode 100644 samples/client/petstore/jaxrs-cxf-client-swagger2/pom.xml create mode 100644 samples/client/petstore/jaxrs-cxf-client-swagger2/src/gen/java/org/openapitools/api/PetApi.java create mode 100644 samples/client/petstore/jaxrs-cxf-client-swagger2/src/gen/java/org/openapitools/api/StoreApi.java create mode 100644 samples/client/petstore/jaxrs-cxf-client-swagger2/src/gen/java/org/openapitools/api/UserApi.java create mode 100644 samples/client/petstore/jaxrs-cxf-client-swagger2/src/gen/java/org/openapitools/model/Category.java create mode 100644 samples/client/petstore/jaxrs-cxf-client-swagger2/src/gen/java/org/openapitools/model/ModelApiResponse.java create mode 100644 samples/client/petstore/jaxrs-cxf-client-swagger2/src/gen/java/org/openapitools/model/Order.java create mode 100644 samples/client/petstore/jaxrs-cxf-client-swagger2/src/gen/java/org/openapitools/model/Pet.java create mode 100644 samples/client/petstore/jaxrs-cxf-client-swagger2/src/gen/java/org/openapitools/model/Tag.java create mode 100644 samples/client/petstore/jaxrs-cxf-client-swagger2/src/gen/java/org/openapitools/model/User.java create mode 100644 samples/client/petstore/jaxrs-cxf-client-swagger2/src/test/java/org/openapitools/api/PetApiTest.java create mode 100644 samples/client/petstore/jaxrs-cxf-client-swagger2/src/test/java/org/openapitools/api/StoreApiTest.java create mode 100644 samples/client/petstore/jaxrs-cxf-client-swagger2/src/test/java/org/openapitools/api/UserApiTest.java diff --git a/.github/workflows/samples-java-client-jdk11.yaml b/.github/workflows/samples-java-client-jdk11.yaml index 70c220bb87b..158fce1473c 100644 --- a/.github/workflows/samples-java-client-jdk11.yaml +++ b/.github/workflows/samples-java-client-jdk11.yaml @@ -5,6 +5,7 @@ on: paths: - 'samples/client/petstore/java/**' - samples/client/petstore/jaxrs-cxf-client/** + - samples/client/petstore/jaxrs-cxf-client-swagger2/** - samples/client/petstore/java-micronaut-client/** - samples/openapi3/client/petstore/java/jersey2-java8-special-characters/** - samples/openapi3/client/petstore/java/jersey2-java8-swagger1/** @@ -27,6 +28,7 @@ on: paths: - 'samples/client/petstore/java/**' - samples/client/petstore/jaxrs-cxf-client/** + - samples/client/petstore/jaxrs-cxf-client-swagger2/** - samples/client/petstore/java-micronaut-client/** - samples/openapi3/client/petstore/java/jersey2-java8-special-characters/** - samples/openapi3/client/petstore/java/jersey2-java8-swagger1/** @@ -54,6 +56,7 @@ jobs: matrix: sample: # clients + - samples/client/petstore/jaxrs-cxf-client-swagger2 - samples/client/petstore/jaxrs-cxf-client - samples/client/petstore/java/native - samples/client/petstore/java/native-async diff --git a/bin/configs/jaxrs-cxf-client-swagger2.yaml b/bin/configs/jaxrs-cxf-client-swagger2.yaml new file mode 100644 index 00000000000..7efef0f734a --- /dev/null +++ b/bin/configs/jaxrs-cxf-client-swagger2.yaml @@ -0,0 +1,8 @@ +generatorName: jaxrs-cxf-client +outputDir: samples/client/petstore/jaxrs-cxf-client-swagger2 +inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml +templateDir: modules/openapi-generator/src/main/resources/JavaJaxRS/cxf +additionalProperties: + artifactId: jaxrs-cxf-petstore-swagger2 + documentationProvider: swagger2 + annotationLibrary: swagger2 diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf/api_test.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf/api_test.mustache index bbaf8e4d999..6e760e411a8 100644 --- a/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf/api_test.mustache +++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf/api_test.mustache @@ -8,7 +8,9 @@ import org.junit.Test; import org.junit.Before; import static org.junit.Assert.*; +{{#useBeanValidation}} import {{javaxPackage}}.validation.Valid; +{{/useBeanValidation}} import {{javaxPackage}}.ws.rs.core.Response; import org.apache.cxf.jaxrs.client.JAXRSClientFactory; import org.apache.cxf.jaxrs.client.ClientConfiguration; diff --git a/samples/client/petstore/jaxrs-cxf-client-swagger2/.openapi-generator-ignore b/samples/client/petstore/jaxrs-cxf-client-swagger2/.openapi-generator-ignore new file mode 100644 index 00000000000..7484ee590a3 --- /dev/null +++ b/samples/client/petstore/jaxrs-cxf-client-swagger2/.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/client/petstore/jaxrs-cxf-client-swagger2/.openapi-generator/FILES b/samples/client/petstore/jaxrs-cxf-client-swagger2/.openapi-generator/FILES new file mode 100644 index 00000000000..a32a0965f8c --- /dev/null +++ b/samples/client/petstore/jaxrs-cxf-client-swagger2/.openapi-generator/FILES @@ -0,0 +1,10 @@ +pom.xml +src/gen/java/org/openapitools/api/PetApi.java +src/gen/java/org/openapitools/api/StoreApi.java +src/gen/java/org/openapitools/api/UserApi.java +src/gen/java/org/openapitools/model/Category.java +src/gen/java/org/openapitools/model/ModelApiResponse.java +src/gen/java/org/openapitools/model/Order.java +src/gen/java/org/openapitools/model/Pet.java +src/gen/java/org/openapitools/model/Tag.java +src/gen/java/org/openapitools/model/User.java diff --git a/samples/client/petstore/jaxrs-cxf-client-swagger2/.openapi-generator/VERSION b/samples/client/petstore/jaxrs-cxf-client-swagger2/.openapi-generator/VERSION new file mode 100644 index 00000000000..5e528295308 --- /dev/null +++ b/samples/client/petstore/jaxrs-cxf-client-swagger2/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.16.0-SNAPSHOT diff --git a/samples/client/petstore/jaxrs-cxf-client-swagger2/pom.xml b/samples/client/petstore/jaxrs-cxf-client-swagger2/pom.xml new file mode 100644 index 00000000000..999d07509b2 --- /dev/null +++ b/samples/client/petstore/jaxrs-cxf-client-swagger2/pom.xml @@ -0,0 +1,197 @@ + + 4.0.0 + org.openapitools + jaxrs-cxf-petstore-swagger2 + jar + jaxrs-cxf-petstore-swagger2 + This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + 1.0.0 + + + + src/main/java + + + maven-failsafe-plugin + 2.6 + + + + integration-test + verify + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.9.1 + + + add-source + generate-sources + + add-source + + + + src/gen/java + + + + + + + + + + + com.fasterxml.jackson + jackson-bom + ${jackson-jaxrs-version} + pom + import + + + + + + io.swagger.core.v3 + swagger-annotations + ${swagger-annotations-version} + + + ch.qos.logback + logback-classic + ${logback-version} + compile + + + ch.qos.logback + logback-core + ${logback-version} + compile + + + junit + junit + ${junit-version} + test + + + + org.apache.cxf + cxf-rt-rs-client + ${cxf-version} + test + + + + + org.apache.cxf + cxf-rt-frontend-jaxrs + ${cxf-version} + compile + + + org.apache.cxf + cxf-rt-rs-service-description + ${cxf-version} + compile + + + org.apache.cxf + cxf-rt-ws-policy + ${cxf-version} + compile + + + org.apache.cxf + cxf-rt-wsdl + ${cxf-version} + compile + + + com.fasterxml.jackson.jaxrs + jackson-jaxrs-json-provider + ${jackson-jaxrs-version} + compile + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + ${jackson-jaxrs-version} + + + jakarta.annotation + jakarta.annotation-api + ${jakarta-annotation-version} + provided + + + joda-time + joda-time + 2.10.13 + + + + + sonatype-snapshots + https://oss.sonatype.org/content/repositories/snapshots + + true + + + + + 1.8 + ${java.version} + ${java.version} + 2.2.7 + 9.2.9.v20150224 + 4.13.2 + 1.5.13 + 3.5.9 + 2.17.1 + 1.3.5 + UTF-8 + + diff --git a/samples/client/petstore/jaxrs-cxf-client-swagger2/src/gen/java/org/openapitools/api/PetApi.java b/samples/client/petstore/jaxrs-cxf-client-swagger2/src/gen/java/org/openapitools/api/PetApi.java new file mode 100644 index 00000000000..f3e82fe5260 --- /dev/null +++ b/samples/client/petstore/jaxrs-cxf-client-swagger2/src/gen/java/org/openapitools/api/PetApi.java @@ -0,0 +1,161 @@ +package org.openapitools.api; + +import java.io.File; +import org.openapitools.model.ModelApiResponse; +import org.openapitools.model.Pet; + +import java.util.List; +import java.util.Map; +import javax.ws.rs.*; +import org.apache.cxf.jaxrs.ext.multipart.*; + +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.info.Info; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; + +/** + * 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. + * + */ +@Path("/pet") +@OpenAPIDefinition( + info = @Info( + title = "OpenAPI Petstore", + description = "This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.", + version = "1.0.0" + ) +) +public interface PetApi { + + /** + * Add a new pet to the store + * + * + * + */ + @POST + + @Consumes({ "application/json", "application/xml" }) + @Produces({ "application/xml", "application/json" }) + @Operation(operationId = "addPet", summary = "Add a new pet to the store", tags={ }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "405", description = "Invalid input") }) + public Pet addPet(Pet pet); + + /** + * Deletes a pet + * + * + * + */ + @DELETE + @Path("/{petId}") + @Operation(operationId = "deletePet", summary = "Deletes a pet", tags={ }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Invalid pet value") }) + public void deletePet(@PathParam("petId") Long petId, @HeaderParam("api_key") String apiKey); + + /** + * Finds Pets by status + * + * Multiple status values can be provided with comma separated strings + * + */ + @GET + @Path("/findByStatus") + @Produces({ "application/xml", "application/json" }) + @Operation(operationId = "findPetsByStatus", summary = "Finds Pets by status", tags={ }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Pet.class)))), + @ApiResponse(responseCode = "400", description = "Invalid status value") }) + public List findPetsByStatus(@QueryParam("status") List status); + + /** + * Finds Pets by tags + * + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * + */ + @GET + @Path("/findByTags") + @Produces({ "application/xml", "application/json" }) + @Operation(operationId = "findPetsByTags", summary = "Finds Pets by tags", deprecated = true, tags={ }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Pet.class)))), + @ApiResponse(responseCode = "400", description = "Invalid tag value") }) + public List findPetsByTags(@QueryParam("tags") List tags); + + /** + * Find pet by ID + * + * Returns a single pet + * + */ + @GET + @Path("/{petId}") + @Produces({ "application/xml", "application/json" }) + @Operation(operationId = "getPetById", summary = "Find pet by ID", tags={ }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found") }) + public Pet getPetById(@PathParam("petId") Long petId); + + /** + * Update an existing pet + * + * + * + */ + @PUT + + @Consumes({ "application/json", "application/xml" }) + @Produces({ "application/xml", "application/json" }) + @Operation(operationId = "updatePet", summary = "Update an existing pet", tags={ }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found"), + @ApiResponse(responseCode = "405", description = "Validation exception") }) + public Pet updatePet(Pet pet); + + /** + * Updates a pet in the store with form data + * + * + * + */ + @POST + @Path("/{petId}") + @Consumes({ "application/x-www-form-urlencoded" }) + @Operation(operationId = "updatePetWithForm", summary = "Updates a pet in the store with form data", tags={ }) + @ApiResponses(value = { + @ApiResponse(responseCode = "405", description = "Invalid input") }) + public void updatePetWithForm(@PathParam("petId") Long petId, @Multipart(value = "name", required = false) String name, @Multipart(value = "status", required = false) String status); + + /** + * uploads an image + * + * + * + */ + @POST + @Path("/{petId}/uploadImage") + @Consumes({ "multipart/form-data" }) + @Produces({ "application/json" }) + @Operation(operationId = "uploadFile", summary = "uploads an image", tags={ }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = ModelApiResponse.class))) }) + public ModelApiResponse uploadFile(@PathParam("petId") Long petId, @Multipart(value = "additionalMetadata", required = false) String additionalMetadata, @Multipart(value = "file" , required = false) Attachment _fileDetail); +} diff --git a/samples/client/petstore/jaxrs-cxf-client-swagger2/src/gen/java/org/openapitools/api/StoreApi.java b/samples/client/petstore/jaxrs-cxf-client-swagger2/src/gen/java/org/openapitools/api/StoreApi.java new file mode 100644 index 00000000000..ec282a9dd40 --- /dev/null +++ b/samples/client/petstore/jaxrs-cxf-client-swagger2/src/gen/java/org/openapitools/api/StoreApi.java @@ -0,0 +1,97 @@ +package org.openapitools.api; + +import org.openapitools.model.Order; + +import java.util.List; +import java.util.Map; +import javax.ws.rs.*; +import org.apache.cxf.jaxrs.ext.multipart.*; + +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.info.Info; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; + +/** + * 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. + * + */ +@Path("/store") +@OpenAPIDefinition( + info = @Info( + title = "OpenAPI Petstore", + description = "This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.", + version = "1.0.0" + ) +) +public interface StoreApi { + + /** + * Delete purchase order by ID + * + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * + */ + @DELETE + @Path("/order/{orderId}") + @Operation(operationId = "deleteOrder", summary = "Delete purchase order by ID", tags={ }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Order not found") }) + public void deleteOrder(@PathParam("orderId") String orderId); + + /** + * Returns pet inventories by status + * + * Returns a map of status codes to quantities + * + */ + @GET + @Path("/inventory") + @Produces({ "application/json" }) + @Operation(operationId = "getInventory", summary = "Returns pet inventories by status", tags={ }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Map.class)))) }) + public Map getInventory(); + + /** + * Find purchase order by ID + * + * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + * + */ + @GET + @Path("/order/{orderId}") + @Produces({ "application/xml", "application/json" }) + @Operation(operationId = "getOrderById", summary = "Find purchase order by ID", tags={ }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = Order.class))), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Order not found") }) + public Order getOrderById(@PathParam("orderId") Long orderId); + + /** + * Place an order for a pet + * + * + * + */ + @POST + @Path("/order") + @Consumes({ "application/json" }) + @Produces({ "application/xml", "application/json" }) + @Operation(operationId = "placeOrder", summary = "Place an order for a pet", tags={ }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = Order.class))), + @ApiResponse(responseCode = "400", description = "Invalid Order") }) + public Order placeOrder(Order order); +} diff --git a/samples/client/petstore/jaxrs-cxf-client-swagger2/src/gen/java/org/openapitools/api/UserApi.java b/samples/client/petstore/jaxrs-cxf-client-swagger2/src/gen/java/org/openapitools/api/UserApi.java new file mode 100644 index 00000000000..b9a3f39b069 --- /dev/null +++ b/samples/client/petstore/jaxrs-cxf-client-swagger2/src/gen/java/org/openapitools/api/UserApi.java @@ -0,0 +1,153 @@ +package org.openapitools.api; + +import java.util.Date; +import org.openapitools.model.User; + +import java.util.List; +import java.util.Map; +import javax.ws.rs.*; +import org.apache.cxf.jaxrs.ext.multipart.*; + +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.info.Info; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; + +/** + * 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. + * + */ +@Path("/user") +@OpenAPIDefinition( + info = @Info( + title = "OpenAPI Petstore", + description = "This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.", + version = "1.0.0" + ) +) +public interface UserApi { + + /** + * Create user + * + * This can only be done by the logged in user. + * + */ + @POST + + @Consumes({ "application/json" }) + @Operation(operationId = "createUser", summary = "Create user", tags={ }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation") }) + public void createUser(User user); + + /** + * Creates list of users with given input array + * + * + * + */ + @POST + @Path("/createWithArray") + @Consumes({ "application/json" }) + @Operation(operationId = "createUsersWithArrayInput", summary = "Creates list of users with given input array", tags={ }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation") }) + public void createUsersWithArrayInput(List user); + + /** + * Creates list of users with given input array + * + * + * + */ + @POST + @Path("/createWithList") + @Consumes({ "application/json" }) + @Operation(operationId = "createUsersWithListInput", summary = "Creates list of users with given input array", tags={ }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation") }) + public void createUsersWithListInput(List user); + + /** + * Delete user + * + * This can only be done by the logged in user. + * + */ + @DELETE + @Path("/{username}") + @Operation(operationId = "deleteUser", summary = "Delete user", tags={ }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Invalid username supplied"), + @ApiResponse(responseCode = "404", description = "User not found") }) + public void deleteUser(@PathParam("username") String username); + + /** + * Get user by user name + * + * + * + */ + @GET + @Path("/{username}") + @Produces({ "application/xml", "application/json" }) + @Operation(operationId = "getUserByName", summary = "Get user by user name", tags={ }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = User.class))), + @ApiResponse(responseCode = "400", description = "Invalid username supplied"), + @ApiResponse(responseCode = "404", description = "User not found") }) + public User getUserByName(@PathParam("username") String username); + + /** + * Logs user into the system + * + * + * + */ + @GET + @Path("/login") + @Produces({ "application/xml", "application/json" }) + @Operation(operationId = "loginUser", summary = "Logs user into the system", tags={ }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = String.class))), + @ApiResponse(responseCode = "400", description = "Invalid username/password supplied") }) + public String loginUser(@QueryParam("username") String username, @QueryParam("password") String password); + + /** + * Logs out current logged in user session + * + * + * + */ + @GET + @Path("/logout") + @Operation(operationId = "logoutUser", summary = "Logs out current logged in user session", tags={ }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation") }) + public void logoutUser(); + + /** + * Updated user + * + * This can only be done by the logged in user. + * + */ + @PUT + @Path("/{username}") + @Consumes({ "application/json" }) + @Operation(operationId = "updateUser", summary = "Updated user", tags={ }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Invalid user supplied"), + @ApiResponse(responseCode = "404", description = "User not found") }) + public void updateUser(@PathParam("username") String username, User user); +} diff --git a/samples/client/petstore/jaxrs-cxf-client-swagger2/src/gen/java/org/openapitools/model/Category.java b/samples/client/petstore/jaxrs-cxf-client-swagger2/src/gen/java/org/openapitools/model/Category.java new file mode 100644 index 00000000000..b87fe592443 --- /dev/null +++ b/samples/client/petstore/jaxrs-cxf-client-swagger2/src/gen/java/org/openapitools/model/Category.java @@ -0,0 +1,98 @@ +package org.openapitools.model; + + +import io.swagger.v3.oas.annotations.media.Schema; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * A category for a pet + */ +@Schema(description="A category for a pet") + +public class Category { + + @Schema(description = "") + + private Long id; + + @Schema(description = "") + + private String name; + /** + * Get id + * @return id + **/ + @JsonProperty("id") + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Category id(Long id) { + this.id = id; + return this; + } + + /** + * Get name + * @return name + **/ + @JsonProperty("name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Category name(String name) { + this.name = name; + return this; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Category category = (Category) o; + return Objects.equals(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 static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/client/petstore/jaxrs-cxf-client-swagger2/src/gen/java/org/openapitools/model/ModelApiResponse.java b/samples/client/petstore/jaxrs-cxf-client-swagger2/src/gen/java/org/openapitools/model/ModelApiResponse.java new file mode 100644 index 00000000000..fa490f33f00 --- /dev/null +++ b/samples/client/petstore/jaxrs-cxf-client-swagger2/src/gen/java/org/openapitools/model/ModelApiResponse.java @@ -0,0 +1,122 @@ +package org.openapitools.model; + + +import io.swagger.v3.oas.annotations.media.Schema; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Describes the result of uploading an image resource + */ +@Schema(description="Describes the result of uploading an image resource") + +public class ModelApiResponse { + + @Schema(description = "") + + private Integer code; + + @Schema(description = "") + + private String type; + + @Schema(description = "") + + private String message; + /** + * Get code + * @return code + **/ + @JsonProperty("code") + public Integer getCode() { + return code; + } + + public void setCode(Integer code) { + this.code = code; + } + + public ModelApiResponse code(Integer code) { + this.code = code; + return this; + } + + /** + * Get type + * @return type + **/ + @JsonProperty("type") + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public ModelApiResponse type(String type) { + this.type = type; + return this; + } + + /** + * Get message + * @return message + **/ + @JsonProperty("message") + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public ModelApiResponse message(String message) { + this.message = message; + return this; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelApiResponse _apiResponse = (ModelApiResponse) o; + return Objects.equals(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 static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/client/petstore/jaxrs-cxf-client-swagger2/src/gen/java/org/openapitools/model/Order.java b/samples/client/petstore/jaxrs-cxf-client-swagger2/src/gen/java/org/openapitools/model/Order.java new file mode 100644 index 00000000000..cc6bfed1644 --- /dev/null +++ b/samples/client/petstore/jaxrs-cxf-client-swagger2/src/gen/java/org/openapitools/model/Order.java @@ -0,0 +1,231 @@ +package org.openapitools.model; + +import java.util.Date; + +import io.swagger.v3.oas.annotations.media.Schema; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * An order for a pets from the pet store + */ +@Schema(description="An order for a pets from the pet store") + +public class Order { + + @Schema(description = "") + + private Long id; + + @Schema(description = "") + + private Long petId; + + @Schema(description = "") + + private Integer quantity; + + @Schema(description = "") + + private Date shipDate; + +public enum StatusEnum { + +PLACED(String.valueOf("placed")), APPROVED(String.valueOf("approved")), DELIVERED(String.valueOf("delivered")); + + + private String value; + + StatusEnum (String v) { + value = v; + } + + public String value() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} + + /** + * Order Status + */ + @Schema(description = "Order Status") + + private StatusEnum status; + + @Schema(description = "") + + private Boolean complete = false; + /** + * Get id + * @return id + **/ + @JsonProperty("id") + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Order id(Long id) { + this.id = id; + return this; + } + + /** + * Get petId + * @return petId + **/ + @JsonProperty("petId") + public Long getPetId() { + return petId; + } + + public void setPetId(Long petId) { + this.petId = petId; + } + + public Order petId(Long petId) { + this.petId = petId; + return this; + } + + /** + * Get quantity + * @return quantity + **/ + @JsonProperty("quantity") + public Integer getQuantity() { + return quantity; + } + + public void setQuantity(Integer quantity) { + this.quantity = quantity; + } + + public Order quantity(Integer quantity) { + this.quantity = quantity; + return this; + } + + /** + * Get shipDate + * @return shipDate + **/ + @JsonProperty("shipDate") + public Date getShipDate() { + return shipDate; + } + + public void setShipDate(Date shipDate) { + this.shipDate = shipDate; + } + + public Order shipDate(Date shipDate) { + this.shipDate = shipDate; + return this; + } + + /** + * Order Status + * @return status + **/ + @JsonProperty("status") + public String getStatus() { + if (status == null) { + return null; + } + return status.value(); + } + + public void setStatus(StatusEnum status) { + this.status = status; + } + + public Order status(StatusEnum status) { + this.status = status; + return this; + } + + /** + * Get complete + * @return complete + **/ + @JsonProperty("complete") + public Boolean getComplete() { + return complete; + } + + public void setComplete(Boolean complete) { + this.complete = complete; + } + + public Order complete(Boolean complete) { + this.complete = complete; + return this; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Order order = (Order) o; + return Objects.equals(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 static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/client/petstore/jaxrs-cxf-client-swagger2/src/gen/java/org/openapitools/model/Pet.java b/samples/client/petstore/jaxrs-cxf-client-swagger2/src/gen/java/org/openapitools/model/Pet.java new file mode 100644 index 00000000000..49c860b8bc1 --- /dev/null +++ b/samples/client/petstore/jaxrs-cxf-client-swagger2/src/gen/java/org/openapitools/model/Pet.java @@ -0,0 +1,245 @@ +package org.openapitools.model; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.openapitools.model.Category; +import org.openapitools.model.Tag; + +import io.swagger.v3.oas.annotations.media.Schema; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * A pet for sale in the pet store + */ +@Schema(description="A pet for sale in the pet store") + +public class Pet { + + @Schema(description = "") + + private Long id; + + @Schema(description = "") + + private Category category; + + @Schema(description = "", example = "doggie", requiredMode = Schema.RequiredMode.REQUIRED) + + private String name; + + @Schema(description = "", requiredMode = Schema.RequiredMode.REQUIRED) + + private List photoUrls = new ArrayList<>(); + + @Schema(description = "") + + private List tags = new ArrayList<>(); + +public enum StatusEnum { + +AVAILABLE(String.valueOf("available")), PENDING(String.valueOf("pending")), SOLD(String.valueOf("sold")); + + + private String value; + + StatusEnum (String v) { + value = v; + } + + public String value() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} + + /** + * pet status in the store + */ + @Schema(description = "pet status in the store") + + private StatusEnum status; + /** + * Get id + * @return id + **/ + @JsonProperty("id") + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Pet id(Long id) { + this.id = id; + return this; + } + + /** + * Get category + * @return category + **/ + @JsonProperty("category") + public Category getCategory() { + return category; + } + + public void setCategory(Category category) { + this.category = category; + } + + public Pet category(Category category) { + this.category = category; + return this; + } + + /** + * Get name + * @return name + **/ + @JsonProperty("name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Pet name(String name) { + this.name = name; + return this; + } + + /** + * Get photoUrls + * @return photoUrls + **/ + @JsonProperty("photoUrls") + public List getPhotoUrls() { + return photoUrls; + } + + public void setPhotoUrls(List photoUrls) { + this.photoUrls = photoUrls; + } + + public Pet photoUrls(List photoUrls) { + this.photoUrls = photoUrls; + return this; + } + + public Pet addPhotoUrlsItem(String photoUrlsItem) { + this.photoUrls.add(photoUrlsItem); + return this; + } + + /** + * Get tags + * @return tags + **/ + @JsonProperty("tags") + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + public Pet tags(List tags) { + this.tags = tags; + return this; + } + + public Pet addTagsItem(Tag tagsItem) { + this.tags.add(tagsItem); + return this; + } + + /** + * pet status in the store + * @return status + **/ + @JsonProperty("status") + public String getStatus() { + if (status == null) { + return null; + } + return status.value(); + } + + public void setStatus(StatusEnum status) { + this.status = status; + } + + public Pet status(StatusEnum status) { + this.status = status; + return this; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Pet pet = (Pet) o; + return Objects.equals(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 static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/client/petstore/jaxrs-cxf-client-swagger2/src/gen/java/org/openapitools/model/Tag.java b/samples/client/petstore/jaxrs-cxf-client-swagger2/src/gen/java/org/openapitools/model/Tag.java new file mode 100644 index 00000000000..2d6aa396bc0 --- /dev/null +++ b/samples/client/petstore/jaxrs-cxf-client-swagger2/src/gen/java/org/openapitools/model/Tag.java @@ -0,0 +1,98 @@ +package org.openapitools.model; + + +import io.swagger.v3.oas.annotations.media.Schema; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * A tag for a pet + */ +@Schema(description="A tag for a pet") + +public class Tag { + + @Schema(description = "") + + private Long id; + + @Schema(description = "") + + private String name; + /** + * Get id + * @return id + **/ + @JsonProperty("id") + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Tag id(Long id) { + this.id = id; + return this; + } + + /** + * Get name + * @return name + **/ + @JsonProperty("name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Tag name(String name) { + this.name = name; + return this; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Tag tag = (Tag) o; + return Objects.equals(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 static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/client/petstore/jaxrs-cxf-client-swagger2/src/gen/java/org/openapitools/model/User.java b/samples/client/petstore/jaxrs-cxf-client-swagger2/src/gen/java/org/openapitools/model/User.java new file mode 100644 index 00000000000..a26d89d5f60 --- /dev/null +++ b/samples/client/petstore/jaxrs-cxf-client-swagger2/src/gen/java/org/openapitools/model/User.java @@ -0,0 +1,245 @@ +package org.openapitools.model; + + +import io.swagger.v3.oas.annotations.media.Schema; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * A User who is purchasing from the pet store + */ +@Schema(description="A User who is purchasing from the pet store") + +public class User { + + @Schema(description = "") + + private Long id; + + @Schema(description = "") + + private String username; + + @Schema(description = "") + + private String firstName; + + @Schema(description = "") + + private String lastName; + + @Schema(description = "") + + private String email; + + @Schema(description = "") + + private String password; + + @Schema(description = "") + + private String phone; + + /** + * User Status + */ + @Schema(description = "User Status") + + private Integer userStatus; + /** + * Get id + * @return id + **/ + @JsonProperty("id") + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public User id(Long id) { + this.id = id; + return this; + } + + /** + * Get username + * @return username + **/ + @JsonProperty("username") + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public User username(String username) { + this.username = username; + return this; + } + + /** + * Get firstName + * @return firstName + **/ + @JsonProperty("firstName") + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public User firstName(String firstName) { + this.firstName = firstName; + return this; + } + + /** + * Get lastName + * @return lastName + **/ + @JsonProperty("lastName") + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public User lastName(String lastName) { + this.lastName = lastName; + return this; + } + + /** + * Get email + * @return email + **/ + @JsonProperty("email") + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public User email(String email) { + this.email = email; + return this; + } + + /** + * Get password + * @return password + **/ + @JsonProperty("password") + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public User password(String password) { + this.password = password; + return this; + } + + /** + * Get phone + * @return phone + **/ + @JsonProperty("phone") + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public User phone(String phone) { + this.phone = phone; + return this; + } + + /** + * User Status + * @return userStatus + **/ + @JsonProperty("userStatus") + public Integer getUserStatus() { + return userStatus; + } + + public void setUserStatus(Integer userStatus) { + this.userStatus = userStatus; + } + + public User userStatus(Integer userStatus) { + this.userStatus = userStatus; + return this; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + User user = (User) o; + return Objects.equals(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 static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/client/petstore/jaxrs-cxf-client-swagger2/src/test/java/org/openapitools/api/PetApiTest.java b/samples/client/petstore/jaxrs-cxf-client-swagger2/src/test/java/org/openapitools/api/PetApiTest.java new file mode 100644 index 00000000000..2e572bcdebe --- /dev/null +++ b/samples/client/petstore/jaxrs-cxf-client-swagger2/src/test/java/org/openapitools/api/PetApiTest.java @@ -0,0 +1,213 @@ +/* + * 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. + * + * The version of the OpenAPI document: 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.api; + +import java.io.File; +import org.openapitools.model.ModelApiResponse; +import org.openapitools.model.Pet; +import org.junit.Test; +import org.junit.Before; +import static org.junit.Assert.*; + +import javax.ws.rs.core.Response; +import org.apache.cxf.jaxrs.client.JAXRSClientFactory; +import org.apache.cxf.jaxrs.client.ClientConfiguration; +import org.apache.cxf.jaxrs.client.WebClient; + + +import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + + + +/** + * 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. + * + * API tests for PetApi + */ +public class PetApiTest { + + + private PetApi api; + + @Before + public void setup() { + JacksonJsonProvider provider = new JacksonJsonProvider(); + List providers = new ArrayList(); + providers.add(provider); + + api = JAXRSClientFactory.create("http://petstore.swagger.io/v2", PetApi.class, providers); + org.apache.cxf.jaxrs.client.Client client = WebClient.client(api); + + ClientConfiguration config = WebClient.getConfig(client); + } + + + /** + * Add a new pet to the store + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void addPetTest() { + Pet pet = null; + //Pet response = api.addPet(pet); + //assertNotNull(response); + // TODO: test validations + + + } + + /** + * Deletes a pet + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void deletePetTest() { + Long petId = null; + String apiKey = null; + //api.deletePet(petId, apiKey); + + // TODO: test validations + + + } + + /** + * Finds Pets by status + * + * Multiple status values can be provided with comma separated strings + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void findPetsByStatusTest() { + List status = null; + //List response = api.findPetsByStatus(status); + //assertNotNull(response); + // TODO: test validations + + + } + + /** + * Finds Pets by tags + * + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void findPetsByTagsTest() { + List tags = null; + //List response = api.findPetsByTags(tags); + //assertNotNull(response); + // TODO: test validations + + + } + + /** + * Find pet by ID + * + * Returns a single pet + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void getPetByIdTest() { + Long petId = null; + //Pet response = api.getPetById(petId); + //assertNotNull(response); + // TODO: test validations + + + } + + /** + * Update an existing pet + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void updatePetTest() { + Pet pet = null; + //Pet response = api.updatePet(pet); + //assertNotNull(response); + // TODO: test validations + + + } + + /** + * Updates a pet in the store with form data + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void updatePetWithFormTest() { + Long petId = null; + String name = null; + String status = null; + //api.updatePetWithForm(petId, name, status); + + // TODO: test validations + + + } + + /** + * uploads an image + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void uploadFileTest() { + Long petId = null; + String additionalMetadata = null; + File _file = null; + //ModelApiResponse response = api.uploadFile(petId, additionalMetadata, _file); + //assertNotNull(response); + // TODO: test validations + + + } + +} diff --git a/samples/client/petstore/jaxrs-cxf-client-swagger2/src/test/java/org/openapitools/api/StoreApiTest.java b/samples/client/petstore/jaxrs-cxf-client-swagger2/src/test/java/org/openapitools/api/StoreApiTest.java new file mode 100644 index 00000000000..7a041c546e6 --- /dev/null +++ b/samples/client/petstore/jaxrs-cxf-client-swagger2/src/test/java/org/openapitools/api/StoreApiTest.java @@ -0,0 +1,133 @@ +/* + * 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. + * + * The version of the OpenAPI document: 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.api; + +import org.openapitools.model.Order; +import org.junit.Test; +import org.junit.Before; +import static org.junit.Assert.*; + +import javax.ws.rs.core.Response; +import org.apache.cxf.jaxrs.client.JAXRSClientFactory; +import org.apache.cxf.jaxrs.client.ClientConfiguration; +import org.apache.cxf.jaxrs.client.WebClient; + + +import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + + + +/** + * 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. + * + * API tests for StoreApi + */ +public class StoreApiTest { + + + private StoreApi api; + + @Before + public void setup() { + JacksonJsonProvider provider = new JacksonJsonProvider(); + List providers = new ArrayList(); + providers.add(provider); + + api = JAXRSClientFactory.create("http://petstore.swagger.io/v2", StoreApi.class, providers); + org.apache.cxf.jaxrs.client.Client client = WebClient.client(api); + + ClientConfiguration config = WebClient.getConfig(client); + } + + + /** + * Delete purchase order by ID + * + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void deleteOrderTest() { + String orderId = null; + //api.deleteOrder(orderId); + + // TODO: test validations + + + } + + /** + * Returns pet inventories by status + * + * Returns a map of status codes to quantities + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void getInventoryTest() { + //Map response = api.getInventory(); + //assertNotNull(response); + // TODO: test validations + + + } + + /** + * Find purchase order by ID + * + * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void getOrderByIdTest() { + Long orderId = null; + //Order response = api.getOrderById(orderId); + //assertNotNull(response); + // TODO: test validations + + + } + + /** + * Place an order for a pet + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void placeOrderTest() { + Order order = null; + //Order response = api.placeOrder(order); + //assertNotNull(response); + // TODO: test validations + + + } + +} diff --git a/samples/client/petstore/jaxrs-cxf-client-swagger2/src/test/java/org/openapitools/api/UserApiTest.java b/samples/client/petstore/jaxrs-cxf-client-swagger2/src/test/java/org/openapitools/api/UserApiTest.java new file mode 100644 index 00000000000..7aec5bdd747 --- /dev/null +++ b/samples/client/petstore/jaxrs-cxf-client-swagger2/src/test/java/org/openapitools/api/UserApiTest.java @@ -0,0 +1,208 @@ +/* + * 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. + * + * The version of the OpenAPI document: 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.api; + +import java.util.Date; +import org.openapitools.model.User; +import org.junit.Test; +import org.junit.Before; +import static org.junit.Assert.*; + +import javax.ws.rs.core.Response; +import org.apache.cxf.jaxrs.client.JAXRSClientFactory; +import org.apache.cxf.jaxrs.client.ClientConfiguration; +import org.apache.cxf.jaxrs.client.WebClient; + + +import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + + + +/** + * 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. + * + * API tests for UserApi + */ +public class UserApiTest { + + + private UserApi api; + + @Before + public void setup() { + JacksonJsonProvider provider = new JacksonJsonProvider(); + List providers = new ArrayList(); + providers.add(provider); + + api = JAXRSClientFactory.create("http://petstore.swagger.io/v2", UserApi.class, providers); + org.apache.cxf.jaxrs.client.Client client = WebClient.client(api); + + ClientConfiguration config = WebClient.getConfig(client); + } + + + /** + * Create user + * + * This can only be done by the logged in user. + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void createUserTest() { + User user = null; + //api.createUser(user); + + // TODO: test validations + + + } + + /** + * Creates list of users with given input array + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void createUsersWithArrayInputTest() { + List user = null; + //api.createUsersWithArrayInput(user); + + // TODO: test validations + + + } + + /** + * Creates list of users with given input array + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void createUsersWithListInputTest() { + List user = null; + //api.createUsersWithListInput(user); + + // TODO: test validations + + + } + + /** + * Delete user + * + * This can only be done by the logged in user. + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void deleteUserTest() { + String username = null; + //api.deleteUser(username); + + // TODO: test validations + + + } + + /** + * Get user by user name + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void getUserByNameTest() { + String username = null; + //User response = api.getUserByName(username); + //assertNotNull(response); + // TODO: test validations + + + } + + /** + * Logs user into the system + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void loginUserTest() { + String username = null; + String password = null; + //String response = api.loginUser(username, password); + //assertNotNull(response); + // TODO: test validations + + + } + + /** + * Logs out current logged in user session + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void logoutUserTest() { + //api.logoutUser(); + + // TODO: test validations + + + } + + /** + * Updated user + * + * This can only be done by the logged in user. + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void updateUserTest() { + String username = null; + User user = null; + //api.updateUser(username, user); + + // TODO: test validations + + + } + +}