forked from loafle/openapi-generator-original
Mark java-vertx as deprecated (#8609)
* mark java-vert as deprecated * update, clean up samples * remove entrites related to java-vertx
This commit is contained in:
parent
19eaf73205
commit
e6cee8eb71
@ -94,7 +94,7 @@ The following generators are available:
|
||||
* [java-pkmst](generators/java-pkmst.md)
|
||||
* [java-play-framework](generators/java-play-framework.md)
|
||||
* [java-undertow-server](generators/java-undertow-server.md)
|
||||
* [java-vertx](generators/java-vertx.md)
|
||||
* [java-vertx (deprecated)](generators/java-vertx.md)
|
||||
* [java-vertx-web (beta)](generators/java-vertx-web.md)
|
||||
* [jaxrs-cxf](generators/jaxrs-cxf.md)
|
||||
* [jaxrs-cxf-cdi](generators/jaxrs-cxf-cdi.md)
|
||||
|
@ -24,9 +24,14 @@ import io.swagger.v3.oas.models.PathItem.HttpMethod;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import io.swagger.v3.oas.models.servers.Server;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
import org.openapitools.codegen.meta.features.DocumentationFeature;
|
||||
import org.openapitools.codegen.utils.URLPathUtils;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
@ -37,6 +42,7 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class JavaVertXServerCodegen extends AbstractJavaCodegen {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(JavaVertXServerCodegen.class);
|
||||
|
||||
protected String resourceFolder = "src/main/resources";
|
||||
protected String rootPackage = "org.openapitools.server.api";
|
||||
@ -61,6 +67,10 @@ public class JavaVertXServerCodegen extends AbstractJavaCodegen {
|
||||
|
||||
modifyFeatureSet(features -> features.includeDocumentationFeatures(DocumentationFeature.Readme));
|
||||
|
||||
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
|
||||
.stability(Stability.DEPRECATED)
|
||||
.build();
|
||||
|
||||
// set the output folder here
|
||||
outputFolder = "generated-code" + File.separator + "javaVertXServer";
|
||||
|
||||
@ -134,6 +144,8 @@ public class JavaVertXServerCodegen extends AbstractJavaCodegen {
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
||||
LOGGER.warn("IMPORTANT: This generator has been deprecated. Please use `java-vertx-web` instead");
|
||||
|
||||
apiTestTemplateFiles.clear();
|
||||
|
||||
importMapping.remove("JsonCreator");
|
||||
|
4
pom.xml
4
pom.xml
@ -1260,8 +1260,7 @@
|
||||
<module>samples/server/petstore/jaxrs-spec</module>
|
||||
<module>samples/server/petstore/jaxrs-spec-interface</module>
|
||||
<module>samples/server/petstore/jaxrs-spec-interface-response</module>
|
||||
<module>samples/server/petstore/java-vertx/rx</module>
|
||||
<module>samples/server/petstore/java-vertx/async</module>
|
||||
<module>samples/server/petstore/java-vertx-web</module>
|
||||
<module>samples/server/petstore/java-inflector</module>
|
||||
<module>samples/server/petstore/java-pkmst</module>
|
||||
<module>samples/server/petstore/java-play-framework</module>
|
||||
@ -1303,7 +1302,6 @@
|
||||
<module>samples/server/petstore/scala-play-server</module>
|
||||
<module>samples/server/petstore/scala-akka-http-server</module>
|
||||
<module>samples/server/petstore/scalatra</module>
|
||||
<module>samples/server/petstore/java-vertx-web</module>
|
||||
<module>samples/server/petstore/scala-finch</module>
|
||||
<!--<module>samples/server/petstore/kotlin/vertx</module>-->
|
||||
</modules>
|
||||
|
@ -1,23 +0,0 @@
|
||||
# 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
|
@ -1,21 +0,0 @@
|
||||
README.md
|
||||
pom.xml
|
||||
src/main/java/org/openapitools/server/api/MainApiException.java
|
||||
src/main/java/org/openapitools/server/api/MainApiVerticle.java
|
||||
src/main/java/org/openapitools/server/api/model/Category.java
|
||||
src/main/java/org/openapitools/server/api/model/ModelApiResponse.java
|
||||
src/main/java/org/openapitools/server/api/model/Order.java
|
||||
src/main/java/org/openapitools/server/api/model/Pet.java
|
||||
src/main/java/org/openapitools/server/api/model/Tag.java
|
||||
src/main/java/org/openapitools/server/api/model/User.java
|
||||
src/main/java/org/openapitools/server/api/verticle/PetApi.java
|
||||
src/main/java/org/openapitools/server/api/verticle/PetApiException.java
|
||||
src/main/java/org/openapitools/server/api/verticle/PetApiVerticle.java
|
||||
src/main/java/org/openapitools/server/api/verticle/StoreApi.java
|
||||
src/main/java/org/openapitools/server/api/verticle/StoreApiException.java
|
||||
src/main/java/org/openapitools/server/api/verticle/StoreApiVerticle.java
|
||||
src/main/java/org/openapitools/server/api/verticle/UserApi.java
|
||||
src/main/java/org/openapitools/server/api/verticle/UserApiException.java
|
||||
src/main/java/org/openapitools/server/api/verticle/UserApiVerticle.java
|
||||
src/main/resources/openapi.json
|
||||
src/main/resources/vertx-default-jul-logging.properties
|
@ -1 +0,0 @@
|
||||
5.0.1-SNAPSHOT
|
@ -1,91 +0,0 @@
|
||||
<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>openapi-java-vertx-server</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>OpenAPI Petstore</name>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<junit.version>4.13.1</junit.version>
|
||||
<vertx.version>3.4.1</vertx.version>
|
||||
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
|
||||
<vertx-swagger-router.version>1.4.0</vertx-swagger-router.version>
|
||||
<maven-shade-plugin.version>2.3</maven-shade-plugin.version>
|
||||
<jackson-datatype-jsr310.version>2.7.4</jackson-datatype-jsr310.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.vertx</groupId>
|
||||
<artifactId>vertx-unit</artifactId>
|
||||
<version>${vertx.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.phiz71</groupId>
|
||||
<artifactId>vertx-swagger-router</artifactId>
|
||||
<version>${vertx-swagger-router.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
<version>${jackson-datatype-jsr310.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${maven-compiler-plugin.version}</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>${maven-shade-plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<transformers>
|
||||
<transformer
|
||||
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||
<manifestEntries>
|
||||
<Main-Class>io.vertx.core.Starter</Main-Class>
|
||||
<Main-Verticle>org.openapitools.server.api.MainApiVerticle</Main-Verticle>
|
||||
</manifestEntries>
|
||||
</transformer>
|
||||
</transformers>
|
||||
<artifactSet />
|
||||
<outputFile>${project.build.directory}/${project.artifactId}-${project.version}-fat.jar</outputFile>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -1,22 +0,0 @@
|
||||
package org.openapitools.server.api;
|
||||
|
||||
public class MainApiException extends Exception {
|
||||
private int statusCode;
|
||||
private String statusMessage;
|
||||
|
||||
public MainApiException(int statusCode, String statusMessage) {
|
||||
super();
|
||||
this.statusCode = statusCode;
|
||||
this.statusMessage = statusMessage;
|
||||
}
|
||||
|
||||
public int getStatusCode() {
|
||||
return statusCode;
|
||||
}
|
||||
|
||||
public String getStatusMessage() {
|
||||
return statusMessage;
|
||||
}
|
||||
|
||||
public static final MainApiException INTERNAL_SERVER_ERROR = new MainApiException(500, "Internal Server Error");
|
||||
}
|
@ -1,97 +0,0 @@
|
||||
package org.openapitools.server.api;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import com.github.phiz71.vertx.swagger.router.OperationIdServiceIdResolver;
|
||||
import com.github.phiz71.vertx.swagger.router.SwaggerRouter;
|
||||
|
||||
import io.swagger.models.Swagger;
|
||||
import io.swagger.parser.SwaggerParser;
|
||||
import io.vertx.core.AbstractVerticle;
|
||||
import io.vertx.core.Context;
|
||||
import io.vertx.core.Future;
|
||||
import io.vertx.core.file.FileSystem;
|
||||
import io.vertx.core.json.Json;
|
||||
import io.vertx.core.logging.Logger;
|
||||
import io.vertx.core.logging.LoggerFactory;
|
||||
import io.vertx.core.Vertx;
|
||||
import io.vertx.ext.web.Router;
|
||||
|
||||
public class MainApiVerticle extends AbstractVerticle {
|
||||
static final Logger LOGGER = LoggerFactory.getLogger(MainApiVerticle.class);
|
||||
|
||||
private int serverPort = 8080;
|
||||
protected Router router;
|
||||
|
||||
public int getServerPort() {
|
||||
return serverPort;
|
||||
}
|
||||
|
||||
public void setServerPort(int serverPort) {
|
||||
this.serverPort = serverPort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Vertx vertx, Context context) {
|
||||
super.init(vertx, context);
|
||||
router = Router.router(vertx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(Future<Void> startFuture) throws Exception {
|
||||
Json.mapper.registerModule(new JavaTimeModule());
|
||||
FileSystem vertxFileSystem = vertx.fileSystem();
|
||||
vertxFileSystem.readFile("openapi.json", readFile -> {
|
||||
if (readFile.succeeded()) {
|
||||
Swagger swagger = new SwaggerParser().parse(readFile.result().toString(Charset.forName("utf-8")));
|
||||
Router swaggerRouter = SwaggerRouter.swaggerRouter(router, swagger, vertx.eventBus(), new OperationIdServiceIdResolver());
|
||||
|
||||
deployVerticles(startFuture);
|
||||
|
||||
vertx.createHttpServer()
|
||||
.requestHandler(swaggerRouter::accept)
|
||||
.listen(serverPort, h -> {
|
||||
if (h.succeeded()) {
|
||||
startFuture.complete();
|
||||
} else {
|
||||
startFuture.fail(h.cause());
|
||||
}
|
||||
});
|
||||
} else {
|
||||
startFuture.fail(readFile.cause());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void deployVerticles(Future<Void> startFuture) {
|
||||
|
||||
vertx.deployVerticle("org.openapitools.server.api.verticle.PetApiVerticle", res -> {
|
||||
if (res.succeeded()) {
|
||||
LOGGER.info("PetApiVerticle : Deployed");
|
||||
} else {
|
||||
startFuture.fail(res.cause());
|
||||
LOGGER.error("PetApiVerticle : Deployment failed");
|
||||
}
|
||||
});
|
||||
|
||||
vertx.deployVerticle("org.openapitools.server.api.verticle.StoreApiVerticle", res -> {
|
||||
if (res.succeeded()) {
|
||||
LOGGER.info("StoreApiVerticle : Deployed");
|
||||
} else {
|
||||
startFuture.fail(res.cause());
|
||||
LOGGER.error("StoreApiVerticle : Deployment failed");
|
||||
}
|
||||
});
|
||||
|
||||
vertx.deployVerticle("org.openapitools.server.api.verticle.UserApiVerticle", res -> {
|
||||
if (res.succeeded()) {
|
||||
LOGGER.info("UserApiVerticle : Deployed");
|
||||
} else {
|
||||
startFuture.fail(res.cause());
|
||||
LOGGER.error("UserApiVerticle : Deployment failed");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
package org.openapitools.server.api.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* A category for a pet
|
||||
**/
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class Category {
|
||||
|
||||
private Long id;
|
||||
private String name;
|
||||
|
||||
public Category () {
|
||||
|
||||
}
|
||||
|
||||
public Category (Long id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("id")
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("name")
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Category category = (Category) o;
|
||||
return Objects.equals(id, category.id) &&
|
||||
Objects.equals(name, category.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class Category {\n");
|
||||
|
||||
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
@ -1,96 +0,0 @@
|
||||
package org.openapitools.server.api.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* Describes the result of uploading an image resource
|
||||
**/
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class ModelApiResponse {
|
||||
|
||||
private Integer code;
|
||||
private String type;
|
||||
private String message;
|
||||
|
||||
public ModelApiResponse () {
|
||||
|
||||
}
|
||||
|
||||
public ModelApiResponse (Integer code, String type, String message) {
|
||||
this.code = code;
|
||||
this.type = type;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("code")
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("type")
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("message")
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
|
||||
@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(code, _apiResponse.code) &&
|
||||
Objects.equals(type, _apiResponse.type) &&
|
||||
Objects.equals(message, _apiResponse.message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(code, type, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class ModelApiResponse {\n");
|
||||
|
||||
sb.append(" code: ").append(toIndentedString(code)).append("\n");
|
||||
sb.append(" type: ").append(toIndentedString(type)).append("\n");
|
||||
sb.append(" message: ").append(toIndentedString(message)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
@ -1,157 +0,0 @@
|
||||
package org.openapitools.server.api.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import java.time.OffsetDateTime;
|
||||
|
||||
/**
|
||||
* An order for a pets from the pet store
|
||||
**/
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class Order {
|
||||
|
||||
private Long id;
|
||||
private Long petId;
|
||||
private Integer quantity;
|
||||
private OffsetDateTime shipDate;
|
||||
|
||||
|
||||
public enum StatusEnum {
|
||||
PLACED("placed"),
|
||||
APPROVED("approved"),
|
||||
DELIVERED("delivered");
|
||||
|
||||
private String value;
|
||||
|
||||
StatusEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
public String toString() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
private StatusEnum status;
|
||||
private Boolean complete = false;
|
||||
|
||||
public Order () {
|
||||
|
||||
}
|
||||
|
||||
public Order (Long id, Long petId, Integer quantity, OffsetDateTime shipDate, StatusEnum status, Boolean complete) {
|
||||
this.id = id;
|
||||
this.petId = petId;
|
||||
this.quantity = quantity;
|
||||
this.shipDate = shipDate;
|
||||
this.status = status;
|
||||
this.complete = complete;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("id")
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("petId")
|
||||
public Long getPetId() {
|
||||
return petId;
|
||||
}
|
||||
public void setPetId(Long petId) {
|
||||
this.petId = petId;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("quantity")
|
||||
public Integer getQuantity() {
|
||||
return quantity;
|
||||
}
|
||||
public void setQuantity(Integer quantity) {
|
||||
this.quantity = quantity;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("shipDate")
|
||||
public OffsetDateTime getShipDate() {
|
||||
return shipDate;
|
||||
}
|
||||
public void setShipDate(OffsetDateTime shipDate) {
|
||||
this.shipDate = shipDate;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("status")
|
||||
public StatusEnum getStatus() {
|
||||
return status;
|
||||
}
|
||||
public void setStatus(StatusEnum status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("complete")
|
||||
public Boolean getComplete() {
|
||||
return complete;
|
||||
}
|
||||
public void setComplete(Boolean complete) {
|
||||
this.complete = complete;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Order order = (Order) o;
|
||||
return Objects.equals(id, order.id) &&
|
||||
Objects.equals(petId, order.petId) &&
|
||||
Objects.equals(quantity, order.quantity) &&
|
||||
Objects.equals(shipDate, order.shipDate) &&
|
||||
Objects.equals(status, order.status) &&
|
||||
Objects.equals(complete, order.complete);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, petId, quantity, shipDate, status, complete);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class Order {\n");
|
||||
|
||||
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
||||
sb.append(" petId: ").append(toIndentedString(petId)).append("\n");
|
||||
sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n");
|
||||
sb.append(" shipDate: ").append(toIndentedString(shipDate)).append("\n");
|
||||
sb.append(" status: ").append(toIndentedString(status)).append("\n");
|
||||
sb.append(" complete: ").append(toIndentedString(complete)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
@ -1,160 +0,0 @@
|
||||
package org.openapitools.server.api.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.openapitools.server.api.model.Category;
|
||||
import org.openapitools.server.api.model.Tag;
|
||||
|
||||
/**
|
||||
* A pet for sale in the pet store
|
||||
**/
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class Pet {
|
||||
|
||||
private Long id;
|
||||
private Category category;
|
||||
private String name;
|
||||
private List<String> photoUrls = new ArrayList<>();
|
||||
private List<Tag> tags = new ArrayList<>();
|
||||
|
||||
|
||||
public enum StatusEnum {
|
||||
AVAILABLE("available"),
|
||||
PENDING("pending"),
|
||||
SOLD("sold");
|
||||
|
||||
private String value;
|
||||
|
||||
StatusEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
public String toString() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
private StatusEnum status;
|
||||
|
||||
public Pet () {
|
||||
|
||||
}
|
||||
|
||||
public Pet (Long id, Category category, String name, List<String> photoUrls, List<Tag> tags, StatusEnum status) {
|
||||
this.id = id;
|
||||
this.category = category;
|
||||
this.name = name;
|
||||
this.photoUrls = photoUrls;
|
||||
this.tags = tags;
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("id")
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("category")
|
||||
public Category getCategory() {
|
||||
return category;
|
||||
}
|
||||
public void setCategory(Category category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("name")
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("photoUrls")
|
||||
public List<String> getPhotoUrls() {
|
||||
return photoUrls;
|
||||
}
|
||||
public void setPhotoUrls(List<String> photoUrls) {
|
||||
this.photoUrls = photoUrls;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("tags")
|
||||
public List<Tag> getTags() {
|
||||
return tags;
|
||||
}
|
||||
public void setTags(List<Tag> tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("status")
|
||||
public StatusEnum getStatus() {
|
||||
return status;
|
||||
}
|
||||
public void setStatus(StatusEnum status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Pet pet = (Pet) o;
|
||||
return Objects.equals(id, pet.id) &&
|
||||
Objects.equals(category, pet.category) &&
|
||||
Objects.equals(name, pet.name) &&
|
||||
Objects.equals(photoUrls, pet.photoUrls) &&
|
||||
Objects.equals(tags, pet.tags) &&
|
||||
Objects.equals(status, pet.status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, category, name, photoUrls, tags, status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class Pet {\n");
|
||||
|
||||
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
||||
sb.append(" category: ").append(toIndentedString(category)).append("\n");
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n");
|
||||
sb.append(" tags: ").append(toIndentedString(tags)).append("\n");
|
||||
sb.append(" status: ").append(toIndentedString(status)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
package org.openapitools.server.api.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* A tag for a pet
|
||||
**/
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class Tag {
|
||||
|
||||
private Long id;
|
||||
private String name;
|
||||
|
||||
public Tag () {
|
||||
|
||||
}
|
||||
|
||||
public Tag (Long id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("id")
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("name")
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Tag tag = (Tag) o;
|
||||
return Objects.equals(id, tag.id) &&
|
||||
Objects.equals(name, tag.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class Tag {\n");
|
||||
|
||||
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
@ -1,161 +0,0 @@
|
||||
package org.openapitools.server.api.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* A User who is purchasing from the pet store
|
||||
**/
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class User {
|
||||
|
||||
private Long id;
|
||||
private String username;
|
||||
private String firstName;
|
||||
private String lastName;
|
||||
private String email;
|
||||
private String password;
|
||||
private String phone;
|
||||
private Integer userStatus;
|
||||
|
||||
public User () {
|
||||
|
||||
}
|
||||
|
||||
public User (Long id, String username, String firstName, String lastName, String email, String password, String phone, Integer userStatus) {
|
||||
this.id = id;
|
||||
this.username = username;
|
||||
this.firstName = firstName;
|
||||
this.lastName = lastName;
|
||||
this.email = email;
|
||||
this.password = password;
|
||||
this.phone = phone;
|
||||
this.userStatus = userStatus;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("id")
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("username")
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("firstName")
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("lastName")
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("email")
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("password")
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("phone")
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("userStatus")
|
||||
public Integer getUserStatus() {
|
||||
return userStatus;
|
||||
}
|
||||
public void setUserStatus(Integer userStatus) {
|
||||
this.userStatus = userStatus;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
User user = (User) o;
|
||||
return Objects.equals(id, user.id) &&
|
||||
Objects.equals(username, user.username) &&
|
||||
Objects.equals(firstName, user.firstName) &&
|
||||
Objects.equals(lastName, user.lastName) &&
|
||||
Objects.equals(email, user.email) &&
|
||||
Objects.equals(password, user.password) &&
|
||||
Objects.equals(phone, user.phone) &&
|
||||
Objects.equals(userStatus, user.userStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, username, firstName, lastName, email, password, phone, userStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class User {\n");
|
||||
|
||||
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
||||
sb.append(" username: ").append(toIndentedString(username)).append("\n");
|
||||
sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n");
|
||||
sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n");
|
||||
sb.append(" email: ").append(toIndentedString(email)).append("\n");
|
||||
sb.append(" password: ").append(toIndentedString(password)).append("\n");
|
||||
sb.append(" phone: ").append(toIndentedString(phone)).append("\n");
|
||||
sb.append(" userStatus: ").append(toIndentedString(userStatus)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
package org.openapitools.server.api.verticle;
|
||||
|
||||
import java.io.File;
|
||||
import org.openapitools.server.api.MainApiException;
|
||||
import org.openapitools.server.api.model.ModelApiResponse;
|
||||
import org.openapitools.server.api.model.Pet;
|
||||
|
||||
import io.vertx.core.AsyncResult;
|
||||
import io.vertx.core.Handler;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface PetApi {
|
||||
//addPet
|
||||
void addPet(Pet body, Handler<AsyncResult<Void>> handler);
|
||||
|
||||
//deletePet
|
||||
void deletePet(Long petId, String apiKey, Handler<AsyncResult<Void>> handler);
|
||||
|
||||
//findPetsByStatus
|
||||
void findPetsByStatus(List<String> status, Handler<AsyncResult<List<Pet>>> handler);
|
||||
|
||||
//findPetsByTags
|
||||
void findPetsByTags(List<String> tags, Handler<AsyncResult<List<Pet>>> handler);
|
||||
|
||||
//getPetById
|
||||
void getPetById(Long petId, Handler<AsyncResult<Pet>> handler);
|
||||
|
||||
//updatePet
|
||||
void updatePet(Pet body, Handler<AsyncResult<Void>> handler);
|
||||
|
||||
//updatePetWithForm
|
||||
void updatePetWithForm(Long petId, String name, String status, Handler<AsyncResult<Void>> handler);
|
||||
|
||||
//uploadFile
|
||||
void uploadFile(Long petId, String additionalMetadata, File file, Handler<AsyncResult<ModelApiResponse>> handler);
|
||||
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package org.openapitools.server.api.verticle;
|
||||
|
||||
import java.io.File;
|
||||
import org.openapitools.server.api.MainApiException;
|
||||
import org.openapitools.server.api.model.ModelApiResponse;
|
||||
import org.openapitools.server.api.model.Pet;
|
||||
|
||||
public final class PetApiException extends MainApiException {
|
||||
public PetApiException(int statusCode, String statusMessage) {
|
||||
super(statusCode, statusMessage);
|
||||
}
|
||||
|
||||
public static final PetApiException Pet_addPet_405_Exception = new PetApiException(405, "Invalid input");
|
||||
public static final PetApiException Pet_deletePet_400_Exception = new PetApiException(400, "Invalid pet value");
|
||||
public static final PetApiException Pet_findPetsByStatus_200_Exception = new PetApiException(200, "successful operation");
|
||||
public static final PetApiException Pet_findPetsByStatus_400_Exception = new PetApiException(400, "Invalid status value");
|
||||
public static final PetApiException Pet_findPetsByTags_200_Exception = new PetApiException(200, "successful operation");
|
||||
public static final PetApiException Pet_findPetsByTags_400_Exception = new PetApiException(400, "Invalid tag value");
|
||||
public static final PetApiException Pet_getPetById_200_Exception = new PetApiException(200, "successful operation");
|
||||
public static final PetApiException Pet_getPetById_400_Exception = new PetApiException(400, "Invalid ID supplied");
|
||||
public static final PetApiException Pet_getPetById_404_Exception = new PetApiException(404, "Pet not found");
|
||||
public static final PetApiException Pet_updatePet_400_Exception = new PetApiException(400, "Invalid ID supplied");
|
||||
public static final PetApiException Pet_updatePet_404_Exception = new PetApiException(404, "Pet not found");
|
||||
public static final PetApiException Pet_updatePet_405_Exception = new PetApiException(405, "Validation exception");
|
||||
public static final PetApiException Pet_updatePetWithForm_405_Exception = new PetApiException(405, "Invalid input");
|
||||
public static final PetApiException Pet_uploadFile_200_Exception = new PetApiException(200, "successful operation");
|
||||
|
||||
|
||||
}
|
@ -1,276 +0,0 @@
|
||||
package org.openapitools.server.api.verticle;
|
||||
|
||||
import io.vertx.core.AbstractVerticle;
|
||||
import io.vertx.core.eventbus.Message;
|
||||
import io.vertx.core.json.Json;
|
||||
import io.vertx.core.json.JsonArray;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import io.vertx.core.logging.Logger;
|
||||
import io.vertx.core.logging.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import org.openapitools.server.api.MainApiException;
|
||||
import org.openapitools.server.api.model.ModelApiResponse;
|
||||
import org.openapitools.server.api.model.Pet;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class PetApiVerticle extends AbstractVerticle {
|
||||
static final Logger LOGGER = LoggerFactory.getLogger(PetApiVerticle.class);
|
||||
|
||||
static final String ADDPET_SERVICE_ID = "addPet";
|
||||
static final String DELETEPET_SERVICE_ID = "deletePet";
|
||||
static final String FINDPETSBYSTATUS_SERVICE_ID = "findPetsByStatus";
|
||||
static final String FINDPETSBYTAGS_SERVICE_ID = "findPetsByTags";
|
||||
static final String GETPETBYID_SERVICE_ID = "getPetById";
|
||||
static final String UPDATEPET_SERVICE_ID = "updatePet";
|
||||
static final String UPDATEPETWITHFORM_SERVICE_ID = "updatePetWithForm";
|
||||
static final String UPLOADFILE_SERVICE_ID = "uploadFile";
|
||||
|
||||
final PetApi service;
|
||||
|
||||
public PetApiVerticle() {
|
||||
try {
|
||||
Class serviceImplClass = getClass().getClassLoader().loadClass("org.openapitools.server.api.verticle.PetApiImpl");
|
||||
service = (PetApi)serviceImplClass.newInstance();
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("PetApiVerticle constructor", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() throws Exception {
|
||||
|
||||
//Consumer for addPet
|
||||
vertx.eventBus().<JsonObject> consumer(ADDPET_SERVICE_ID).handler(message -> {
|
||||
try {
|
||||
// Workaround for #allParams section clearing the vendorExtensions map
|
||||
String serviceId = "addPet";
|
||||
JsonObject bodyParam = message.body().getJsonObject("body");
|
||||
if (bodyParam == null) {
|
||||
manageError(message, new MainApiException(400, "body is required"), serviceId);
|
||||
return;
|
||||
}
|
||||
Pet body = Json.mapper.readValue(bodyParam.encode(), Pet.class);
|
||||
service.addPet(body, result -> {
|
||||
if (result.succeeded())
|
||||
message.reply(null);
|
||||
else {
|
||||
Throwable cause = result.cause();
|
||||
manageError(message, cause, "addPet");
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("addPet", e);
|
||||
message.fail(MainApiException.INTERNAL_SERVER_ERROR.getStatusCode(), MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage());
|
||||
}
|
||||
});
|
||||
|
||||
//Consumer for deletePet
|
||||
vertx.eventBus().<JsonObject> consumer(DELETEPET_SERVICE_ID).handler(message -> {
|
||||
try {
|
||||
// Workaround for #allParams section clearing the vendorExtensions map
|
||||
String serviceId = "deletePet";
|
||||
String petIdParam = message.body().getString("petId");
|
||||
if(petIdParam == null) {
|
||||
manageError(message, new MainApiException(400, "petId is required"), serviceId);
|
||||
return;
|
||||
}
|
||||
Long petId = Json.mapper.readValue(petIdParam, Long.class);
|
||||
String apiKeyParam = message.body().getString("api_key");
|
||||
String apiKey = (apiKeyParam == null) ? null : apiKeyParam;
|
||||
service.deletePet(petId, apiKey, result -> {
|
||||
if (result.succeeded())
|
||||
message.reply(null);
|
||||
else {
|
||||
Throwable cause = result.cause();
|
||||
manageError(message, cause, "deletePet");
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("deletePet", e);
|
||||
message.fail(MainApiException.INTERNAL_SERVER_ERROR.getStatusCode(), MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage());
|
||||
}
|
||||
});
|
||||
|
||||
//Consumer for findPetsByStatus
|
||||
vertx.eventBus().<JsonObject> consumer(FINDPETSBYSTATUS_SERVICE_ID).handler(message -> {
|
||||
try {
|
||||
// Workaround for #allParams section clearing the vendorExtensions map
|
||||
String serviceId = "findPetsByStatus";
|
||||
JsonArray statusParam = message.body().getJsonArray("status");
|
||||
if(statusParam == null) {
|
||||
manageError(message, new MainApiException(400, "status is required"), serviceId);
|
||||
return;
|
||||
}
|
||||
List<String> status = Json.mapper.readValue(statusParam.encode(),
|
||||
Json.mapper.getTypeFactory().constructCollectionType(List.class, String.class));
|
||||
service.findPetsByStatus(status, result -> {
|
||||
if (result.succeeded())
|
||||
message.reply(new JsonArray(Json.encode(result.result())).encodePrettily());
|
||||
else {
|
||||
Throwable cause = result.cause();
|
||||
manageError(message, cause, "findPetsByStatus");
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("findPetsByStatus", e);
|
||||
message.fail(MainApiException.INTERNAL_SERVER_ERROR.getStatusCode(), MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage());
|
||||
}
|
||||
});
|
||||
|
||||
//Consumer for findPetsByTags
|
||||
vertx.eventBus().<JsonObject> consumer(FINDPETSBYTAGS_SERVICE_ID).handler(message -> {
|
||||
try {
|
||||
// Workaround for #allParams section clearing the vendorExtensions map
|
||||
String serviceId = "findPetsByTags";
|
||||
JsonArray tagsParam = message.body().getJsonArray("tags");
|
||||
if(tagsParam == null) {
|
||||
manageError(message, new MainApiException(400, "tags is required"), serviceId);
|
||||
return;
|
||||
}
|
||||
List<String> tags = Json.mapper.readValue(tagsParam.encode(),
|
||||
Json.mapper.getTypeFactory().constructCollectionType(List.class, String.class));
|
||||
service.findPetsByTags(tags, result -> {
|
||||
if (result.succeeded())
|
||||
message.reply(new JsonArray(Json.encode(result.result())).encodePrettily());
|
||||
else {
|
||||
Throwable cause = result.cause();
|
||||
manageError(message, cause, "findPetsByTags");
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("findPetsByTags", e);
|
||||
message.fail(MainApiException.INTERNAL_SERVER_ERROR.getStatusCode(), MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage());
|
||||
}
|
||||
});
|
||||
|
||||
//Consumer for getPetById
|
||||
vertx.eventBus().<JsonObject> consumer(GETPETBYID_SERVICE_ID).handler(message -> {
|
||||
try {
|
||||
// Workaround for #allParams section clearing the vendorExtensions map
|
||||
String serviceId = "getPetById";
|
||||
String petIdParam = message.body().getString("petId");
|
||||
if(petIdParam == null) {
|
||||
manageError(message, new MainApiException(400, "petId is required"), serviceId);
|
||||
return;
|
||||
}
|
||||
Long petId = Json.mapper.readValue(petIdParam, Long.class);
|
||||
service.getPetById(petId, result -> {
|
||||
if (result.succeeded())
|
||||
message.reply(new JsonObject(Json.encode(result.result())).encodePrettily());
|
||||
else {
|
||||
Throwable cause = result.cause();
|
||||
manageError(message, cause, "getPetById");
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("getPetById", e);
|
||||
message.fail(MainApiException.INTERNAL_SERVER_ERROR.getStatusCode(), MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage());
|
||||
}
|
||||
});
|
||||
|
||||
//Consumer for updatePet
|
||||
vertx.eventBus().<JsonObject> consumer(UPDATEPET_SERVICE_ID).handler(message -> {
|
||||
try {
|
||||
// Workaround for #allParams section clearing the vendorExtensions map
|
||||
String serviceId = "updatePet";
|
||||
JsonObject bodyParam = message.body().getJsonObject("body");
|
||||
if (bodyParam == null) {
|
||||
manageError(message, new MainApiException(400, "body is required"), serviceId);
|
||||
return;
|
||||
}
|
||||
Pet body = Json.mapper.readValue(bodyParam.encode(), Pet.class);
|
||||
service.updatePet(body, result -> {
|
||||
if (result.succeeded())
|
||||
message.reply(null);
|
||||
else {
|
||||
Throwable cause = result.cause();
|
||||
manageError(message, cause, "updatePet");
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("updatePet", e);
|
||||
message.fail(MainApiException.INTERNAL_SERVER_ERROR.getStatusCode(), MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage());
|
||||
}
|
||||
});
|
||||
|
||||
//Consumer for updatePetWithForm
|
||||
vertx.eventBus().<JsonObject> consumer(UPDATEPETWITHFORM_SERVICE_ID).handler(message -> {
|
||||
try {
|
||||
// Workaround for #allParams section clearing the vendorExtensions map
|
||||
String serviceId = "updatePetWithForm";
|
||||
String petIdParam = message.body().getString("petId");
|
||||
if(petIdParam == null) {
|
||||
manageError(message, new MainApiException(400, "petId is required"), serviceId);
|
||||
return;
|
||||
}
|
||||
Long petId = Json.mapper.readValue(petIdParam, Long.class);
|
||||
String nameParam = message.body().getString("name");
|
||||
String name = (nameParam == null) ? null : nameParam;
|
||||
String statusParam = message.body().getString("status");
|
||||
String status = (statusParam == null) ? null : statusParam;
|
||||
service.updatePetWithForm(petId, name, status, result -> {
|
||||
if (result.succeeded())
|
||||
message.reply(null);
|
||||
else {
|
||||
Throwable cause = result.cause();
|
||||
manageError(message, cause, "updatePetWithForm");
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("updatePetWithForm", e);
|
||||
message.fail(MainApiException.INTERNAL_SERVER_ERROR.getStatusCode(), MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage());
|
||||
}
|
||||
});
|
||||
|
||||
//Consumer for uploadFile
|
||||
vertx.eventBus().<JsonObject> consumer(UPLOADFILE_SERVICE_ID).handler(message -> {
|
||||
try {
|
||||
// Workaround for #allParams section clearing the vendorExtensions map
|
||||
String serviceId = "uploadFile";
|
||||
String petIdParam = message.body().getString("petId");
|
||||
if(petIdParam == null) {
|
||||
manageError(message, new MainApiException(400, "petId is required"), serviceId);
|
||||
return;
|
||||
}
|
||||
Long petId = Json.mapper.readValue(petIdParam, Long.class);
|
||||
String additionalMetadataParam = message.body().getString("additionalMetadata");
|
||||
String additionalMetadata = (additionalMetadataParam == null) ? null : additionalMetadataParam;
|
||||
String fileParam = message.body().getString("file");
|
||||
File file = (fileParam == null) ? null : Json.mapper.readValue(fileParam, File.class);
|
||||
service.uploadFile(petId, additionalMetadata, file, result -> {
|
||||
if (result.succeeded())
|
||||
message.reply(new JsonObject(Json.encode(result.result())).encodePrettily());
|
||||
else {
|
||||
Throwable cause = result.cause();
|
||||
manageError(message, cause, "uploadFile");
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("uploadFile", e);
|
||||
message.fail(MainApiException.INTERNAL_SERVER_ERROR.getStatusCode(), MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void manageError(Message<JsonObject> message, Throwable cause, String serviceName) {
|
||||
int code = MainApiException.INTERNAL_SERVER_ERROR.getStatusCode();
|
||||
String statusMessage = MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage();
|
||||
if (cause instanceof MainApiException) {
|
||||
code = ((MainApiException)cause).getStatusCode();
|
||||
statusMessage = ((MainApiException)cause).getStatusMessage();
|
||||
} else {
|
||||
logUnexpectedError(serviceName, cause);
|
||||
}
|
||||
|
||||
message.fail(code, statusMessage);
|
||||
}
|
||||
|
||||
private void logUnexpectedError(String serviceName, Throwable cause) {
|
||||
LOGGER.error("Unexpected error in "+ serviceName, cause);
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
package org.openapitools.server.api.verticle;
|
||||
|
||||
import org.openapitools.server.api.MainApiException;
|
||||
import org.openapitools.server.api.model.Order;
|
||||
|
||||
import io.vertx.core.AsyncResult;
|
||||
import io.vertx.core.Handler;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface StoreApi {
|
||||
//deleteOrder
|
||||
void deleteOrder(String orderId, Handler<AsyncResult<Void>> handler);
|
||||
|
||||
//getInventory
|
||||
void getInventory(Handler<AsyncResult<Map<String, Integer>>> handler);
|
||||
|
||||
//getOrderById
|
||||
void getOrderById(Long orderId, Handler<AsyncResult<Order>> handler);
|
||||
|
||||
//placeOrder
|
||||
void placeOrder(Order body, Handler<AsyncResult<Order>> handler);
|
||||
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package org.openapitools.server.api.verticle;
|
||||
|
||||
import org.openapitools.server.api.MainApiException;
|
||||
import org.openapitools.server.api.model.Order;
|
||||
|
||||
public final class StoreApiException extends MainApiException {
|
||||
public StoreApiException(int statusCode, String statusMessage) {
|
||||
super(statusCode, statusMessage);
|
||||
}
|
||||
|
||||
public static final StoreApiException Store_deleteOrder_400_Exception = new StoreApiException(400, "Invalid ID supplied");
|
||||
public static final StoreApiException Store_deleteOrder_404_Exception = new StoreApiException(404, "Order not found");
|
||||
public static final StoreApiException Store_getInventory_200_Exception = new StoreApiException(200, "successful operation");
|
||||
public static final StoreApiException Store_getOrderById_200_Exception = new StoreApiException(200, "successful operation");
|
||||
public static final StoreApiException Store_getOrderById_400_Exception = new StoreApiException(400, "Invalid ID supplied");
|
||||
public static final StoreApiException Store_getOrderById_404_Exception = new StoreApiException(404, "Order not found");
|
||||
public static final StoreApiException Store_placeOrder_200_Exception = new StoreApiException(200, "successful operation");
|
||||
public static final StoreApiException Store_placeOrder_400_Exception = new StoreApiException(400, "Invalid Order");
|
||||
|
||||
|
||||
}
|
@ -1,152 +0,0 @@
|
||||
package org.openapitools.server.api.verticle;
|
||||
|
||||
import io.vertx.core.AbstractVerticle;
|
||||
import io.vertx.core.eventbus.Message;
|
||||
import io.vertx.core.json.Json;
|
||||
import io.vertx.core.json.JsonArray;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import io.vertx.core.logging.Logger;
|
||||
import io.vertx.core.logging.LoggerFactory;
|
||||
|
||||
import org.openapitools.server.api.MainApiException;
|
||||
import org.openapitools.server.api.model.Order;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class StoreApiVerticle extends AbstractVerticle {
|
||||
static final Logger LOGGER = LoggerFactory.getLogger(StoreApiVerticle.class);
|
||||
|
||||
static final String DELETEORDER_SERVICE_ID = "deleteOrder";
|
||||
static final String GETINVENTORY_SERVICE_ID = "getInventory";
|
||||
static final String GETORDERBYID_SERVICE_ID = "getOrderById";
|
||||
static final String PLACEORDER_SERVICE_ID = "placeOrder";
|
||||
|
||||
final StoreApi service;
|
||||
|
||||
public StoreApiVerticle() {
|
||||
try {
|
||||
Class serviceImplClass = getClass().getClassLoader().loadClass("org.openapitools.server.api.verticle.StoreApiImpl");
|
||||
service = (StoreApi)serviceImplClass.newInstance();
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("StoreApiVerticle constructor", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() throws Exception {
|
||||
|
||||
//Consumer for deleteOrder
|
||||
vertx.eventBus().<JsonObject> consumer(DELETEORDER_SERVICE_ID).handler(message -> {
|
||||
try {
|
||||
// Workaround for #allParams section clearing the vendorExtensions map
|
||||
String serviceId = "deleteOrder";
|
||||
String orderIdParam = message.body().getString("orderId");
|
||||
if(orderIdParam == null) {
|
||||
manageError(message, new MainApiException(400, "orderId is required"), serviceId);
|
||||
return;
|
||||
}
|
||||
String orderId = orderIdParam;
|
||||
service.deleteOrder(orderId, result -> {
|
||||
if (result.succeeded())
|
||||
message.reply(null);
|
||||
else {
|
||||
Throwable cause = result.cause();
|
||||
manageError(message, cause, "deleteOrder");
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("deleteOrder", e);
|
||||
message.fail(MainApiException.INTERNAL_SERVER_ERROR.getStatusCode(), MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage());
|
||||
}
|
||||
});
|
||||
|
||||
//Consumer for getInventory
|
||||
vertx.eventBus().<JsonObject> consumer(GETINVENTORY_SERVICE_ID).handler(message -> {
|
||||
try {
|
||||
// Workaround for #allParams section clearing the vendorExtensions map
|
||||
String serviceId = "getInventory";
|
||||
service.getInventory(result -> {
|
||||
if (result.succeeded())
|
||||
message.reply(new JsonObject(Json.encode(result.result())).encodePrettily());
|
||||
else {
|
||||
Throwable cause = result.cause();
|
||||
manageError(message, cause, "getInventory");
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("getInventory", e);
|
||||
message.fail(MainApiException.INTERNAL_SERVER_ERROR.getStatusCode(), MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage());
|
||||
}
|
||||
});
|
||||
|
||||
//Consumer for getOrderById
|
||||
vertx.eventBus().<JsonObject> consumer(GETORDERBYID_SERVICE_ID).handler(message -> {
|
||||
try {
|
||||
// Workaround for #allParams section clearing the vendorExtensions map
|
||||
String serviceId = "getOrderById";
|
||||
String orderIdParam = message.body().getString("orderId");
|
||||
if(orderIdParam == null) {
|
||||
manageError(message, new MainApiException(400, "orderId is required"), serviceId);
|
||||
return;
|
||||
}
|
||||
Long orderId = Json.mapper.readValue(orderIdParam, Long.class);
|
||||
service.getOrderById(orderId, result -> {
|
||||
if (result.succeeded())
|
||||
message.reply(new JsonObject(Json.encode(result.result())).encodePrettily());
|
||||
else {
|
||||
Throwable cause = result.cause();
|
||||
manageError(message, cause, "getOrderById");
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("getOrderById", e);
|
||||
message.fail(MainApiException.INTERNAL_SERVER_ERROR.getStatusCode(), MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage());
|
||||
}
|
||||
});
|
||||
|
||||
//Consumer for placeOrder
|
||||
vertx.eventBus().<JsonObject> consumer(PLACEORDER_SERVICE_ID).handler(message -> {
|
||||
try {
|
||||
// Workaround for #allParams section clearing the vendorExtensions map
|
||||
String serviceId = "placeOrder";
|
||||
JsonObject bodyParam = message.body().getJsonObject("body");
|
||||
if (bodyParam == null) {
|
||||
manageError(message, new MainApiException(400, "body is required"), serviceId);
|
||||
return;
|
||||
}
|
||||
Order body = Json.mapper.readValue(bodyParam.encode(), Order.class);
|
||||
service.placeOrder(body, result -> {
|
||||
if (result.succeeded())
|
||||
message.reply(new JsonObject(Json.encode(result.result())).encodePrettily());
|
||||
else {
|
||||
Throwable cause = result.cause();
|
||||
manageError(message, cause, "placeOrder");
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("placeOrder", e);
|
||||
message.fail(MainApiException.INTERNAL_SERVER_ERROR.getStatusCode(), MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void manageError(Message<JsonObject> message, Throwable cause, String serviceName) {
|
||||
int code = MainApiException.INTERNAL_SERVER_ERROR.getStatusCode();
|
||||
String statusMessage = MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage();
|
||||
if (cause instanceof MainApiException) {
|
||||
code = ((MainApiException)cause).getStatusCode();
|
||||
statusMessage = ((MainApiException)cause).getStatusMessage();
|
||||
} else {
|
||||
logUnexpectedError(serviceName, cause);
|
||||
}
|
||||
|
||||
message.fail(code, statusMessage);
|
||||
}
|
||||
|
||||
private void logUnexpectedError(String serviceName, Throwable cause) {
|
||||
LOGGER.error("Unexpected error in "+ serviceName, cause);
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
package org.openapitools.server.api.verticle;
|
||||
|
||||
import org.openapitools.server.api.MainApiException;
|
||||
import org.openapitools.server.api.model.User;
|
||||
|
||||
import io.vertx.core.AsyncResult;
|
||||
import io.vertx.core.Handler;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface UserApi {
|
||||
//createUser
|
||||
void createUser(User body, Handler<AsyncResult<Void>> handler);
|
||||
|
||||
//createUsersWithArrayInput
|
||||
void createUsersWithArrayInput(List<User> body, Handler<AsyncResult<Void>> handler);
|
||||
|
||||
//createUsersWithListInput
|
||||
void createUsersWithListInput(List<User> body, Handler<AsyncResult<Void>> handler);
|
||||
|
||||
//deleteUser
|
||||
void deleteUser(String username, Handler<AsyncResult<Void>> handler);
|
||||
|
||||
//getUserByName
|
||||
void getUserByName(String username, Handler<AsyncResult<User>> handler);
|
||||
|
||||
//loginUser
|
||||
void loginUser(String username, String password, Handler<AsyncResult<String>> handler);
|
||||
|
||||
//logoutUser
|
||||
void logoutUser(Handler<AsyncResult<Void>> handler);
|
||||
|
||||
//updateUser
|
||||
void updateUser(String username, User body, Handler<AsyncResult<Void>> handler);
|
||||
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package org.openapitools.server.api.verticle;
|
||||
|
||||
import org.openapitools.server.api.MainApiException;
|
||||
import org.openapitools.server.api.model.User;
|
||||
|
||||
public final class UserApiException extends MainApiException {
|
||||
public UserApiException(int statusCode, String statusMessage) {
|
||||
super(statusCode, statusMessage);
|
||||
}
|
||||
|
||||
public static final UserApiException User_deleteUser_400_Exception = new UserApiException(400, "Invalid username supplied");
|
||||
public static final UserApiException User_deleteUser_404_Exception = new UserApiException(404, "User not found");
|
||||
public static final UserApiException User_getUserByName_200_Exception = new UserApiException(200, "successful operation");
|
||||
public static final UserApiException User_getUserByName_400_Exception = new UserApiException(400, "Invalid username supplied");
|
||||
public static final UserApiException User_getUserByName_404_Exception = new UserApiException(404, "User not found");
|
||||
public static final UserApiException User_loginUser_200_Exception = new UserApiException(200, "successful operation");
|
||||
public static final UserApiException User_loginUser_400_Exception = new UserApiException(400, "Invalid username/password supplied");
|
||||
public static final UserApiException User_updateUser_400_Exception = new UserApiException(400, "Invalid user supplied");
|
||||
public static final UserApiException User_updateUser_404_Exception = new UserApiException(404, "User not found");
|
||||
|
||||
|
||||
}
|
@ -1,270 +0,0 @@
|
||||
package org.openapitools.server.api.verticle;
|
||||
|
||||
import io.vertx.core.AbstractVerticle;
|
||||
import io.vertx.core.eventbus.Message;
|
||||
import io.vertx.core.json.Json;
|
||||
import io.vertx.core.json.JsonArray;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import io.vertx.core.logging.Logger;
|
||||
import io.vertx.core.logging.LoggerFactory;
|
||||
|
||||
import org.openapitools.server.api.MainApiException;
|
||||
import org.openapitools.server.api.model.User;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class UserApiVerticle extends AbstractVerticle {
|
||||
static final Logger LOGGER = LoggerFactory.getLogger(UserApiVerticle.class);
|
||||
|
||||
static final String CREATEUSER_SERVICE_ID = "createUser";
|
||||
static final String CREATEUSERSWITHARRAYINPUT_SERVICE_ID = "createUsersWithArrayInput";
|
||||
static final String CREATEUSERSWITHLISTINPUT_SERVICE_ID = "createUsersWithListInput";
|
||||
static final String DELETEUSER_SERVICE_ID = "deleteUser";
|
||||
static final String GETUSERBYNAME_SERVICE_ID = "getUserByName";
|
||||
static final String LOGINUSER_SERVICE_ID = "loginUser";
|
||||
static final String LOGOUTUSER_SERVICE_ID = "logoutUser";
|
||||
static final String UPDATEUSER_SERVICE_ID = "updateUser";
|
||||
|
||||
final UserApi service;
|
||||
|
||||
public UserApiVerticle() {
|
||||
try {
|
||||
Class serviceImplClass = getClass().getClassLoader().loadClass("org.openapitools.server.api.verticle.UserApiImpl");
|
||||
service = (UserApi)serviceImplClass.newInstance();
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("UserApiVerticle constructor", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() throws Exception {
|
||||
|
||||
//Consumer for createUser
|
||||
vertx.eventBus().<JsonObject> consumer(CREATEUSER_SERVICE_ID).handler(message -> {
|
||||
try {
|
||||
// Workaround for #allParams section clearing the vendorExtensions map
|
||||
String serviceId = "createUser";
|
||||
JsonObject bodyParam = message.body().getJsonObject("body");
|
||||
if (bodyParam == null) {
|
||||
manageError(message, new MainApiException(400, "body is required"), serviceId);
|
||||
return;
|
||||
}
|
||||
User body = Json.mapper.readValue(bodyParam.encode(), User.class);
|
||||
service.createUser(body, result -> {
|
||||
if (result.succeeded())
|
||||
message.reply(null);
|
||||
else {
|
||||
Throwable cause = result.cause();
|
||||
manageError(message, cause, "createUser");
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("createUser", e);
|
||||
message.fail(MainApiException.INTERNAL_SERVER_ERROR.getStatusCode(), MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage());
|
||||
}
|
||||
});
|
||||
|
||||
//Consumer for createUsersWithArrayInput
|
||||
vertx.eventBus().<JsonObject> consumer(CREATEUSERSWITHARRAYINPUT_SERVICE_ID).handler(message -> {
|
||||
try {
|
||||
// Workaround for #allParams section clearing the vendorExtensions map
|
||||
String serviceId = "createUsersWithArrayInput";
|
||||
JsonArray bodyParam = message.body().getJsonArray("body");
|
||||
if(bodyParam == null) {
|
||||
manageError(message, new MainApiException(400, "body is required"), serviceId);
|
||||
return;
|
||||
}
|
||||
List<User> body = Json.mapper.readValue(bodyParam.encode(),
|
||||
Json.mapper.getTypeFactory().constructCollectionType(List.class, User.class));
|
||||
service.createUsersWithArrayInput(body, result -> {
|
||||
if (result.succeeded())
|
||||
message.reply(null);
|
||||
else {
|
||||
Throwable cause = result.cause();
|
||||
manageError(message, cause, "createUsersWithArrayInput");
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("createUsersWithArrayInput", e);
|
||||
message.fail(MainApiException.INTERNAL_SERVER_ERROR.getStatusCode(), MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage());
|
||||
}
|
||||
});
|
||||
|
||||
//Consumer for createUsersWithListInput
|
||||
vertx.eventBus().<JsonObject> consumer(CREATEUSERSWITHLISTINPUT_SERVICE_ID).handler(message -> {
|
||||
try {
|
||||
// Workaround for #allParams section clearing the vendorExtensions map
|
||||
String serviceId = "createUsersWithListInput";
|
||||
JsonArray bodyParam = message.body().getJsonArray("body");
|
||||
if(bodyParam == null) {
|
||||
manageError(message, new MainApiException(400, "body is required"), serviceId);
|
||||
return;
|
||||
}
|
||||
List<User> body = Json.mapper.readValue(bodyParam.encode(),
|
||||
Json.mapper.getTypeFactory().constructCollectionType(List.class, User.class));
|
||||
service.createUsersWithListInput(body, result -> {
|
||||
if (result.succeeded())
|
||||
message.reply(null);
|
||||
else {
|
||||
Throwable cause = result.cause();
|
||||
manageError(message, cause, "createUsersWithListInput");
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("createUsersWithListInput", e);
|
||||
message.fail(MainApiException.INTERNAL_SERVER_ERROR.getStatusCode(), MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage());
|
||||
}
|
||||
});
|
||||
|
||||
//Consumer for deleteUser
|
||||
vertx.eventBus().<JsonObject> consumer(DELETEUSER_SERVICE_ID).handler(message -> {
|
||||
try {
|
||||
// Workaround for #allParams section clearing the vendorExtensions map
|
||||
String serviceId = "deleteUser";
|
||||
String usernameParam = message.body().getString("username");
|
||||
if(usernameParam == null) {
|
||||
manageError(message, new MainApiException(400, "username is required"), serviceId);
|
||||
return;
|
||||
}
|
||||
String username = usernameParam;
|
||||
service.deleteUser(username, result -> {
|
||||
if (result.succeeded())
|
||||
message.reply(null);
|
||||
else {
|
||||
Throwable cause = result.cause();
|
||||
manageError(message, cause, "deleteUser");
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("deleteUser", e);
|
||||
message.fail(MainApiException.INTERNAL_SERVER_ERROR.getStatusCode(), MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage());
|
||||
}
|
||||
});
|
||||
|
||||
//Consumer for getUserByName
|
||||
vertx.eventBus().<JsonObject> consumer(GETUSERBYNAME_SERVICE_ID).handler(message -> {
|
||||
try {
|
||||
// Workaround for #allParams section clearing the vendorExtensions map
|
||||
String serviceId = "getUserByName";
|
||||
String usernameParam = message.body().getString("username");
|
||||
if(usernameParam == null) {
|
||||
manageError(message, new MainApiException(400, "username is required"), serviceId);
|
||||
return;
|
||||
}
|
||||
String username = usernameParam;
|
||||
service.getUserByName(username, result -> {
|
||||
if (result.succeeded())
|
||||
message.reply(new JsonObject(Json.encode(result.result())).encodePrettily());
|
||||
else {
|
||||
Throwable cause = result.cause();
|
||||
manageError(message, cause, "getUserByName");
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("getUserByName", e);
|
||||
message.fail(MainApiException.INTERNAL_SERVER_ERROR.getStatusCode(), MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage());
|
||||
}
|
||||
});
|
||||
|
||||
//Consumer for loginUser
|
||||
vertx.eventBus().<JsonObject> consumer(LOGINUSER_SERVICE_ID).handler(message -> {
|
||||
try {
|
||||
// Workaround for #allParams section clearing the vendorExtensions map
|
||||
String serviceId = "loginUser";
|
||||
String usernameParam = message.body().getString("username");
|
||||
if(usernameParam == null) {
|
||||
manageError(message, new MainApiException(400, "username is required"), serviceId);
|
||||
return;
|
||||
}
|
||||
String username = usernameParam;
|
||||
String passwordParam = message.body().getString("password");
|
||||
if(passwordParam == null) {
|
||||
manageError(message, new MainApiException(400, "password is required"), serviceId);
|
||||
return;
|
||||
}
|
||||
String password = passwordParam;
|
||||
service.loginUser(username, password, result -> {
|
||||
if (result.succeeded())
|
||||
message.reply(new JsonObject(Json.encode(result.result())).encodePrettily());
|
||||
else {
|
||||
Throwable cause = result.cause();
|
||||
manageError(message, cause, "loginUser");
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("loginUser", e);
|
||||
message.fail(MainApiException.INTERNAL_SERVER_ERROR.getStatusCode(), MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage());
|
||||
}
|
||||
});
|
||||
|
||||
//Consumer for logoutUser
|
||||
vertx.eventBus().<JsonObject> consumer(LOGOUTUSER_SERVICE_ID).handler(message -> {
|
||||
try {
|
||||
// Workaround for #allParams section clearing the vendorExtensions map
|
||||
String serviceId = "logoutUser";
|
||||
service.logoutUser(result -> {
|
||||
if (result.succeeded())
|
||||
message.reply(null);
|
||||
else {
|
||||
Throwable cause = result.cause();
|
||||
manageError(message, cause, "logoutUser");
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("logoutUser", e);
|
||||
message.fail(MainApiException.INTERNAL_SERVER_ERROR.getStatusCode(), MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage());
|
||||
}
|
||||
});
|
||||
|
||||
//Consumer for updateUser
|
||||
vertx.eventBus().<JsonObject> consumer(UPDATEUSER_SERVICE_ID).handler(message -> {
|
||||
try {
|
||||
// Workaround for #allParams section clearing the vendorExtensions map
|
||||
String serviceId = "updateUser";
|
||||
String usernameParam = message.body().getString("username");
|
||||
if(usernameParam == null) {
|
||||
manageError(message, new MainApiException(400, "username is required"), serviceId);
|
||||
return;
|
||||
}
|
||||
String username = usernameParam;
|
||||
JsonObject bodyParam = message.body().getJsonObject("body");
|
||||
if (bodyParam == null) {
|
||||
manageError(message, new MainApiException(400, "body is required"), serviceId);
|
||||
return;
|
||||
}
|
||||
User body = Json.mapper.readValue(bodyParam.encode(), User.class);
|
||||
service.updateUser(username, body, result -> {
|
||||
if (result.succeeded())
|
||||
message.reply(null);
|
||||
else {
|
||||
Throwable cause = result.cause();
|
||||
manageError(message, cause, "updateUser");
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("updateUser", e);
|
||||
message.fail(MainApiException.INTERNAL_SERVER_ERROR.getStatusCode(), MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void manageError(Message<JsonObject> message, Throwable cause, String serviceName) {
|
||||
int code = MainApiException.INTERNAL_SERVER_ERROR.getStatusCode();
|
||||
String statusMessage = MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage();
|
||||
if (cause instanceof MainApiException) {
|
||||
code = ((MainApiException)cause).getStatusCode();
|
||||
statusMessage = ((MainApiException)cause).getStatusMessage();
|
||||
} else {
|
||||
logUnexpectedError(serviceName, cause);
|
||||
}
|
||||
|
||||
message.fail(code, statusMessage);
|
||||
}
|
||||
|
||||
private void logUnexpectedError(String serviceName, Throwable cause) {
|
||||
LOGGER.error("Unexpected error in "+ serviceName, cause);
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,30 +0,0 @@
|
||||
#
|
||||
# Copyright 2014 Red Hat, Inc.
|
||||
#
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# are made available under the terms of the Eclipse Public License v1.0
|
||||
# and Apache License v2.0 which accompanies this distribution.
|
||||
#
|
||||
# The Eclipse Public License is available at
|
||||
# http://www.eclipse.org/legal/epl-v10.html
|
||||
#
|
||||
# The Apache License v2.0 is available at
|
||||
# http://www.opensource.org/licenses/apache2.0.php
|
||||
#
|
||||
# You may elect to redistribute this code under either of these licenses.
|
||||
#
|
||||
handlers=java.util.logging.ConsoleHandler,java.util.logging.FileHandler
|
||||
java.util.logging.SimpleFormatter.format=%5$s %6$s\n
|
||||
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
|
||||
java.util.logging.ConsoleHandler.level=FINEST
|
||||
java.util.logging.FileHandler.level=INFO
|
||||
java.util.logging.FileHandler.formatter=io.vertx.core.logging.VertxLoggerFormatter
|
||||
|
||||
# Put the log in the system temporary directory
|
||||
java.util.logging.FileHandler.pattern=vertx.log
|
||||
|
||||
.level=INFO
|
||||
io.vertx.ext.web.level=FINEST
|
||||
io.vertx.level=INFO
|
||||
com.hazelcast.level=INFO
|
||||
io.netty.util.internal.PlatformDependent.level=SEVERE
|
@ -1,23 +0,0 @@
|
||||
# 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
|
@ -1,21 +0,0 @@
|
||||
README.md
|
||||
pom.xml
|
||||
src/main/java/org/openapitools/server/api/MainApiException.java
|
||||
src/main/java/org/openapitools/server/api/MainApiVerticle.java
|
||||
src/main/java/org/openapitools/server/api/model/Category.java
|
||||
src/main/java/org/openapitools/server/api/model/ModelApiResponse.java
|
||||
src/main/java/org/openapitools/server/api/model/Order.java
|
||||
src/main/java/org/openapitools/server/api/model/Pet.java
|
||||
src/main/java/org/openapitools/server/api/model/Tag.java
|
||||
src/main/java/org/openapitools/server/api/model/User.java
|
||||
src/main/java/org/openapitools/server/api/verticle/PetApi.java
|
||||
src/main/java/org/openapitools/server/api/verticle/PetApiException.java
|
||||
src/main/java/org/openapitools/server/api/verticle/PetApiVerticle.java
|
||||
src/main/java/org/openapitools/server/api/verticle/StoreApi.java
|
||||
src/main/java/org/openapitools/server/api/verticle/StoreApiException.java
|
||||
src/main/java/org/openapitools/server/api/verticle/StoreApiVerticle.java
|
||||
src/main/java/org/openapitools/server/api/verticle/UserApi.java
|
||||
src/main/java/org/openapitools/server/api/verticle/UserApiException.java
|
||||
src/main/java/org/openapitools/server/api/verticle/UserApiVerticle.java
|
||||
src/main/resources/openapi.json
|
||||
src/main/resources/vertx-default-jul-logging.properties
|
@ -1 +0,0 @@
|
||||
5.0.1-SNAPSHOT
|
@ -1,91 +0,0 @@
|
||||
<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>java-vertx-rx-server</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>OpenAPI Petstore</name>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<junit.version>4.13.1</junit.version>
|
||||
<vertx.version>3.4.1</vertx.version>
|
||||
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
|
||||
<vertx-swagger-router.version>1.4.0</vertx-swagger-router.version>
|
||||
<maven-shade-plugin.version>2.3</maven-shade-plugin.version>
|
||||
<jackson-datatype-jsr310.version>2.7.4</jackson-datatype-jsr310.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.vertx</groupId>
|
||||
<artifactId>vertx-unit</artifactId>
|
||||
<version>${vertx.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.phiz71</groupId>
|
||||
<artifactId>vertx-swagger-router</artifactId>
|
||||
<version>${vertx-swagger-router.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
<version>${jackson-datatype-jsr310.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${maven-compiler-plugin.version}</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>${maven-shade-plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<transformers>
|
||||
<transformer
|
||||
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||
<manifestEntries>
|
||||
<Main-Class>io.vertx.core.Starter</Main-Class>
|
||||
<Main-Verticle>org.openapitools.server.api.MainApiVerticle</Main-Verticle>
|
||||
</manifestEntries>
|
||||
</transformer>
|
||||
</transformers>
|
||||
<artifactSet />
|
||||
<outputFile>${project.build.directory}/${project.artifactId}-${project.version}-fat.jar</outputFile>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -1,22 +0,0 @@
|
||||
package org.openapitools.server.api;
|
||||
|
||||
public class MainApiException extends Exception {
|
||||
private int statusCode;
|
||||
private String statusMessage;
|
||||
|
||||
public MainApiException(int statusCode, String statusMessage) {
|
||||
super();
|
||||
this.statusCode = statusCode;
|
||||
this.statusMessage = statusMessage;
|
||||
}
|
||||
|
||||
public int getStatusCode() {
|
||||
return statusCode;
|
||||
}
|
||||
|
||||
public String getStatusMessage() {
|
||||
return statusMessage;
|
||||
}
|
||||
|
||||
public static final MainApiException INTERNAL_SERVER_ERROR = new MainApiException(500, "Internal Server Error");
|
||||
}
|
@ -1,97 +0,0 @@
|
||||
package org.openapitools.server.api;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import com.github.phiz71.vertx.swagger.router.OperationIdServiceIdResolver;
|
||||
import com.github.phiz71.vertx.swagger.router.SwaggerRouter;
|
||||
|
||||
import io.swagger.models.Swagger;
|
||||
import io.swagger.parser.SwaggerParser;
|
||||
import io.vertx.core.AbstractVerticle;
|
||||
import io.vertx.core.Context;
|
||||
import io.vertx.core.Future;
|
||||
import io.vertx.core.file.FileSystem;
|
||||
import io.vertx.core.json.Json;
|
||||
import io.vertx.core.logging.Logger;
|
||||
import io.vertx.core.logging.LoggerFactory;
|
||||
import io.vertx.core.Vertx;
|
||||
import io.vertx.ext.web.Router;
|
||||
|
||||
public class MainApiVerticle extends AbstractVerticle {
|
||||
static final Logger LOGGER = LoggerFactory.getLogger(MainApiVerticle.class);
|
||||
|
||||
private int serverPort = 8080;
|
||||
protected Router router;
|
||||
|
||||
public int getServerPort() {
|
||||
return serverPort;
|
||||
}
|
||||
|
||||
public void setServerPort(int serverPort) {
|
||||
this.serverPort = serverPort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Vertx vertx, Context context) {
|
||||
super.init(vertx, context);
|
||||
router = Router.router(vertx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(Future<Void> startFuture) throws Exception {
|
||||
Json.mapper.registerModule(new JavaTimeModule());
|
||||
FileSystem vertxFileSystem = vertx.fileSystem();
|
||||
vertxFileSystem.readFile("openapi.json", readFile -> {
|
||||
if (readFile.succeeded()) {
|
||||
Swagger swagger = new SwaggerParser().parse(readFile.result().toString(Charset.forName("utf-8")));
|
||||
Router swaggerRouter = SwaggerRouter.swaggerRouter(router, swagger, vertx.eventBus(), new OperationIdServiceIdResolver());
|
||||
|
||||
deployVerticles(startFuture);
|
||||
|
||||
vertx.createHttpServer()
|
||||
.requestHandler(swaggerRouter::accept)
|
||||
.listen(serverPort, h -> {
|
||||
if (h.succeeded()) {
|
||||
startFuture.complete();
|
||||
} else {
|
||||
startFuture.fail(h.cause());
|
||||
}
|
||||
});
|
||||
} else {
|
||||
startFuture.fail(readFile.cause());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void deployVerticles(Future<Void> startFuture) {
|
||||
|
||||
vertx.deployVerticle("org.openapitools.server.api.verticle.PetApiVerticle", res -> {
|
||||
if (res.succeeded()) {
|
||||
LOGGER.info("PetApiVerticle : Deployed");
|
||||
} else {
|
||||
startFuture.fail(res.cause());
|
||||
LOGGER.error("PetApiVerticle : Deployment failed");
|
||||
}
|
||||
});
|
||||
|
||||
vertx.deployVerticle("org.openapitools.server.api.verticle.StoreApiVerticle", res -> {
|
||||
if (res.succeeded()) {
|
||||
LOGGER.info("StoreApiVerticle : Deployed");
|
||||
} else {
|
||||
startFuture.fail(res.cause());
|
||||
LOGGER.error("StoreApiVerticle : Deployment failed");
|
||||
}
|
||||
});
|
||||
|
||||
vertx.deployVerticle("org.openapitools.server.api.verticle.UserApiVerticle", res -> {
|
||||
if (res.succeeded()) {
|
||||
LOGGER.info("UserApiVerticle : Deployed");
|
||||
} else {
|
||||
startFuture.fail(res.cause());
|
||||
LOGGER.error("UserApiVerticle : Deployment failed");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
package org.openapitools.server.api.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* A category for a pet
|
||||
**/
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class Category {
|
||||
|
||||
private Long id;
|
||||
private String name;
|
||||
|
||||
public Category () {
|
||||
|
||||
}
|
||||
|
||||
public Category (Long id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("id")
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("name")
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Category category = (Category) o;
|
||||
return Objects.equals(id, category.id) &&
|
||||
Objects.equals(name, category.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class Category {\n");
|
||||
|
||||
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
@ -1,96 +0,0 @@
|
||||
package org.openapitools.server.api.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* Describes the result of uploading an image resource
|
||||
**/
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class ModelApiResponse {
|
||||
|
||||
private Integer code;
|
||||
private String type;
|
||||
private String message;
|
||||
|
||||
public ModelApiResponse () {
|
||||
|
||||
}
|
||||
|
||||
public ModelApiResponse (Integer code, String type, String message) {
|
||||
this.code = code;
|
||||
this.type = type;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("code")
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("type")
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("message")
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
|
||||
@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(code, _apiResponse.code) &&
|
||||
Objects.equals(type, _apiResponse.type) &&
|
||||
Objects.equals(message, _apiResponse.message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(code, type, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class ModelApiResponse {\n");
|
||||
|
||||
sb.append(" code: ").append(toIndentedString(code)).append("\n");
|
||||
sb.append(" type: ").append(toIndentedString(type)).append("\n");
|
||||
sb.append(" message: ").append(toIndentedString(message)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
@ -1,157 +0,0 @@
|
||||
package org.openapitools.server.api.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import java.time.OffsetDateTime;
|
||||
|
||||
/**
|
||||
* An order for a pets from the pet store
|
||||
**/
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class Order {
|
||||
|
||||
private Long id;
|
||||
private Long petId;
|
||||
private Integer quantity;
|
||||
private OffsetDateTime shipDate;
|
||||
|
||||
|
||||
public enum StatusEnum {
|
||||
PLACED("placed"),
|
||||
APPROVED("approved"),
|
||||
DELIVERED("delivered");
|
||||
|
||||
private String value;
|
||||
|
||||
StatusEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
public String toString() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
private StatusEnum status;
|
||||
private Boolean complete = false;
|
||||
|
||||
public Order () {
|
||||
|
||||
}
|
||||
|
||||
public Order (Long id, Long petId, Integer quantity, OffsetDateTime shipDate, StatusEnum status, Boolean complete) {
|
||||
this.id = id;
|
||||
this.petId = petId;
|
||||
this.quantity = quantity;
|
||||
this.shipDate = shipDate;
|
||||
this.status = status;
|
||||
this.complete = complete;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("id")
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("petId")
|
||||
public Long getPetId() {
|
||||
return petId;
|
||||
}
|
||||
public void setPetId(Long petId) {
|
||||
this.petId = petId;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("quantity")
|
||||
public Integer getQuantity() {
|
||||
return quantity;
|
||||
}
|
||||
public void setQuantity(Integer quantity) {
|
||||
this.quantity = quantity;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("shipDate")
|
||||
public OffsetDateTime getShipDate() {
|
||||
return shipDate;
|
||||
}
|
||||
public void setShipDate(OffsetDateTime shipDate) {
|
||||
this.shipDate = shipDate;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("status")
|
||||
public StatusEnum getStatus() {
|
||||
return status;
|
||||
}
|
||||
public void setStatus(StatusEnum status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("complete")
|
||||
public Boolean getComplete() {
|
||||
return complete;
|
||||
}
|
||||
public void setComplete(Boolean complete) {
|
||||
this.complete = complete;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Order order = (Order) o;
|
||||
return Objects.equals(id, order.id) &&
|
||||
Objects.equals(petId, order.petId) &&
|
||||
Objects.equals(quantity, order.quantity) &&
|
||||
Objects.equals(shipDate, order.shipDate) &&
|
||||
Objects.equals(status, order.status) &&
|
||||
Objects.equals(complete, order.complete);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, petId, quantity, shipDate, status, complete);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class Order {\n");
|
||||
|
||||
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
||||
sb.append(" petId: ").append(toIndentedString(petId)).append("\n");
|
||||
sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n");
|
||||
sb.append(" shipDate: ").append(toIndentedString(shipDate)).append("\n");
|
||||
sb.append(" status: ").append(toIndentedString(status)).append("\n");
|
||||
sb.append(" complete: ").append(toIndentedString(complete)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
@ -1,160 +0,0 @@
|
||||
package org.openapitools.server.api.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.openapitools.server.api.model.Category;
|
||||
import org.openapitools.server.api.model.Tag;
|
||||
|
||||
/**
|
||||
* A pet for sale in the pet store
|
||||
**/
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class Pet {
|
||||
|
||||
private Long id;
|
||||
private Category category;
|
||||
private String name;
|
||||
private List<String> photoUrls = new ArrayList<>();
|
||||
private List<Tag> tags = new ArrayList<>();
|
||||
|
||||
|
||||
public enum StatusEnum {
|
||||
AVAILABLE("available"),
|
||||
PENDING("pending"),
|
||||
SOLD("sold");
|
||||
|
||||
private String value;
|
||||
|
||||
StatusEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
public String toString() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
private StatusEnum status;
|
||||
|
||||
public Pet () {
|
||||
|
||||
}
|
||||
|
||||
public Pet (Long id, Category category, String name, List<String> photoUrls, List<Tag> tags, StatusEnum status) {
|
||||
this.id = id;
|
||||
this.category = category;
|
||||
this.name = name;
|
||||
this.photoUrls = photoUrls;
|
||||
this.tags = tags;
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("id")
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("category")
|
||||
public Category getCategory() {
|
||||
return category;
|
||||
}
|
||||
public void setCategory(Category category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("name")
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("photoUrls")
|
||||
public List<String> getPhotoUrls() {
|
||||
return photoUrls;
|
||||
}
|
||||
public void setPhotoUrls(List<String> photoUrls) {
|
||||
this.photoUrls = photoUrls;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("tags")
|
||||
public List<Tag> getTags() {
|
||||
return tags;
|
||||
}
|
||||
public void setTags(List<Tag> tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("status")
|
||||
public StatusEnum getStatus() {
|
||||
return status;
|
||||
}
|
||||
public void setStatus(StatusEnum status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Pet pet = (Pet) o;
|
||||
return Objects.equals(id, pet.id) &&
|
||||
Objects.equals(category, pet.category) &&
|
||||
Objects.equals(name, pet.name) &&
|
||||
Objects.equals(photoUrls, pet.photoUrls) &&
|
||||
Objects.equals(tags, pet.tags) &&
|
||||
Objects.equals(status, pet.status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, category, name, photoUrls, tags, status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class Pet {\n");
|
||||
|
||||
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
||||
sb.append(" category: ").append(toIndentedString(category)).append("\n");
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n");
|
||||
sb.append(" tags: ").append(toIndentedString(tags)).append("\n");
|
||||
sb.append(" status: ").append(toIndentedString(status)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
package org.openapitools.server.api.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* A tag for a pet
|
||||
**/
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class Tag {
|
||||
|
||||
private Long id;
|
||||
private String name;
|
||||
|
||||
public Tag () {
|
||||
|
||||
}
|
||||
|
||||
public Tag (Long id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("id")
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("name")
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Tag tag = (Tag) o;
|
||||
return Objects.equals(id, tag.id) &&
|
||||
Objects.equals(name, tag.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class Tag {\n");
|
||||
|
||||
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
@ -1,161 +0,0 @@
|
||||
package org.openapitools.server.api.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* A User who is purchasing from the pet store
|
||||
**/
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class User {
|
||||
|
||||
private Long id;
|
||||
private String username;
|
||||
private String firstName;
|
||||
private String lastName;
|
||||
private String email;
|
||||
private String password;
|
||||
private String phone;
|
||||
private Integer userStatus;
|
||||
|
||||
public User () {
|
||||
|
||||
}
|
||||
|
||||
public User (Long id, String username, String firstName, String lastName, String email, String password, String phone, Integer userStatus) {
|
||||
this.id = id;
|
||||
this.username = username;
|
||||
this.firstName = firstName;
|
||||
this.lastName = lastName;
|
||||
this.email = email;
|
||||
this.password = password;
|
||||
this.phone = phone;
|
||||
this.userStatus = userStatus;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("id")
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("username")
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("firstName")
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("lastName")
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("email")
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("password")
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("phone")
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("userStatus")
|
||||
public Integer getUserStatus() {
|
||||
return userStatus;
|
||||
}
|
||||
public void setUserStatus(Integer userStatus) {
|
||||
this.userStatus = userStatus;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
User user = (User) o;
|
||||
return Objects.equals(id, user.id) &&
|
||||
Objects.equals(username, user.username) &&
|
||||
Objects.equals(firstName, user.firstName) &&
|
||||
Objects.equals(lastName, user.lastName) &&
|
||||
Objects.equals(email, user.email) &&
|
||||
Objects.equals(password, user.password) &&
|
||||
Objects.equals(phone, user.phone) &&
|
||||
Objects.equals(userStatus, user.userStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, username, firstName, lastName, email, password, phone, userStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class User {\n");
|
||||
|
||||
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
||||
sb.append(" username: ").append(toIndentedString(username)).append("\n");
|
||||
sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n");
|
||||
sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n");
|
||||
sb.append(" email: ").append(toIndentedString(email)).append("\n");
|
||||
sb.append(" password: ").append(toIndentedString(password)).append("\n");
|
||||
sb.append(" phone: ").append(toIndentedString(phone)).append("\n");
|
||||
sb.append(" userStatus: ").append(toIndentedString(userStatus)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
package org.openapitools.server.api.verticle;
|
||||
|
||||
import java.io.File;
|
||||
import org.openapitools.server.api.MainApiException;
|
||||
import org.openapitools.server.api.model.ModelApiResponse;
|
||||
import org.openapitools.server.api.model.Pet;
|
||||
|
||||
import rx.Completable;
|
||||
import rx.Single;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface PetApi {
|
||||
//addPet
|
||||
public Completable addPet(Pet body);
|
||||
|
||||
//deletePet
|
||||
public Completable deletePet(Long petId,String apiKey);
|
||||
|
||||
//findPetsByStatus
|
||||
public Single<List<Pet>> findPetsByStatus(List<String> status);
|
||||
|
||||
//findPetsByTags
|
||||
public Single<List<Pet>> findPetsByTags(List<String> tags);
|
||||
|
||||
//getPetById
|
||||
public Single<Pet> getPetById(Long petId);
|
||||
|
||||
//updatePet
|
||||
public Completable updatePet(Pet body);
|
||||
|
||||
//updatePetWithForm
|
||||
public Completable updatePetWithForm(Long petId,String name,String status);
|
||||
|
||||
//uploadFile
|
||||
public Single<ModelApiResponse> uploadFile(Long petId,String additionalMetadata,File file);
|
||||
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package org.openapitools.server.api.verticle;
|
||||
|
||||
import java.io.File;
|
||||
import org.openapitools.server.api.MainApiException;
|
||||
import org.openapitools.server.api.model.ModelApiResponse;
|
||||
import org.openapitools.server.api.model.Pet;
|
||||
|
||||
public final class PetApiException extends MainApiException {
|
||||
public PetApiException(int statusCode, String statusMessage) {
|
||||
super(statusCode, statusMessage);
|
||||
}
|
||||
|
||||
public static final PetApiException Pet_addPet_405_Exception = new PetApiException(405, "Invalid input");
|
||||
public static final PetApiException Pet_deletePet_400_Exception = new PetApiException(400, "Invalid pet value");
|
||||
public static final PetApiException Pet_findPetsByStatus_200_Exception = new PetApiException(200, "successful operation");
|
||||
public static final PetApiException Pet_findPetsByStatus_400_Exception = new PetApiException(400, "Invalid status value");
|
||||
public static final PetApiException Pet_findPetsByTags_200_Exception = new PetApiException(200, "successful operation");
|
||||
public static final PetApiException Pet_findPetsByTags_400_Exception = new PetApiException(400, "Invalid tag value");
|
||||
public static final PetApiException Pet_getPetById_200_Exception = new PetApiException(200, "successful operation");
|
||||
public static final PetApiException Pet_getPetById_400_Exception = new PetApiException(400, "Invalid ID supplied");
|
||||
public static final PetApiException Pet_getPetById_404_Exception = new PetApiException(404, "Pet not found");
|
||||
public static final PetApiException Pet_updatePet_400_Exception = new PetApiException(400, "Invalid ID supplied");
|
||||
public static final PetApiException Pet_updatePet_404_Exception = new PetApiException(404, "Pet not found");
|
||||
public static final PetApiException Pet_updatePet_405_Exception = new PetApiException(405, "Validation exception");
|
||||
public static final PetApiException Pet_updatePetWithForm_405_Exception = new PetApiException(405, "Invalid input");
|
||||
public static final PetApiException Pet_uploadFile_200_Exception = new PetApiException(200, "successful operation");
|
||||
|
||||
|
||||
}
|
@ -1,268 +0,0 @@
|
||||
package org.openapitools.server.api.verticle;
|
||||
|
||||
import io.vertx.core.AbstractVerticle;
|
||||
import io.vertx.core.eventbus.Message;
|
||||
import io.vertx.core.json.Json;
|
||||
import io.vertx.core.json.JsonArray;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import io.vertx.core.logging.Logger;
|
||||
import io.vertx.core.logging.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import org.openapitools.server.api.MainApiException;
|
||||
import org.openapitools.server.api.model.ModelApiResponse;
|
||||
import org.openapitools.server.api.model.Pet;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class PetApiVerticle extends AbstractVerticle {
|
||||
static final Logger LOGGER = LoggerFactory.getLogger(PetApiVerticle.class);
|
||||
|
||||
static final String ADDPET_SERVICE_ID = "addPet";
|
||||
static final String DELETEPET_SERVICE_ID = "deletePet";
|
||||
static final String FINDPETSBYSTATUS_SERVICE_ID = "findPetsByStatus";
|
||||
static final String FINDPETSBYTAGS_SERVICE_ID = "findPetsByTags";
|
||||
static final String GETPETBYID_SERVICE_ID = "getPetById";
|
||||
static final String UPDATEPET_SERVICE_ID = "updatePet";
|
||||
static final String UPDATEPETWITHFORM_SERVICE_ID = "updatePetWithForm";
|
||||
static final String UPLOADFILE_SERVICE_ID = "uploadFile";
|
||||
|
||||
final PetApi service;
|
||||
|
||||
public PetApiVerticle() {
|
||||
try {
|
||||
Class serviceImplClass = getClass().getClassLoader().loadClass("org.openapitools.server.api.verticle.PetApiImpl");
|
||||
service = (PetApi)serviceImplClass.newInstance();
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("PetApiVerticle constructor", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() throws Exception {
|
||||
|
||||
//Consumer for addPet
|
||||
vertx.eventBus().<JsonObject> consumer(ADDPET_SERVICE_ID).handler(message -> {
|
||||
try {
|
||||
// Workaround for #allParams section clearing the vendorExtensions map
|
||||
String serviceId = "addPet";
|
||||
JsonObject bodyParam = message.body().getJsonObject("body");
|
||||
if (bodyParam == null) {
|
||||
manageError(message, new MainApiException(400, "body is required"), serviceId);
|
||||
return;
|
||||
}
|
||||
Pet body = Json.mapper.readValue(bodyParam.encode(), Pet.class);
|
||||
service.addPet(body).subscribe(
|
||||
() -> {
|
||||
message.reply(null);
|
||||
},
|
||||
error -> {
|
||||
manageError(message, error, "addPet");
|
||||
});
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("addPet", e);
|
||||
message.fail(MainApiException.INTERNAL_SERVER_ERROR.getStatusCode(), MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage());
|
||||
}
|
||||
});
|
||||
|
||||
//Consumer for deletePet
|
||||
vertx.eventBus().<JsonObject> consumer(DELETEPET_SERVICE_ID).handler(message -> {
|
||||
try {
|
||||
// Workaround for #allParams section clearing the vendorExtensions map
|
||||
String serviceId = "deletePet";
|
||||
String petIdParam = message.body().getString("petId");
|
||||
if(petIdParam == null) {
|
||||
manageError(message, new MainApiException(400, "petId is required"), serviceId);
|
||||
return;
|
||||
}
|
||||
Long petId = Json.mapper.readValue(petIdParam, Long.class);
|
||||
String apiKeyParam = message.body().getString("api_key");
|
||||
String apiKey = (apiKeyParam == null) ? null : apiKeyParam;
|
||||
service.deletePet(petId, apiKey).subscribe(
|
||||
() -> {
|
||||
message.reply(null);
|
||||
},
|
||||
error -> {
|
||||
manageError(message, error, "deletePet");
|
||||
});
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("deletePet", e);
|
||||
message.fail(MainApiException.INTERNAL_SERVER_ERROR.getStatusCode(), MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage());
|
||||
}
|
||||
});
|
||||
|
||||
//Consumer for findPetsByStatus
|
||||
vertx.eventBus().<JsonObject> consumer(FINDPETSBYSTATUS_SERVICE_ID).handler(message -> {
|
||||
try {
|
||||
// Workaround for #allParams section clearing the vendorExtensions map
|
||||
String serviceId = "findPetsByStatus";
|
||||
JsonArray statusParam = message.body().getJsonArray("status");
|
||||
if(statusParam == null) {
|
||||
manageError(message, new MainApiException(400, "status is required"), serviceId);
|
||||
return;
|
||||
}
|
||||
List<String> status = Json.mapper.readValue(statusParam.encode(),
|
||||
Json.mapper.getTypeFactory().constructCollectionType(List.class, String.class));
|
||||
service.findPetsByStatus(status).subscribe(
|
||||
result -> {
|
||||
message.reply(new JsonArray(Json.encode(result)).encodePrettily());
|
||||
},
|
||||
error -> {
|
||||
manageError(message, error, "findPetsByStatus");
|
||||
});
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("findPetsByStatus", e);
|
||||
message.fail(MainApiException.INTERNAL_SERVER_ERROR.getStatusCode(), MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage());
|
||||
}
|
||||
});
|
||||
|
||||
//Consumer for findPetsByTags
|
||||
vertx.eventBus().<JsonObject> consumer(FINDPETSBYTAGS_SERVICE_ID).handler(message -> {
|
||||
try {
|
||||
// Workaround for #allParams section clearing the vendorExtensions map
|
||||
String serviceId = "findPetsByTags";
|
||||
JsonArray tagsParam = message.body().getJsonArray("tags");
|
||||
if(tagsParam == null) {
|
||||
manageError(message, new MainApiException(400, "tags is required"), serviceId);
|
||||
return;
|
||||
}
|
||||
List<String> tags = Json.mapper.readValue(tagsParam.encode(),
|
||||
Json.mapper.getTypeFactory().constructCollectionType(List.class, String.class));
|
||||
service.findPetsByTags(tags).subscribe(
|
||||
result -> {
|
||||
message.reply(new JsonArray(Json.encode(result)).encodePrettily());
|
||||
},
|
||||
error -> {
|
||||
manageError(message, error, "findPetsByTags");
|
||||
});
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("findPetsByTags", e);
|
||||
message.fail(MainApiException.INTERNAL_SERVER_ERROR.getStatusCode(), MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage());
|
||||
}
|
||||
});
|
||||
|
||||
//Consumer for getPetById
|
||||
vertx.eventBus().<JsonObject> consumer(GETPETBYID_SERVICE_ID).handler(message -> {
|
||||
try {
|
||||
// Workaround for #allParams section clearing the vendorExtensions map
|
||||
String serviceId = "getPetById";
|
||||
String petIdParam = message.body().getString("petId");
|
||||
if(petIdParam == null) {
|
||||
manageError(message, new MainApiException(400, "petId is required"), serviceId);
|
||||
return;
|
||||
}
|
||||
Long petId = Json.mapper.readValue(petIdParam, Long.class);
|
||||
service.getPetById(petId).subscribe(
|
||||
result -> {
|
||||
message.reply(new JsonObject(Json.encode(result)).encodePrettily());
|
||||
},
|
||||
error -> {
|
||||
manageError(message, error, "getPetById");
|
||||
});
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("getPetById", e);
|
||||
message.fail(MainApiException.INTERNAL_SERVER_ERROR.getStatusCode(), MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage());
|
||||
}
|
||||
});
|
||||
|
||||
//Consumer for updatePet
|
||||
vertx.eventBus().<JsonObject> consumer(UPDATEPET_SERVICE_ID).handler(message -> {
|
||||
try {
|
||||
// Workaround for #allParams section clearing the vendorExtensions map
|
||||
String serviceId = "updatePet";
|
||||
JsonObject bodyParam = message.body().getJsonObject("body");
|
||||
if (bodyParam == null) {
|
||||
manageError(message, new MainApiException(400, "body is required"), serviceId);
|
||||
return;
|
||||
}
|
||||
Pet body = Json.mapper.readValue(bodyParam.encode(), Pet.class);
|
||||
service.updatePet(body).subscribe(
|
||||
() -> {
|
||||
message.reply(null);
|
||||
},
|
||||
error -> {
|
||||
manageError(message, error, "updatePet");
|
||||
});
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("updatePet", e);
|
||||
message.fail(MainApiException.INTERNAL_SERVER_ERROR.getStatusCode(), MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage());
|
||||
}
|
||||
});
|
||||
|
||||
//Consumer for updatePetWithForm
|
||||
vertx.eventBus().<JsonObject> consumer(UPDATEPETWITHFORM_SERVICE_ID).handler(message -> {
|
||||
try {
|
||||
// Workaround for #allParams section clearing the vendorExtensions map
|
||||
String serviceId = "updatePetWithForm";
|
||||
String petIdParam = message.body().getString("petId");
|
||||
if(petIdParam == null) {
|
||||
manageError(message, new MainApiException(400, "petId is required"), serviceId);
|
||||
return;
|
||||
}
|
||||
Long petId = Json.mapper.readValue(petIdParam, Long.class);
|
||||
String nameParam = message.body().getString("name");
|
||||
String name = (nameParam == null) ? null : nameParam;
|
||||
String statusParam = message.body().getString("status");
|
||||
String status = (statusParam == null) ? null : statusParam;
|
||||
service.updatePetWithForm(petId, name, status).subscribe(
|
||||
() -> {
|
||||
message.reply(null);
|
||||
},
|
||||
error -> {
|
||||
manageError(message, error, "updatePetWithForm");
|
||||
});
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("updatePetWithForm", e);
|
||||
message.fail(MainApiException.INTERNAL_SERVER_ERROR.getStatusCode(), MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage());
|
||||
}
|
||||
});
|
||||
|
||||
//Consumer for uploadFile
|
||||
vertx.eventBus().<JsonObject> consumer(UPLOADFILE_SERVICE_ID).handler(message -> {
|
||||
try {
|
||||
// Workaround for #allParams section clearing the vendorExtensions map
|
||||
String serviceId = "uploadFile";
|
||||
String petIdParam = message.body().getString("petId");
|
||||
if(petIdParam == null) {
|
||||
manageError(message, new MainApiException(400, "petId is required"), serviceId);
|
||||
return;
|
||||
}
|
||||
Long petId = Json.mapper.readValue(petIdParam, Long.class);
|
||||
String additionalMetadataParam = message.body().getString("additionalMetadata");
|
||||
String additionalMetadata = (additionalMetadataParam == null) ? null : additionalMetadataParam;
|
||||
String fileParam = message.body().getString("file");
|
||||
File file = (fileParam == null) ? null : Json.mapper.readValue(fileParam, File.class);
|
||||
service.uploadFile(petId, additionalMetadata, file).subscribe(
|
||||
result -> {
|
||||
message.reply(new JsonObject(Json.encode(result)).encodePrettily());
|
||||
},
|
||||
error -> {
|
||||
manageError(message, error, "uploadFile");
|
||||
});
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("uploadFile", e);
|
||||
message.fail(MainApiException.INTERNAL_SERVER_ERROR.getStatusCode(), MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void manageError(Message<JsonObject> message, Throwable cause, String serviceName) {
|
||||
int code = MainApiException.INTERNAL_SERVER_ERROR.getStatusCode();
|
||||
String statusMessage = MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage();
|
||||
if (cause instanceof MainApiException) {
|
||||
code = ((MainApiException)cause).getStatusCode();
|
||||
statusMessage = ((MainApiException)cause).getStatusMessage();
|
||||
} else {
|
||||
logUnexpectedError(serviceName, cause);
|
||||
}
|
||||
|
||||
message.fail(code, statusMessage);
|
||||
}
|
||||
|
||||
private void logUnexpectedError(String serviceName, Throwable cause) {
|
||||
LOGGER.error("Unexpected error in "+ serviceName, cause);
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
package org.openapitools.server.api.verticle;
|
||||
|
||||
import org.openapitools.server.api.MainApiException;
|
||||
import org.openapitools.server.api.model.Order;
|
||||
|
||||
import rx.Completable;
|
||||
import rx.Single;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface StoreApi {
|
||||
//deleteOrder
|
||||
public Completable deleteOrder(String orderId);
|
||||
|
||||
//getInventory
|
||||
public Single<Map<String, Integer>> getInventory();
|
||||
|
||||
//getOrderById
|
||||
public Single<Order> getOrderById(Long orderId);
|
||||
|
||||
//placeOrder
|
||||
public Single<Order> placeOrder(Order body);
|
||||
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package org.openapitools.server.api.verticle;
|
||||
|
||||
import org.openapitools.server.api.MainApiException;
|
||||
import org.openapitools.server.api.model.Order;
|
||||
|
||||
public final class StoreApiException extends MainApiException {
|
||||
public StoreApiException(int statusCode, String statusMessage) {
|
||||
super(statusCode, statusMessage);
|
||||
}
|
||||
|
||||
public static final StoreApiException Store_deleteOrder_400_Exception = new StoreApiException(400, "Invalid ID supplied");
|
||||
public static final StoreApiException Store_deleteOrder_404_Exception = new StoreApiException(404, "Order not found");
|
||||
public static final StoreApiException Store_getInventory_200_Exception = new StoreApiException(200, "successful operation");
|
||||
public static final StoreApiException Store_getOrderById_200_Exception = new StoreApiException(200, "successful operation");
|
||||
public static final StoreApiException Store_getOrderById_400_Exception = new StoreApiException(400, "Invalid ID supplied");
|
||||
public static final StoreApiException Store_getOrderById_404_Exception = new StoreApiException(404, "Order not found");
|
||||
public static final StoreApiException Store_placeOrder_200_Exception = new StoreApiException(200, "successful operation");
|
||||
public static final StoreApiException Store_placeOrder_400_Exception = new StoreApiException(400, "Invalid Order");
|
||||
|
||||
|
||||
}
|
@ -1,148 +0,0 @@
|
||||
package org.openapitools.server.api.verticle;
|
||||
|
||||
import io.vertx.core.AbstractVerticle;
|
||||
import io.vertx.core.eventbus.Message;
|
||||
import io.vertx.core.json.Json;
|
||||
import io.vertx.core.json.JsonArray;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import io.vertx.core.logging.Logger;
|
||||
import io.vertx.core.logging.LoggerFactory;
|
||||
|
||||
import org.openapitools.server.api.MainApiException;
|
||||
import org.openapitools.server.api.model.Order;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class StoreApiVerticle extends AbstractVerticle {
|
||||
static final Logger LOGGER = LoggerFactory.getLogger(StoreApiVerticle.class);
|
||||
|
||||
static final String DELETEORDER_SERVICE_ID = "deleteOrder";
|
||||
static final String GETINVENTORY_SERVICE_ID = "getInventory";
|
||||
static final String GETORDERBYID_SERVICE_ID = "getOrderById";
|
||||
static final String PLACEORDER_SERVICE_ID = "placeOrder";
|
||||
|
||||
final StoreApi service;
|
||||
|
||||
public StoreApiVerticle() {
|
||||
try {
|
||||
Class serviceImplClass = getClass().getClassLoader().loadClass("org.openapitools.server.api.verticle.StoreApiImpl");
|
||||
service = (StoreApi)serviceImplClass.newInstance();
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("StoreApiVerticle constructor", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() throws Exception {
|
||||
|
||||
//Consumer for deleteOrder
|
||||
vertx.eventBus().<JsonObject> consumer(DELETEORDER_SERVICE_ID).handler(message -> {
|
||||
try {
|
||||
// Workaround for #allParams section clearing the vendorExtensions map
|
||||
String serviceId = "deleteOrder";
|
||||
String orderIdParam = message.body().getString("orderId");
|
||||
if(orderIdParam == null) {
|
||||
manageError(message, new MainApiException(400, "orderId is required"), serviceId);
|
||||
return;
|
||||
}
|
||||
String orderId = orderIdParam;
|
||||
service.deleteOrder(orderId).subscribe(
|
||||
() -> {
|
||||
message.reply(null);
|
||||
},
|
||||
error -> {
|
||||
manageError(message, error, "deleteOrder");
|
||||
});
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("deleteOrder", e);
|
||||
message.fail(MainApiException.INTERNAL_SERVER_ERROR.getStatusCode(), MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage());
|
||||
}
|
||||
});
|
||||
|
||||
//Consumer for getInventory
|
||||
vertx.eventBus().<JsonObject> consumer(GETINVENTORY_SERVICE_ID).handler(message -> {
|
||||
try {
|
||||
// Workaround for #allParams section clearing the vendorExtensions map
|
||||
String serviceId = "getInventory";
|
||||
service.getInventory().subscribe(
|
||||
result -> {
|
||||
message.reply(new JsonObject(Json.encode(result)).encodePrettily());
|
||||
},
|
||||
error -> {
|
||||
manageError(message, error, "getInventory");
|
||||
});
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("getInventory", e);
|
||||
message.fail(MainApiException.INTERNAL_SERVER_ERROR.getStatusCode(), MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage());
|
||||
}
|
||||
});
|
||||
|
||||
//Consumer for getOrderById
|
||||
vertx.eventBus().<JsonObject> consumer(GETORDERBYID_SERVICE_ID).handler(message -> {
|
||||
try {
|
||||
// Workaround for #allParams section clearing the vendorExtensions map
|
||||
String serviceId = "getOrderById";
|
||||
String orderIdParam = message.body().getString("orderId");
|
||||
if(orderIdParam == null) {
|
||||
manageError(message, new MainApiException(400, "orderId is required"), serviceId);
|
||||
return;
|
||||
}
|
||||
Long orderId = Json.mapper.readValue(orderIdParam, Long.class);
|
||||
service.getOrderById(orderId).subscribe(
|
||||
result -> {
|
||||
message.reply(new JsonObject(Json.encode(result)).encodePrettily());
|
||||
},
|
||||
error -> {
|
||||
manageError(message, error, "getOrderById");
|
||||
});
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("getOrderById", e);
|
||||
message.fail(MainApiException.INTERNAL_SERVER_ERROR.getStatusCode(), MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage());
|
||||
}
|
||||
});
|
||||
|
||||
//Consumer for placeOrder
|
||||
vertx.eventBus().<JsonObject> consumer(PLACEORDER_SERVICE_ID).handler(message -> {
|
||||
try {
|
||||
// Workaround for #allParams section clearing the vendorExtensions map
|
||||
String serviceId = "placeOrder";
|
||||
JsonObject bodyParam = message.body().getJsonObject("body");
|
||||
if (bodyParam == null) {
|
||||
manageError(message, new MainApiException(400, "body is required"), serviceId);
|
||||
return;
|
||||
}
|
||||
Order body = Json.mapper.readValue(bodyParam.encode(), Order.class);
|
||||
service.placeOrder(body).subscribe(
|
||||
result -> {
|
||||
message.reply(new JsonObject(Json.encode(result)).encodePrettily());
|
||||
},
|
||||
error -> {
|
||||
manageError(message, error, "placeOrder");
|
||||
});
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("placeOrder", e);
|
||||
message.fail(MainApiException.INTERNAL_SERVER_ERROR.getStatusCode(), MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void manageError(Message<JsonObject> message, Throwable cause, String serviceName) {
|
||||
int code = MainApiException.INTERNAL_SERVER_ERROR.getStatusCode();
|
||||
String statusMessage = MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage();
|
||||
if (cause instanceof MainApiException) {
|
||||
code = ((MainApiException)cause).getStatusCode();
|
||||
statusMessage = ((MainApiException)cause).getStatusMessage();
|
||||
} else {
|
||||
logUnexpectedError(serviceName, cause);
|
||||
}
|
||||
|
||||
message.fail(code, statusMessage);
|
||||
}
|
||||
|
||||
private void logUnexpectedError(String serviceName, Throwable cause) {
|
||||
LOGGER.error("Unexpected error in "+ serviceName, cause);
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
package org.openapitools.server.api.verticle;
|
||||
|
||||
import org.openapitools.server.api.MainApiException;
|
||||
import org.openapitools.server.api.model.User;
|
||||
|
||||
import rx.Completable;
|
||||
import rx.Single;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface UserApi {
|
||||
//createUser
|
||||
public Completable createUser(User body);
|
||||
|
||||
//createUsersWithArrayInput
|
||||
public Completable createUsersWithArrayInput(List<User> body);
|
||||
|
||||
//createUsersWithListInput
|
||||
public Completable createUsersWithListInput(List<User> body);
|
||||
|
||||
//deleteUser
|
||||
public Completable deleteUser(String username);
|
||||
|
||||
//getUserByName
|
||||
public Single<User> getUserByName(String username);
|
||||
|
||||
//loginUser
|
||||
public Single<String> loginUser(String username,String password);
|
||||
|
||||
//logoutUser
|
||||
public Completable logoutUser();
|
||||
|
||||
//updateUser
|
||||
public Completable updateUser(String username,User body);
|
||||
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package org.openapitools.server.api.verticle;
|
||||
|
||||
import org.openapitools.server.api.MainApiException;
|
||||
import org.openapitools.server.api.model.User;
|
||||
|
||||
public final class UserApiException extends MainApiException {
|
||||
public UserApiException(int statusCode, String statusMessage) {
|
||||
super(statusCode, statusMessage);
|
||||
}
|
||||
|
||||
public static final UserApiException User_deleteUser_400_Exception = new UserApiException(400, "Invalid username supplied");
|
||||
public static final UserApiException User_deleteUser_404_Exception = new UserApiException(404, "User not found");
|
||||
public static final UserApiException User_getUserByName_200_Exception = new UserApiException(200, "successful operation");
|
||||
public static final UserApiException User_getUserByName_400_Exception = new UserApiException(400, "Invalid username supplied");
|
||||
public static final UserApiException User_getUserByName_404_Exception = new UserApiException(404, "User not found");
|
||||
public static final UserApiException User_loginUser_200_Exception = new UserApiException(200, "successful operation");
|
||||
public static final UserApiException User_loginUser_400_Exception = new UserApiException(400, "Invalid username/password supplied");
|
||||
public static final UserApiException User_updateUser_400_Exception = new UserApiException(400, "Invalid user supplied");
|
||||
public static final UserApiException User_updateUser_404_Exception = new UserApiException(404, "User not found");
|
||||
|
||||
|
||||
}
|
@ -1,262 +0,0 @@
|
||||
package org.openapitools.server.api.verticle;
|
||||
|
||||
import io.vertx.core.AbstractVerticle;
|
||||
import io.vertx.core.eventbus.Message;
|
||||
import io.vertx.core.json.Json;
|
||||
import io.vertx.core.json.JsonArray;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import io.vertx.core.logging.Logger;
|
||||
import io.vertx.core.logging.LoggerFactory;
|
||||
|
||||
import org.openapitools.server.api.MainApiException;
|
||||
import org.openapitools.server.api.model.User;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class UserApiVerticle extends AbstractVerticle {
|
||||
static final Logger LOGGER = LoggerFactory.getLogger(UserApiVerticle.class);
|
||||
|
||||
static final String CREATEUSER_SERVICE_ID = "createUser";
|
||||
static final String CREATEUSERSWITHARRAYINPUT_SERVICE_ID = "createUsersWithArrayInput";
|
||||
static final String CREATEUSERSWITHLISTINPUT_SERVICE_ID = "createUsersWithListInput";
|
||||
static final String DELETEUSER_SERVICE_ID = "deleteUser";
|
||||
static final String GETUSERBYNAME_SERVICE_ID = "getUserByName";
|
||||
static final String LOGINUSER_SERVICE_ID = "loginUser";
|
||||
static final String LOGOUTUSER_SERVICE_ID = "logoutUser";
|
||||
static final String UPDATEUSER_SERVICE_ID = "updateUser";
|
||||
|
||||
final UserApi service;
|
||||
|
||||
public UserApiVerticle() {
|
||||
try {
|
||||
Class serviceImplClass = getClass().getClassLoader().loadClass("org.openapitools.server.api.verticle.UserApiImpl");
|
||||
service = (UserApi)serviceImplClass.newInstance();
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("UserApiVerticle constructor", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() throws Exception {
|
||||
|
||||
//Consumer for createUser
|
||||
vertx.eventBus().<JsonObject> consumer(CREATEUSER_SERVICE_ID).handler(message -> {
|
||||
try {
|
||||
// Workaround for #allParams section clearing the vendorExtensions map
|
||||
String serviceId = "createUser";
|
||||
JsonObject bodyParam = message.body().getJsonObject("body");
|
||||
if (bodyParam == null) {
|
||||
manageError(message, new MainApiException(400, "body is required"), serviceId);
|
||||
return;
|
||||
}
|
||||
User body = Json.mapper.readValue(bodyParam.encode(), User.class);
|
||||
service.createUser(body).subscribe(
|
||||
() -> {
|
||||
message.reply(null);
|
||||
},
|
||||
error -> {
|
||||
manageError(message, error, "createUser");
|
||||
});
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("createUser", e);
|
||||
message.fail(MainApiException.INTERNAL_SERVER_ERROR.getStatusCode(), MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage());
|
||||
}
|
||||
});
|
||||
|
||||
//Consumer for createUsersWithArrayInput
|
||||
vertx.eventBus().<JsonObject> consumer(CREATEUSERSWITHARRAYINPUT_SERVICE_ID).handler(message -> {
|
||||
try {
|
||||
// Workaround for #allParams section clearing the vendorExtensions map
|
||||
String serviceId = "createUsersWithArrayInput";
|
||||
JsonArray bodyParam = message.body().getJsonArray("body");
|
||||
if(bodyParam == null) {
|
||||
manageError(message, new MainApiException(400, "body is required"), serviceId);
|
||||
return;
|
||||
}
|
||||
List<User> body = Json.mapper.readValue(bodyParam.encode(),
|
||||
Json.mapper.getTypeFactory().constructCollectionType(List.class, User.class));
|
||||
service.createUsersWithArrayInput(body).subscribe(
|
||||
() -> {
|
||||
message.reply(null);
|
||||
},
|
||||
error -> {
|
||||
manageError(message, error, "createUsersWithArrayInput");
|
||||
});
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("createUsersWithArrayInput", e);
|
||||
message.fail(MainApiException.INTERNAL_SERVER_ERROR.getStatusCode(), MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage());
|
||||
}
|
||||
});
|
||||
|
||||
//Consumer for createUsersWithListInput
|
||||
vertx.eventBus().<JsonObject> consumer(CREATEUSERSWITHLISTINPUT_SERVICE_ID).handler(message -> {
|
||||
try {
|
||||
// Workaround for #allParams section clearing the vendorExtensions map
|
||||
String serviceId = "createUsersWithListInput";
|
||||
JsonArray bodyParam = message.body().getJsonArray("body");
|
||||
if(bodyParam == null) {
|
||||
manageError(message, new MainApiException(400, "body is required"), serviceId);
|
||||
return;
|
||||
}
|
||||
List<User> body = Json.mapper.readValue(bodyParam.encode(),
|
||||
Json.mapper.getTypeFactory().constructCollectionType(List.class, User.class));
|
||||
service.createUsersWithListInput(body).subscribe(
|
||||
() -> {
|
||||
message.reply(null);
|
||||
},
|
||||
error -> {
|
||||
manageError(message, error, "createUsersWithListInput");
|
||||
});
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("createUsersWithListInput", e);
|
||||
message.fail(MainApiException.INTERNAL_SERVER_ERROR.getStatusCode(), MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage());
|
||||
}
|
||||
});
|
||||
|
||||
//Consumer for deleteUser
|
||||
vertx.eventBus().<JsonObject> consumer(DELETEUSER_SERVICE_ID).handler(message -> {
|
||||
try {
|
||||
// Workaround for #allParams section clearing the vendorExtensions map
|
||||
String serviceId = "deleteUser";
|
||||
String usernameParam = message.body().getString("username");
|
||||
if(usernameParam == null) {
|
||||
manageError(message, new MainApiException(400, "username is required"), serviceId);
|
||||
return;
|
||||
}
|
||||
String username = usernameParam;
|
||||
service.deleteUser(username).subscribe(
|
||||
() -> {
|
||||
message.reply(null);
|
||||
},
|
||||
error -> {
|
||||
manageError(message, error, "deleteUser");
|
||||
});
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("deleteUser", e);
|
||||
message.fail(MainApiException.INTERNAL_SERVER_ERROR.getStatusCode(), MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage());
|
||||
}
|
||||
});
|
||||
|
||||
//Consumer for getUserByName
|
||||
vertx.eventBus().<JsonObject> consumer(GETUSERBYNAME_SERVICE_ID).handler(message -> {
|
||||
try {
|
||||
// Workaround for #allParams section clearing the vendorExtensions map
|
||||
String serviceId = "getUserByName";
|
||||
String usernameParam = message.body().getString("username");
|
||||
if(usernameParam == null) {
|
||||
manageError(message, new MainApiException(400, "username is required"), serviceId);
|
||||
return;
|
||||
}
|
||||
String username = usernameParam;
|
||||
service.getUserByName(username).subscribe(
|
||||
result -> {
|
||||
message.reply(new JsonObject(Json.encode(result)).encodePrettily());
|
||||
},
|
||||
error -> {
|
||||
manageError(message, error, "getUserByName");
|
||||
});
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("getUserByName", e);
|
||||
message.fail(MainApiException.INTERNAL_SERVER_ERROR.getStatusCode(), MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage());
|
||||
}
|
||||
});
|
||||
|
||||
//Consumer for loginUser
|
||||
vertx.eventBus().<JsonObject> consumer(LOGINUSER_SERVICE_ID).handler(message -> {
|
||||
try {
|
||||
// Workaround for #allParams section clearing the vendorExtensions map
|
||||
String serviceId = "loginUser";
|
||||
String usernameParam = message.body().getString("username");
|
||||
if(usernameParam == null) {
|
||||
manageError(message, new MainApiException(400, "username is required"), serviceId);
|
||||
return;
|
||||
}
|
||||
String username = usernameParam;
|
||||
String passwordParam = message.body().getString("password");
|
||||
if(passwordParam == null) {
|
||||
manageError(message, new MainApiException(400, "password is required"), serviceId);
|
||||
return;
|
||||
}
|
||||
String password = passwordParam;
|
||||
service.loginUser(username, password).subscribe(
|
||||
result -> {
|
||||
message.reply(new JsonObject(Json.encode(result)).encodePrettily());
|
||||
},
|
||||
error -> {
|
||||
manageError(message, error, "loginUser");
|
||||
});
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("loginUser", e);
|
||||
message.fail(MainApiException.INTERNAL_SERVER_ERROR.getStatusCode(), MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage());
|
||||
}
|
||||
});
|
||||
|
||||
//Consumer for logoutUser
|
||||
vertx.eventBus().<JsonObject> consumer(LOGOUTUSER_SERVICE_ID).handler(message -> {
|
||||
try {
|
||||
// Workaround for #allParams section clearing the vendorExtensions map
|
||||
String serviceId = "logoutUser";
|
||||
service.logoutUser().subscribe(
|
||||
() -> {
|
||||
message.reply(null);
|
||||
},
|
||||
error -> {
|
||||
manageError(message, error, "logoutUser");
|
||||
});
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("logoutUser", e);
|
||||
message.fail(MainApiException.INTERNAL_SERVER_ERROR.getStatusCode(), MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage());
|
||||
}
|
||||
});
|
||||
|
||||
//Consumer for updateUser
|
||||
vertx.eventBus().<JsonObject> consumer(UPDATEUSER_SERVICE_ID).handler(message -> {
|
||||
try {
|
||||
// Workaround for #allParams section clearing the vendorExtensions map
|
||||
String serviceId = "updateUser";
|
||||
String usernameParam = message.body().getString("username");
|
||||
if(usernameParam == null) {
|
||||
manageError(message, new MainApiException(400, "username is required"), serviceId);
|
||||
return;
|
||||
}
|
||||
String username = usernameParam;
|
||||
JsonObject bodyParam = message.body().getJsonObject("body");
|
||||
if (bodyParam == null) {
|
||||
manageError(message, new MainApiException(400, "body is required"), serviceId);
|
||||
return;
|
||||
}
|
||||
User body = Json.mapper.readValue(bodyParam.encode(), User.class);
|
||||
service.updateUser(username, body).subscribe(
|
||||
() -> {
|
||||
message.reply(null);
|
||||
},
|
||||
error -> {
|
||||
manageError(message, error, "updateUser");
|
||||
});
|
||||
} catch (Exception e) {
|
||||
logUnexpectedError("updateUser", e);
|
||||
message.fail(MainApiException.INTERNAL_SERVER_ERROR.getStatusCode(), MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void manageError(Message<JsonObject> message, Throwable cause, String serviceName) {
|
||||
int code = MainApiException.INTERNAL_SERVER_ERROR.getStatusCode();
|
||||
String statusMessage = MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage();
|
||||
if (cause instanceof MainApiException) {
|
||||
code = ((MainApiException)cause).getStatusCode();
|
||||
statusMessage = ((MainApiException)cause).getStatusMessage();
|
||||
} else {
|
||||
logUnexpectedError(serviceName, cause);
|
||||
}
|
||||
|
||||
message.fail(code, statusMessage);
|
||||
}
|
||||
|
||||
private void logUnexpectedError(String serviceName, Throwable cause) {
|
||||
LOGGER.error("Unexpected error in "+ serviceName, cause);
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,30 +0,0 @@
|
||||
#
|
||||
# Copyright 2014 Red Hat, Inc.
|
||||
#
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# are made available under the terms of the Eclipse Public License v1.0
|
||||
# and Apache License v2.0 which accompanies this distribution.
|
||||
#
|
||||
# The Eclipse Public License is available at
|
||||
# http://www.eclipse.org/legal/epl-v10.html
|
||||
#
|
||||
# The Apache License v2.0 is available at
|
||||
# http://www.opensource.org/licenses/apache2.0.php
|
||||
#
|
||||
# You may elect to redistribute this code under either of these licenses.
|
||||
#
|
||||
handlers=java.util.logging.ConsoleHandler,java.util.logging.FileHandler
|
||||
java.util.logging.SimpleFormatter.format=%5$s %6$s\n
|
||||
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
|
||||
java.util.logging.ConsoleHandler.level=FINEST
|
||||
java.util.logging.FileHandler.level=INFO
|
||||
java.util.logging.FileHandler.formatter=io.vertx.core.logging.VertxLoggerFormatter
|
||||
|
||||
# Put the log in the system temporary directory
|
||||
java.util.logging.FileHandler.pattern=vertx.log
|
||||
|
||||
.level=INFO
|
||||
io.vertx.ext.web.level=FINEST
|
||||
io.vertx.level=INFO
|
||||
com.hazelcast.level=INFO
|
||||
io.netty.util.internal.PlatformDependent.level=SEVERE
|
Loading…
x
Reference in New Issue
Block a user