diff --git a/bin/configs/other/jaxrs-cxf-client-jackson.yaml b/bin/configs/other/jaxrs-cxf-client-jackson.yaml new file mode 100644 index 0000000000000000000000000000000000000000..86cb90696fe70dc9a884d6677cfd66103da92851 --- /dev/null +++ b/bin/configs/other/jaxrs-cxf-client-jackson.yaml @@ -0,0 +1,7 @@ +generatorName: jaxrs-cxf-client +outputDir: samples/client/petstore/jaxrs-cxf-client-jackson +inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml +templateDir: modules/openapi-generator/src/main/resources/JavaJaxRS/cxf +additionalProperties: + artifactId: jaxrs-cxf-jackson-petstore-client + jackson: "true" diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaCXFClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaCXFClientCodegen.java index fb5d70bbaef6575c598de38890c233289091fa7d..9f75430551a3f1aba6de1e71a6ff06329c4705bb 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaCXFClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaCXFClientCodegen.java @@ -138,6 +138,14 @@ public class JavaCXFClientCodegen extends AbstractJavaCodegen model.imports.remove("ApiModel"); model.imports.remove("JsonSerialize"); model.imports.remove("ToStringSerializer"); + + //Add imports for Jackson when model has inner enum + if (additionalProperties.containsKey("jackson")) { + if (Boolean.FALSE.equals(model.isEnum) && Boolean.TRUE.equals(model.hasEnums)) { + model.imports.add("JsonCreator"); + model.imports.add("JsonValue"); + } + } } @Override diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaCXFServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaCXFServerCodegen.java index 12f9f9aa482abd7d942d4579535980eaa53fb21b..2ee53cdc7603d82b679dce3d2908a2408b26cf8b 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaCXFServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaCXFServerCodegen.java @@ -243,6 +243,14 @@ public class JavaCXFServerCodegen extends AbstractJavaJAXRSServerCodegen model.imports.remove("ApiModel"); model.imports.remove("JsonSerialize"); model.imports.remove("ToStringSerializer"); + + //Add imports for Jackson when model has inner enum + if (additionalProperties.containsKey("jackson")) { + if (Boolean.FALSE.equals(model.isEnum) && Boolean.TRUE.equals(model.hasEnums)) { + model.imports.add("JsonCreator"); + model.imports.add("JsonValue"); + } + } } @Override diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf/enumClass.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf/enumClass.mustache index 3e19ca9809671e2e7eb8d264b2a036e229623698..ba65a125104a9ab40a1d67a422bc24ec7754d484 100644 --- a/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf/enumClass.mustache +++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf/enumClass.mustache @@ -18,10 +18,16 @@ public enum {{datatypeWithEnum}} { } @Override + {{#jackson}} + @JsonValue + {{/jackson}} public String toString() { return String.valueOf(value); } + {{#jackson}} + @JsonCreator + {{/jackson}} public static {{datatypeWithEnum}} fromValue({{dataType}} value) { for ({{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) { if (b.value.equals(value)) { diff --git a/samples/client/petstore/jaxrs-cxf-client-jackson/.openapi-generator-ignore b/samples/client/petstore/jaxrs-cxf-client-jackson/.openapi-generator-ignore new file mode 100644 index 0000000000000000000000000000000000000000..7484ee590a3894506cf063799b885428f95a71be --- /dev/null +++ b/samples/client/petstore/jaxrs-cxf-client-jackson/.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-jackson/.openapi-generator/FILES b/samples/client/petstore/jaxrs-cxf-client-jackson/.openapi-generator/FILES new file mode 100644 index 0000000000000000000000000000000000000000..a32a0965f8c259776055c89b0046ebba01795f01 --- /dev/null +++ b/samples/client/petstore/jaxrs-cxf-client-jackson/.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-jackson/.openapi-generator/VERSION b/samples/client/petstore/jaxrs-cxf-client-jackson/.openapi-generator/VERSION new file mode 100644 index 0000000000000000000000000000000000000000..d99e7162d01f35766e7a53f78b6acb6f7d84f1c3 --- /dev/null +++ b/samples/client/petstore/jaxrs-cxf-client-jackson/.openapi-generator/VERSION @@ -0,0 +1 @@ +5.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/jaxrs-cxf-client-jackson/pom.xml b/samples/client/petstore/jaxrs-cxf-client-jackson/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..e2d463a2cfe397e278954fcd8abef39946d0eb35 --- /dev/null +++ b/samples/client/petstore/jaxrs-cxf-client-jackson/pom.xml @@ -0,0 +1,181 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.openapitools</groupId> + <artifactId>jaxrs-cxf-jackson-petstore-client</artifactId> + <packaging>jar</packaging> + <name>jaxrs-cxf-jackson-petstore-client</name> + <description>This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.</description> + <version>1.0.0</version> + <build> + <sourceDirectory>src/main/java</sourceDirectory> + <plugins> + <plugin> + <artifactId>maven-failsafe-plugin</artifactId> + <version>2.6</version> + <executions> + <execution> + <goals> + <goal>integration-test</goal> + <goal>verify</goal> + </goals> + </execution> + </executions> + </plugin> + <!--plugin> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-maven-plugin</artifactId> + <version>${jetty-version}</version> + <configuration> + <webApp> + <contextPath>/</contextPath> + </webApp> + <webAppSourceDirectory>target/${project.artifactId}-${project.version}</webAppSourceDirectory> + <stopPort>8079</stopPort> + <stopKey>stopit</stopKey> + <httpConnector> + <port></port> + <idleTimeout>60000</idleTimeout> + </httpConnector> + </configuration> + <executions> + <execution> + <id>start-jetty</id> + <phase>pre-integration-test</phase> + <goals> + <goal>start</goal> + </goals> + <configuration> + <scanIntervalSeconds>0</scanIntervalSeconds> + <daemon>true</daemon> + </configuration> + </execution> + <execution> + <id>stop-jetty</id> + <phase>post-integration-test</phase> + <goals> + <goal>stop</goal> + </goals> + </execution> + </executions> + </plugin--> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <version>1.9.1</version> + <executions> + <execution> + <id>add-source</id> + <phase>generate-sources</phase> + <goals> + <goal>add-source</goal> + </goals> + <configuration> + <sources> + <source>src/gen/java</source> + </sources> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + <dependencies> + <dependency> + <groupId>io.swagger</groupId> + <artifactId>swagger-jaxrs</artifactId> + <scope>compile</scope> + <version>${swagger-core-version}</version> + </dependency> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-classic</artifactId> + <version>${logback-version}</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-core</artifactId> + <version>${logback-version}</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>${junit-version}</version> + <scope>test</scope> + </dependency> + <!-- CXF Client --> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-rs-client</artifactId> + <version>${cxf-version}</version> + <scope>test</scope> + </dependency> + + <!-- CXF server --> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-frontend-jaxrs</artifactId> + <version>${cxf-version}</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-rs-service-description</artifactId> + <version>${cxf-version}</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-ws-policy</artifactId> + <version>${cxf-version}</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-wsdl</artifactId> + <version>${cxf-version}</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.jaxrs</groupId> + <artifactId>jackson-jaxrs-json-provider</artifactId> + <version>${jackson-jaxrs-version}</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.datatype</groupId> + <artifactId>jackson-datatype-joda</artifactId> + <version>${jackson-jaxrs-version}</version> + </dependency> + <dependency> + <groupId>javax.annotation</groupId> + <artifactId>javax.annotation-api</artifactId> + <version>${javax-annotation-version}</version> + <scope>provided</scope> + </dependency> + </dependencies> + <repositories> + <repository> + <id>sonatype-snapshots</id> + <url>https://oss.sonatype.org/content/repositories/snapshots</url> + <snapshots> + <enabled>true</enabled> + </snapshots> + </repository> + </repositories> + <properties> + <java.version>1.7</java.version> + <maven.compiler.source>${java.version}</maven.compiler.source> + <maven.compiler.target>${java.version}</maven.compiler.target> + <swagger-core-version>1.5.18</swagger-core-version> + <jetty-version>9.2.9.v20150224</jetty-version> + <junit-version>4.13.1</junit-version> + <logback-version>1.1.7</logback-version> + <servlet-api-version>2.5</servlet-api-version> + <cxf-version>3.3.0</cxf-version> + <jackson-jaxrs-version>2.9.9</jackson-jaxrs-version> + <javax-annotation-version>1.3.2</javax-annotation-version> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> +</project> diff --git a/samples/client/petstore/jaxrs-cxf-client-jackson/src/gen/java/org/openapitools/api/PetApi.java b/samples/client/petstore/jaxrs-cxf-client-jackson/src/gen/java/org/openapitools/api/PetApi.java new file mode 100644 index 0000000000000000000000000000000000000000..51cce1e1d63aaabc14b0bbca48ca68245efa2122 --- /dev/null +++ b/samples/client/petstore/jaxrs-cxf-client-jackson/src/gen/java/org/openapitools/api/PetApi.java @@ -0,0 +1,140 @@ +package org.openapitools.api; + +import java.io.File; +import org.openapitools.model.ModelApiResponse; +import org.openapitools.model.Pet; + +import java.io.InputStream; +import java.io.OutputStream; +import java.util.List; +import java.util.Map; +import javax.ws.rs.*; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.MediaType; +import org.apache.cxf.jaxrs.ext.multipart.*; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiResponses; +import io.swagger.annotations.ApiResponse; +import io.swagger.jaxrs.PATCH; + +/** + * OpenAPI Petstore + * + * <p>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") +@Api(value = "/", description = "") +public interface PetApi { + + /** + * Add a new pet to the store + * + */ + @POST + + @Consumes({ "application/json", "application/xml" }) + @ApiOperation(value = "Add a new pet to the store", tags={ }) + @ApiResponses(value = { + @ApiResponse(code = 405, message = "Invalid input") }) + public void addPet(Pet body); + + /** + * Deletes a pet + * + */ + @DELETE + @Path("/{petId}") + @ApiOperation(value = "Deletes a pet", tags={ }) + @ApiResponses(value = { + @ApiResponse(code = 400, message = "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" }) + @ApiOperation(value = "Finds Pets by status", tags={ }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"), + @ApiResponse(code = 400, message = "Invalid status value") }) + public List<Pet> findPetsByStatus(@QueryParam("status") List<String> 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" }) + @ApiOperation(value = "Finds Pets by tags", tags={ }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"), + @ApiResponse(code = 400, message = "Invalid tag value") }) + public List<Pet> findPetsByTags(@QueryParam("tags") List<String> tags); + + /** + * Find pet by ID + * + * Returns a single pet + * + */ + @GET + @Path("/{petId}") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Find pet by ID", tags={ }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Pet.class), + @ApiResponse(code = 400, message = "Invalid ID supplied"), + @ApiResponse(code = 404, message = "Pet not found") }) + public Pet getPetById(@PathParam("petId") Long petId); + + /** + * Update an existing pet + * + */ + @PUT + + @Consumes({ "application/json", "application/xml" }) + @ApiOperation(value = "Update an existing pet", tags={ }) + @ApiResponses(value = { + @ApiResponse(code = 400, message = "Invalid ID supplied"), + @ApiResponse(code = 404, message = "Pet not found"), + @ApiResponse(code = 405, message = "Validation exception") }) + public void updatePet(Pet body); + + /** + * Updates a pet in the store with form data + * + */ + @POST + @Path("/{petId}") + @Consumes({ "application/x-www-form-urlencoded" }) + @ApiOperation(value = "Updates a pet in the store with form data", tags={ }) + @ApiResponses(value = { + @ApiResponse(code = 405, message = "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" }) + @ApiOperation(value = "uploads an image", tags={ }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = 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-jackson/src/gen/java/org/openapitools/api/StoreApi.java b/samples/client/petstore/jaxrs-cxf-client-jackson/src/gen/java/org/openapitools/api/StoreApi.java new file mode 100644 index 0000000000000000000000000000000000000000..073884a0c6ff1fa05e276754340d874482f186d9 --- /dev/null +++ b/samples/client/petstore/jaxrs-cxf-client-jackson/src/gen/java/org/openapitools/api/StoreApi.java @@ -0,0 +1,87 @@ +package org.openapitools.api; + +import org.openapitools.model.Order; + +import java.io.InputStream; +import java.io.OutputStream; +import java.util.List; +import java.util.Map; +import javax.ws.rs.*; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.MediaType; +import org.apache.cxf.jaxrs.ext.multipart.*; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiResponses; +import io.swagger.annotations.ApiResponse; +import io.swagger.jaxrs.PATCH; + +/** + * OpenAPI Petstore + * + * <p>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") +@Api(value = "/", description = "") +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}") + @ApiOperation(value = "Delete purchase order by ID", tags={ }) + @ApiResponses(value = { + @ApiResponse(code = 400, message = "Invalid ID supplied"), + @ApiResponse(code = 404, message = "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" }) + @ApiOperation(value = "Returns pet inventories by status", tags={ }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") }) + public Map<String, Integer> getInventory(); + + /** + * Find purchase order by ID + * + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * + */ + @GET + @Path("/order/{orderId}") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Find purchase order by ID", tags={ }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Order.class), + @ApiResponse(code = 400, message = "Invalid ID supplied"), + @ApiResponse(code = 404, message = "Order not found") }) + public Order getOrderById(@PathParam("orderId") Long orderId); + + /** + * Place an order for a pet + * + */ + @POST + @Path("/order") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Place an order for a pet", tags={ }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Order.class), + @ApiResponse(code = 400, message = "Invalid Order") }) + public Order placeOrder(Order body); +} + diff --git a/samples/client/petstore/jaxrs-cxf-client-jackson/src/gen/java/org/openapitools/api/UserApi.java b/samples/client/petstore/jaxrs-cxf-client-jackson/src/gen/java/org/openapitools/api/UserApi.java new file mode 100644 index 0000000000000000000000000000000000000000..ee7ab783661213b4133fd3ced401be646b1493db --- /dev/null +++ b/samples/client/petstore/jaxrs-cxf-client-jackson/src/gen/java/org/openapitools/api/UserApi.java @@ -0,0 +1,131 @@ +package org.openapitools.api; + +import org.openapitools.model.User; + +import java.io.InputStream; +import java.io.OutputStream; +import java.util.List; +import java.util.Map; +import javax.ws.rs.*; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.MediaType; +import org.apache.cxf.jaxrs.ext.multipart.*; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiResponses; +import io.swagger.annotations.ApiResponse; +import io.swagger.jaxrs.PATCH; + +/** + * OpenAPI Petstore + * + * <p>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") +@Api(value = "/", description = "") +public interface UserApi { + + /** + * Create user + * + * This can only be done by the logged in user. + * + */ + @POST + + @ApiOperation(value = "Create user", tags={ }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation") }) + public void createUser(User body); + + /** + * Creates list of users with given input array + * + */ + @POST + @Path("/createWithArray") + @ApiOperation(value = "Creates list of users with given input array", tags={ }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation") }) + public void createUsersWithArrayInput(List<User> body); + + /** + * Creates list of users with given input array + * + */ + @POST + @Path("/createWithList") + @ApiOperation(value = "Creates list of users with given input array", tags={ }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation") }) + public void createUsersWithListInput(List<User> body); + + /** + * Delete user + * + * This can only be done by the logged in user. + * + */ + @DELETE + @Path("/{username}") + @ApiOperation(value = "Delete user", tags={ }) + @ApiResponses(value = { + @ApiResponse(code = 400, message = "Invalid username supplied"), + @ApiResponse(code = 404, message = "User not found") }) + public void deleteUser(@PathParam("username") String username); + + /** + * Get user by user name + * + */ + @GET + @Path("/{username}") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Get user by user name", tags={ }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = User.class), + @ApiResponse(code = 400, message = "Invalid username supplied"), + @ApiResponse(code = 404, message = "User not found") }) + public User getUserByName(@PathParam("username") String username); + + /** + * Logs user into the system + * + */ + @GET + @Path("/login") + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Logs user into the system", tags={ }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = String.class), + @ApiResponse(code = 400, message = "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") + @ApiOperation(value = "Logs out current logged in user session", tags={ }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation") }) + public void logoutUser(); + + /** + * Updated user + * + * This can only be done by the logged in user. + * + */ + @PUT + @Path("/{username}") + @ApiOperation(value = "Updated user", tags={ }) + @ApiResponses(value = { + @ApiResponse(code = 400, message = "Invalid user supplied"), + @ApiResponse(code = 404, message = "User not found") }) + public void updateUser(@PathParam("username") String username, User body); +} + diff --git a/samples/client/petstore/jaxrs-cxf-client-jackson/src/gen/java/org/openapitools/model/Category.java b/samples/client/petstore/jaxrs-cxf-client-jackson/src/gen/java/org/openapitools/model/Category.java new file mode 100644 index 0000000000000000000000000000000000000000..8312405424ae38ed2fdaf89548761f0800c0840a --- /dev/null +++ b/samples/client/petstore/jaxrs-cxf-client-jackson/src/gen/java/org/openapitools/model/Category.java @@ -0,0 +1,85 @@ +package org.openapitools.model; + +import io.swagger.annotations.ApiModel; + +import io.swagger.annotations.ApiModelProperty; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlEnumValue; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * A category for a pet + **/ +@ApiModel(description="A category for a pet") +public class Category { + + @ApiModelProperty(value = "") + private Long id; + + @ApiModelProperty(value = "") + 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 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-jackson/src/gen/java/org/openapitools/model/ModelApiResponse.java b/samples/client/petstore/jaxrs-cxf-client-jackson/src/gen/java/org/openapitools/model/ModelApiResponse.java new file mode 100644 index 0000000000000000000000000000000000000000..14b393d1097063d5625067d566ae765bd02f8cd8 --- /dev/null +++ b/samples/client/petstore/jaxrs-cxf-client-jackson/src/gen/java/org/openapitools/model/ModelApiResponse.java @@ -0,0 +1,107 @@ +package org.openapitools.model; + +import io.swagger.annotations.ApiModel; + +import io.swagger.annotations.ApiModelProperty; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlEnumValue; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Describes the result of uploading an image resource + **/ +@ApiModel(description="Describes the result of uploading an image resource") +public class ModelApiResponse { + + @ApiModelProperty(value = "") + private Integer code; + + @ApiModelProperty(value = "") + private String type; + + @ApiModelProperty(value = "") + 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 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-jackson/src/gen/java/org/openapitools/model/Order.java b/samples/client/petstore/jaxrs-cxf-client-jackson/src/gen/java/org/openapitools/model/Order.java new file mode 100644 index 0000000000000000000000000000000000000000..770e6d30baa96e1507fcc48d2a6ca11b6bb844f4 --- /dev/null +++ b/samples/client/petstore/jaxrs-cxf-client-jackson/src/gen/java/org/openapitools/model/Order.java @@ -0,0 +1,216 @@ +package org.openapitools.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import java.util.Date; + +import io.swagger.annotations.ApiModelProperty; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlEnumValue; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * An order for a pets from the pet store + **/ +@ApiModel(description="An order for a pets from the pet store") +public class Order { + + @ApiModelProperty(value = "") + private Long id; + + @ApiModelProperty(value = "") + private Long petId; + + @ApiModelProperty(value = "") + private Integer quantity; + + @ApiModelProperty(value = "") + private Date shipDate; + +@XmlType(name="StatusEnum") +@XmlEnum(String.class) +public enum StatusEnum { + +@XmlEnumValue("placed") PLACED(String.valueOf("placed")), @XmlEnumValue("approved") APPROVED(String.valueOf("approved")), @XmlEnumValue("delivered") DELIVERED(String.valueOf("delivered")); + + + private String value; + + StatusEnum (String v) { + value = v; + } + + public String value() { + return value; + } + + @Override + @JsonValue + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} + + @ApiModelProperty(value = "Order Status") + /** + * Order Status + **/ + private StatusEnum status; + + @ApiModelProperty(value = "") + 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 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-jackson/src/gen/java/org/openapitools/model/Pet.java b/samples/client/petstore/jaxrs-cxf-client-jackson/src/gen/java/org/openapitools/model/Pet.java new file mode 100644 index 0000000000000000000000000000000000000000..807cb4182d8834532b06ec9a1a94524c1e398ade --- /dev/null +++ b/samples/client/petstore/jaxrs-cxf-client-jackson/src/gen/java/org/openapitools/model/Pet.java @@ -0,0 +1,229 @@ +package org.openapitools.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import java.util.ArrayList; +import java.util.List; +import org.openapitools.model.Category; +import org.openapitools.model.Tag; + +import io.swagger.annotations.ApiModelProperty; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlEnumValue; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * A pet for sale in the pet store + **/ +@ApiModel(description="A pet for sale in the pet store") +public class Pet { + + @ApiModelProperty(value = "") + private Long id; + + @ApiModelProperty(value = "") + private Category category; + + @ApiModelProperty(example = "doggie", required = true, value = "") + private String name; + + @ApiModelProperty(required = true, value = "") + private List<String> photoUrls = new ArrayList<String>(); + + @ApiModelProperty(value = "") + private List<Tag> tags = null; + +@XmlType(name="StatusEnum") +@XmlEnum(String.class) +public enum StatusEnum { + +@XmlEnumValue("available") AVAILABLE(String.valueOf("available")), @XmlEnumValue("pending") PENDING(String.valueOf("pending")), @XmlEnumValue("sold") SOLD(String.valueOf("sold")); + + + private String value; + + StatusEnum (String v) { + value = v; + } + + public String value() { + return value; + } + + @Override + @JsonValue + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} + + @ApiModelProperty(value = "pet status in the store") + /** + * 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<String> getPhotoUrls() { + return photoUrls; + } + + public void setPhotoUrls(List<String> photoUrls) { + this.photoUrls = photoUrls; + } + + public Pet photoUrls(List<String> 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<Tag> getTags() { + return tags; + } + + public void setTags(List<Tag> tags) { + this.tags = tags; + } + + public Pet tags(List<Tag> 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 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-jackson/src/gen/java/org/openapitools/model/Tag.java b/samples/client/petstore/jaxrs-cxf-client-jackson/src/gen/java/org/openapitools/model/Tag.java new file mode 100644 index 0000000000000000000000000000000000000000..ad321a15496029f571ab501ac165e082bce8add6 --- /dev/null +++ b/samples/client/petstore/jaxrs-cxf-client-jackson/src/gen/java/org/openapitools/model/Tag.java @@ -0,0 +1,85 @@ +package org.openapitools.model; + +import io.swagger.annotations.ApiModel; + +import io.swagger.annotations.ApiModelProperty; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlEnumValue; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * A tag for a pet + **/ +@ApiModel(description="A tag for a pet") +public class Tag { + + @ApiModelProperty(value = "") + private Long id; + + @ApiModelProperty(value = "") + 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 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-jackson/src/gen/java/org/openapitools/model/User.java b/samples/client/petstore/jaxrs-cxf-client-jackson/src/gen/java/org/openapitools/model/User.java new file mode 100644 index 0000000000000000000000000000000000000000..0cd34a9baf47a83bc8dbcca54a55a2fca01462b7 --- /dev/null +++ b/samples/client/petstore/jaxrs-cxf-client-jackson/src/gen/java/org/openapitools/model/User.java @@ -0,0 +1,220 @@ +package org.openapitools.model; + +import io.swagger.annotations.ApiModel; + +import io.swagger.annotations.ApiModelProperty; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlEnumValue; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * A User who is purchasing from the pet store + **/ +@ApiModel(description="A User who is purchasing from the pet store") +public class User { + + @ApiModelProperty(value = "") + private Long id; + + @ApiModelProperty(value = "") + private String username; + + @ApiModelProperty(value = "") + private String firstName; + + @ApiModelProperty(value = "") + private String lastName; + + @ApiModelProperty(value = "") + private String email; + + @ApiModelProperty(value = "") + private String password; + + @ApiModelProperty(value = "") + private String phone; + + @ApiModelProperty(value = "User Status") + /** + * 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 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-jackson/src/test/java/org/openapitools/api/PetApiTest.java b/samples/client/petstore/jaxrs-cxf-client-jackson/src/test/java/org/openapitools/api/PetApiTest.java new file mode 100644 index 0000000000000000000000000000000000000000..bb976e89522444c8a2d847e664fbe3502605413b --- /dev/null +++ b/samples/client/petstore/jaxrs-cxf-client-jackson/src/test/java/org/openapitools/api/PetApiTest.java @@ -0,0 +1,203 @@ +/** + * 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 + * + * <p>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 body = null; + //api.addPet(body); + + // 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<String> status = null; + //List<Pet> 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<String> tags = null; + //List<Pet> 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 body = null; + //api.updatePet(body); + + // 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; + org.apache.cxf.jaxrs.ext.multipart.Attachment file = null; + //ModelApiResponse response = api.uploadFile(petId, additionalMetadata, file); + //assertNotNull(response); + // TODO: test validations + + + } + +} diff --git a/samples/client/petstore/jaxrs-cxf-client-jackson/src/test/java/org/openapitools/api/StoreApiTest.java b/samples/client/petstore/jaxrs-cxf-client-jackson/src/test/java/org/openapitools/api/StoreApiTest.java new file mode 100644 index 0000000000000000000000000000000000000000..4e26ac030ebe846ad69be3b1d90d55314392cc44 --- /dev/null +++ b/samples/client/petstore/jaxrs-cxf-client-jackson/src/test/java/org/openapitools/api/StoreApiTest.java @@ -0,0 +1,131 @@ +/** + * 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 + * + * <p>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<String, Integer> 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 generated 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 body = null; + //Order response = api.placeOrder(body); + //assertNotNull(response); + // TODO: test validations + + + } + +} diff --git a/samples/client/petstore/jaxrs-cxf-client-jackson/src/test/java/org/openapitools/api/UserApiTest.java b/samples/client/petstore/jaxrs-cxf-client-jackson/src/test/java/org/openapitools/api/UserApiTest.java new file mode 100644 index 0000000000000000000000000000000000000000..811ace5aebba7cb8c6abe3ed4f2aa7f2e00c578f --- /dev/null +++ b/samples/client/petstore/jaxrs-cxf-client-jackson/src/test/java/org/openapitools/api/UserApiTest.java @@ -0,0 +1,197 @@ +/** + * 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.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 + * + * <p>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 body = null; + //api.createUser(body); + + // TODO: test validations + + + } + + /** + * Creates list of users with given input array + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void createUsersWithArrayInputTest() { + List<User> body = null; + //api.createUsersWithArrayInput(body); + + // TODO: test validations + + + } + + /** + * Creates list of users with given input array + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void createUsersWithListInputTest() { + List<User> body = null; + //api.createUsersWithListInput(body); + + // 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 body = null; + //api.updateUser(username, body); + + // TODO: test validations + + + } + +} diff --git a/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/gen/java/org/openapitools/model/Order.java b/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/gen/java/org/openapitools/model/Order.java index 469546a60eada95cb50af629ea957afec0ca5939..68b9a5e0f2e504e5b5fd42263b1733d7a3eda066 100644 --- a/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/gen/java/org/openapitools/model/Order.java +++ b/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/gen/java/org/openapitools/model/Order.java @@ -1,5 +1,7 @@ package org.openapitools.model; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import java.util.Date; import javax.validation.constraints.*; @@ -51,10 +53,12 @@ public enum StatusEnum { } @Override + @JsonValue public String toString() { return String.valueOf(value); } + @JsonCreator public static StatusEnum fromValue(String value) { for (StatusEnum b : StatusEnum.values()) { if (b.value.equals(value)) { diff --git a/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/gen/java/org/openapitools/model/Pet.java b/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/gen/java/org/openapitools/model/Pet.java index f7bace990d5f2520acfe43d6084bb2fb7c476e49..31b40cd5bd394f1eedb5e38e38b58ce575b0e45d 100644 --- a/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/gen/java/org/openapitools/model/Pet.java +++ b/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/gen/java/org/openapitools/model/Pet.java @@ -1,5 +1,7 @@ package org.openapitools.model; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import java.util.ArrayList; import java.util.List; @@ -59,10 +61,12 @@ public enum StatusEnum { } @Override + @JsonValue public String toString() { return String.valueOf(value); } + @JsonCreator public static StatusEnum fromValue(String value) { for (StatusEnum b : StatusEnum.values()) { if (b.value.equals(value)) { diff --git a/samples/server/petstore/jaxrs-cxf-non-spring-app/src/gen/java/org/openapitools/model/Order.java b/samples/server/petstore/jaxrs-cxf-non-spring-app/src/gen/java/org/openapitools/model/Order.java index 469546a60eada95cb50af629ea957afec0ca5939..68b9a5e0f2e504e5b5fd42263b1733d7a3eda066 100644 --- a/samples/server/petstore/jaxrs-cxf-non-spring-app/src/gen/java/org/openapitools/model/Order.java +++ b/samples/server/petstore/jaxrs-cxf-non-spring-app/src/gen/java/org/openapitools/model/Order.java @@ -1,5 +1,7 @@ package org.openapitools.model; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import java.util.Date; import javax.validation.constraints.*; @@ -51,10 +53,12 @@ public enum StatusEnum { } @Override + @JsonValue public String toString() { return String.valueOf(value); } + @JsonCreator public static StatusEnum fromValue(String value) { for (StatusEnum b : StatusEnum.values()) { if (b.value.equals(value)) { diff --git a/samples/server/petstore/jaxrs-cxf-non-spring-app/src/gen/java/org/openapitools/model/Pet.java b/samples/server/petstore/jaxrs-cxf-non-spring-app/src/gen/java/org/openapitools/model/Pet.java index f7bace990d5f2520acfe43d6084bb2fb7c476e49..31b40cd5bd394f1eedb5e38e38b58ce575b0e45d 100644 --- a/samples/server/petstore/jaxrs-cxf-non-spring-app/src/gen/java/org/openapitools/model/Pet.java +++ b/samples/server/petstore/jaxrs-cxf-non-spring-app/src/gen/java/org/openapitools/model/Pet.java @@ -1,5 +1,7 @@ package org.openapitools.model; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import java.util.ArrayList; import java.util.List; @@ -59,10 +61,12 @@ public enum StatusEnum { } @Override + @JsonValue public String toString() { return String.valueOf(value); } + @JsonCreator public static StatusEnum fromValue(String value) { for (StatusEnum b : StatusEnum.values()) { if (b.value.equals(value)) { diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/org/openapitools/model/BigCat.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/org/openapitools/model/BigCat.java index e472813990725cb08f57d9947afe29be10d5c7c7..3db8eac87f8131d02a932fb1c62d5591b5a088d9 100644 --- a/samples/server/petstore/jaxrs-cxf/src/gen/java/org/openapitools/model/BigCat.java +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/org/openapitools/model/BigCat.java @@ -1,5 +1,7 @@ package org.openapitools.model; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; import org.openapitools.model.BigCatAllOf; import org.openapitools.model.Cat; import javax.validation.constraints.*; @@ -35,10 +37,12 @@ public enum KindEnum { } @Override + @JsonValue public String toString() { return String.valueOf(value); } + @JsonCreator public static KindEnum fromValue(String value) { for (KindEnum b : KindEnum.values()) { if (b.value.equals(value)) { diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/org/openapitools/model/BigCatAllOf.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/org/openapitools/model/BigCatAllOf.java index 523af48ba6b3f2d067aaf129a6ddf657f3433d9a..00f8f1556e5da18a4ef05f0a0f25c4521b80d300 100644 --- a/samples/server/petstore/jaxrs-cxf/src/gen/java/org/openapitools/model/BigCatAllOf.java +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/org/openapitools/model/BigCatAllOf.java @@ -1,5 +1,7 @@ package org.openapitools.model; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; import javax.validation.constraints.*; import javax.validation.Valid; @@ -33,10 +35,12 @@ public enum KindEnum { } @Override + @JsonValue public String toString() { return String.valueOf(value); } + @JsonCreator public static KindEnum fromValue(String value) { for (KindEnum b : KindEnum.values()) { if (b.value.equals(value)) { diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/org/openapitools/model/EnumArrays.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/org/openapitools/model/EnumArrays.java index 28d63661c3170922bece352f22aa490631ef8cf4..33ec37c0574636651a459433083ec28dcd45e716 100644 --- a/samples/server/petstore/jaxrs-cxf/src/gen/java/org/openapitools/model/EnumArrays.java +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/org/openapitools/model/EnumArrays.java @@ -1,5 +1,7 @@ package org.openapitools.model; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; import java.util.ArrayList; import java.util.List; import javax.validation.constraints.*; @@ -35,10 +37,12 @@ public enum JustSymbolEnum { } @Override + @JsonValue public String toString() { return String.valueOf(value); } + @JsonCreator public static JustSymbolEnum fromValue(String value) { for (JustSymbolEnum b : JustSymbolEnum.values()) { if (b.value.equals(value)) { @@ -70,10 +74,12 @@ public enum ArrayEnumEnum { } @Override + @JsonValue public String toString() { return String.valueOf(value); } + @JsonCreator public static ArrayEnumEnum fromValue(String value) { for (ArrayEnumEnum b : ArrayEnumEnum.values()) { if (b.value.equals(value)) { diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/org/openapitools/model/EnumTest.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/org/openapitools/model/EnumTest.java index 6d1245c7a40e0abdf5e1065a4f57098ab8f4d2bb..e90b2d70bc620a8f5acfccd011e3b44c70f3d554 100644 --- a/samples/server/petstore/jaxrs-cxf/src/gen/java/org/openapitools/model/EnumTest.java +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/org/openapitools/model/EnumTest.java @@ -1,5 +1,7 @@ package org.openapitools.model; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; import org.openapitools.model.OuterEnum; import javax.validation.constraints.*; import javax.validation.Valid; @@ -34,10 +36,12 @@ public enum EnumStringEnum { } @Override + @JsonValue public String toString() { return String.valueOf(value); } + @JsonCreator public static EnumStringEnum fromValue(String value) { for (EnumStringEnum b : EnumStringEnum.values()) { if (b.value.equals(value)) { @@ -69,10 +73,12 @@ public enum EnumStringRequiredEnum { } @Override + @JsonValue public String toString() { return String.valueOf(value); } + @JsonCreator public static EnumStringRequiredEnum fromValue(String value) { for (EnumStringRequiredEnum b : EnumStringRequiredEnum.values()) { if (b.value.equals(value)) { @@ -104,10 +110,12 @@ public enum EnumIntegerEnum { } @Override + @JsonValue public String toString() { return String.valueOf(value); } + @JsonCreator public static EnumIntegerEnum fromValue(Integer value) { for (EnumIntegerEnum b : EnumIntegerEnum.values()) { if (b.value.equals(value)) { @@ -139,10 +147,12 @@ public enum EnumNumberEnum { } @Override + @JsonValue public String toString() { return String.valueOf(value); } + @JsonCreator public static EnumNumberEnum fromValue(Double value) { for (EnumNumberEnum b : EnumNumberEnum.values()) { if (b.value.equals(value)) { diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/org/openapitools/model/MapTest.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/org/openapitools/model/MapTest.java index 6f98a9dd6e2c560be458261c27008717e8429239..ce174a3cb41ecb4b541df8a46e4f47d7054c41b4 100644 --- a/samples/server/petstore/jaxrs-cxf/src/gen/java/org/openapitools/model/MapTest.java +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/org/openapitools/model/MapTest.java @@ -1,5 +1,7 @@ package org.openapitools.model; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -40,10 +42,12 @@ public enum InnerEnum { } @Override + @JsonValue public String toString() { return String.valueOf(value); } + @JsonCreator public static InnerEnum fromValue(String value) { for (InnerEnum b : InnerEnum.values()) { if (b.value.equals(value)) { diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/org/openapitools/model/Order.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/org/openapitools/model/Order.java index 586c1f71528a23d9a020fe16ac4a9a468e185c0d..ebf3bcc5c6c5441822b08692999e5b16e5611bec 100644 --- a/samples/server/petstore/jaxrs-cxf/src/gen/java/org/openapitools/model/Order.java +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/org/openapitools/model/Order.java @@ -1,5 +1,7 @@ package org.openapitools.model; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; import java.util.Date; import javax.validation.constraints.*; import javax.validation.Valid; @@ -46,10 +48,12 @@ public enum StatusEnum { } @Override + @JsonValue public String toString() { return String.valueOf(value); } + @JsonCreator public static StatusEnum fromValue(String value) { for (StatusEnum b : StatusEnum.values()) { if (b.value.equals(value)) { diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/org/openapitools/model/Pet.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/org/openapitools/model/Pet.java index 2eff8e27a39ded65bb8cff2b72356ac16f14ef97..0410c4b1eeccddb203e3261592619688e3409f30 100644 --- a/samples/server/petstore/jaxrs-cxf/src/gen/java/org/openapitools/model/Pet.java +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/org/openapitools/model/Pet.java @@ -1,5 +1,7 @@ package org.openapitools.model; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; import java.util.ArrayList; import java.util.LinkedHashSet; import java.util.List; @@ -56,10 +58,12 @@ public enum StatusEnum { } @Override + @JsonValue public String toString() { return String.valueOf(value); } + @JsonCreator public static StatusEnum fromValue(String value) { for (StatusEnum b : StatusEnum.values()) { if (b.value.equals(value)) {