adding Vert.X Codegen

Adding the possibility to generate java Vert.X servers.
It uses Vertx-Swagger-Router project.
It can generate an Async callback version or a Rx version.
This commit is contained in:
Florent Chamfroy
2017-07-08 16:10:07 +02:00
parent 7ae4146a2b
commit d044498de4
69 changed files with 5891 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
# Swagger Codegen Ignore
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
# 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 Swagger Codgen 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

View File

@@ -0,0 +1 @@
2.2.3-SNAPSHOT

View File

@@ -0,0 +1 @@
Project generated on : 2017-07-08T16:03:02.953+02:00

View File

@@ -0,0 +1,91 @@
<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>io.swagger</groupId>
<artifactId>swagger-java-vertx-server</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Swagger Petstore</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<junit.version>4.12</junit.version>
<vertx.version>3.4.1</vertx.version>
<maven-compiler-plugin.version>3.3</maven-compiler-plugin.version>
<vertx-swagger-router.version>1.2.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>io.swagger.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>

View File

@@ -0,0 +1,22 @@
package io.swagger.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");
}

View File

@@ -0,0 +1,75 @@
package io.swagger.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.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.ext.web.Router;
public class MainApiVerticle extends AbstractVerticle {
final static Logger LOGGER = LoggerFactory.getLogger(MainApiVerticle.class);
final Router router = Router.router(vertx);
@Override
public void start(Future<Void> startFuture) throws Exception {
Json.mapper.registerModule(new JavaTimeModule());
FileSystem vertxFileSystem = vertx.fileSystem();
vertxFileSystem.readFile("swagger.json", readFile -> {
if (readFile.succeeded()) {
Swagger swagger = new SwaggerParser().parse(readFile.result().toString(Charset.forName("utf-8")));
Router swaggerRouter = SwaggerRouter.swaggerRouter(Router.router(vertx), swagger, vertx.eventBus(), new OperationIdServiceIdResolver());
deployVerticles(startFuture);
vertx.createHttpServer()
.requestHandler(swaggerRouter::accept)
.listen(8080);
startFuture.complete();
} else {
startFuture.fail(readFile.cause());
}
});
}
public void deployVerticles(Future<Void> startFuture) {
vertx.deployVerticle("io.swagger.server.api.verticle.PetApiVerticle", res -> {
if (res.succeeded()) {
LOGGER.info("PetApiVerticle : Deployed");
} else {
startFuture.fail(res.cause());
LOGGER.error("PetApiVerticle : Deployement failed");
}
});
vertx.deployVerticle("io.swagger.server.api.verticle.StoreApiVerticle", res -> {
if (res.succeeded()) {
LOGGER.info("StoreApiVerticle : Deployed");
} else {
startFuture.fail(res.cause());
LOGGER.error("StoreApiVerticle : Deployement failed");
}
});
vertx.deployVerticle("io.swagger.server.api.verticle.UserApiVerticle", res -> {
if (res.succeeded()) {
LOGGER.info("UserApiVerticle : Deployed");
} else {
startFuture.fail(res.cause());
LOGGER.error("UserApiVerticle : Deployement failed");
}
});
}
}

View File

@@ -0,0 +1,83 @@
package io.swagger.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 = null;
private String name = null;
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 ");
}
}

View File

@@ -0,0 +1,96 @@
package io.swagger.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 = null;
private String type = null;
private String message = null;
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 ");
}
}

View File

@@ -0,0 +1,157 @@
package io.swagger.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 = null;
private Long petId = null;
private Integer quantity = null;
private OffsetDateTime shipDate = null;
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 = null;
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 ");
}
}

View File

@@ -0,0 +1,160 @@
package io.swagger.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 io.swagger.server.api.model.Category;
import io.swagger.server.api.model.Tag;
import java.util.ArrayList;
import java.util.List;
/**
* A pet for sale in the pet store
**/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Pet {
private Long id = null;
private Category category = null;
private String name = null;
private List<String> photoUrls = new ArrayList<String>();
private List<Tag> tags = new ArrayList<Tag>();
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 = null;
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 ");
}
}

View File

@@ -0,0 +1,83 @@
package io.swagger.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 = null;
private String name = null;
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 ");
}
}

View File

@@ -0,0 +1,161 @@
package io.swagger.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 = null;
private String username = null;
private String firstName = null;
private String lastName = null;
private String email = null;
private String password = null;
private String phone = null;
private Integer userStatus = null;
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 ");
}
}

View File

@@ -0,0 +1,39 @@
package io.swagger.server.api.verticle;
import java.io.File;
import io.swagger.server.api.MainApiException;
import io.swagger.server.api.model.ModelApiResponse;
import io.swagger.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);
}

View File

@@ -0,0 +1,25 @@
package io.swagger.server.api.verticle;
import java.io.File;
import io.swagger.server.api.MainApiException;
import io.swagger.server.api.model.ModelApiResponse;
import io.swagger.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_400_Exception = new PetApiException(400, "Invalid status value");
public static final PetApiException Pet_findPetsByTags_400_Exception = new PetApiException(400, "Invalid tag value");
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");
}

View File

@@ -0,0 +1,206 @@
package io.swagger.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 io.swagger.server.api.MainApiException;
import io.swagger.server.api.model.ModelApiResponse;
import io.swagger.server.api.model.Pet;
import java.util.List;
import java.util.Map;
public class PetApiVerticle extends AbstractVerticle {
final static Logger LOGGER = LoggerFactory.getLogger(PetApiVerticle.class);
final static String ADDPET_SERVICE_ID = "addPet";
final static String DELETEPET_SERVICE_ID = "deletePet";
final static String FINDPETSBYSTATUS_SERVICE_ID = "findPetsByStatus";
final static String FINDPETSBYTAGS_SERVICE_ID = "findPetsByTags";
final static String GETPETBYID_SERVICE_ID = "getPetById";
final static String UPDATEPET_SERVICE_ID = "updatePet";
final static String UPDATEPETWITHFORM_SERVICE_ID = "updatePetWithForm";
final static String UPLOADFILE_SERVICE_ID = "uploadFile";
//TODO : create Implementation
PetApi service = new PetApiImpl();
@Override
public void start() throws Exception {
//Consumer for addPet
vertx.eventBus().<JsonObject> consumer(ADDPET_SERVICE_ID).handler(message -> {
try {
Pet body = Json.mapper.readValue(message.body().getJsonObject("body").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 {
Long petId = Json.mapper.readValue(message.body().getString("petId"), Long.class);
String apiKey = message.body().getString("api_key");
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 {
List<String> status = Json.mapper.readValue(message.body().getJsonArray("status").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 {
List<String> tags = Json.mapper.readValue(message.body().getJsonArray("tags").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 {
Long petId = Json.mapper.readValue(message.body().getString("petId"), 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 {
Pet body = Json.mapper.readValue(message.body().getJsonObject("body").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 {
Long petId = Json.mapper.readValue(message.body().getString("petId"), Long.class);
String name = message.body().getString("name");
String status = message.body().getString("status");
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 {
Long petId = Json.mapper.readValue(message.body().getString("petId"), Long.class);
String additionalMetadata = message.body().getString("additionalMetadata");
File file = Json.mapper.readValue(message.body().getJsonObject("file").encode(), 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);
}
}

View File

@@ -0,0 +1,25 @@
package io.swagger.server.api.verticle;
import io.swagger.server.api.MainApiException;
import io.swagger.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);
}

View File

@@ -0,0 +1,18 @@
package io.swagger.server.api.verticle;
import io.swagger.server.api.MainApiException;
import io.swagger.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_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_400_Exception = new StoreApiException(400, "Invalid Order");
}

View File

@@ -0,0 +1,120 @@
package io.swagger.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 io.swagger.server.api.MainApiException;
import io.swagger.server.api.model.Order;
import java.util.List;
import java.util.Map;
public class StoreApiVerticle extends AbstractVerticle {
final static Logger LOGGER = LoggerFactory.getLogger(StoreApiVerticle.class);
final static String DELETEORDER_SERVICE_ID = "deleteOrder";
final static String GETINVENTORY_SERVICE_ID = "getInventory";
final static String GETORDERBYID_SERVICE_ID = "getOrderById";
final static String PLACEORDER_SERVICE_ID = "placeOrder";
//TODO : create Implementation
StoreApi service = new StoreApiImpl();
@Override
public void start() throws Exception {
//Consumer for deleteOrder
vertx.eventBus().<JsonObject> consumer(DELETEORDER_SERVICE_ID).handler(message -> {
try {
String orderId = message.body().getString("orderId");
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 {
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 {
Long orderId = Json.mapper.readValue(message.body().getString("orderId"), 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 {
Order body = Json.mapper.readValue(message.body().getJsonObject("body").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);
}
}

View File

@@ -0,0 +1,37 @@
package io.swagger.server.api.verticle;
import io.swagger.server.api.MainApiException;
import io.swagger.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);
}

View File

@@ -0,0 +1,20 @@
package io.swagger.server.api.verticle;
import io.swagger.server.api.MainApiException;
import io.swagger.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_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_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");
}

View File

@@ -0,0 +1,200 @@
package io.swagger.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 io.swagger.server.api.MainApiException;
import io.swagger.server.api.model.User;
import java.util.List;
import java.util.Map;
public class UserApiVerticle extends AbstractVerticle {
final static Logger LOGGER = LoggerFactory.getLogger(UserApiVerticle.class);
final static String CREATEUSER_SERVICE_ID = "createUser";
final static String CREATEUSERSWITHARRAYINPUT_SERVICE_ID = "createUsersWithArrayInput";
final static String CREATEUSERSWITHLISTINPUT_SERVICE_ID = "createUsersWithListInput";
final static String DELETEUSER_SERVICE_ID = "deleteUser";
final static String GETUSERBYNAME_SERVICE_ID = "getUserByName";
final static String LOGINUSER_SERVICE_ID = "loginUser";
final static String LOGOUTUSER_SERVICE_ID = "logoutUser";
final static String UPDATEUSER_SERVICE_ID = "updateUser";
//TODO : create Implementation
UserApi service = new UserApiImpl();
@Override
public void start() throws Exception {
//Consumer for createUser
vertx.eventBus().<JsonObject> consumer(CREATEUSER_SERVICE_ID).handler(message -> {
try {
User body = Json.mapper.readValue(message.body().getJsonObject("body").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 {
List<User> body = Json.mapper.readValue(message.body().getJsonArray("body").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 {
List<User> body = Json.mapper.readValue(message.body().getJsonArray("body").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 {
String username = message.body().getString("username");
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 {
String username = message.body().getString("username");
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 {
String username = message.body().getString("username");
String password = message.body().getString("password");
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 {
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 {
String username = message.body().getString("username");
User body = Json.mapper.readValue(message.body().getJsonObject("body").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);
}
}

View File

@@ -0,0 +1,870 @@
{
"swagger" : "2.0",
"info" : {
"description" : "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.",
"version" : "1.0.0",
"title" : "Swagger Petstore",
"termsOfService" : "http://swagger.io/terms/",
"contact" : {
"email" : "apiteam@swagger.io"
},
"license" : {
"name" : "Apache 2.0",
"url" : "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host" : "petstore.swagger.io",
"basePath" : "/v2",
"tags" : [ {
"name" : "pet",
"description" : "Everything about your Pets",
"externalDocs" : {
"description" : "Find out more",
"url" : "http://swagger.io"
}
}, {
"name" : "store",
"description" : "Access to Petstore orders"
}, {
"name" : "user",
"description" : "Operations about user",
"externalDocs" : {
"description" : "Find out more about our store",
"url" : "http://swagger.io"
}
} ],
"schemes" : [ "http" ],
"paths" : {
"/pet" : {
"post" : {
"tags" : [ "pet" ],
"summary" : "Add a new pet to the store",
"description" : "",
"operationId" : "addPet",
"consumes" : [ "application/json", "application/xml" ],
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ {
"in" : "body",
"name" : "body",
"description" : "Pet object that needs to be added to the store",
"required" : true,
"schema" : {
"$ref" : "#/definitions/Pet"
}
} ],
"responses" : {
"405" : {
"description" : "Invalid input"
}
},
"security" : [ {
"petstore_auth" : [ "write:pets", "read:pets" ]
} ],
"x-contentType" : "application/json",
"x-accepts" : "application/json"
},
"put" : {
"tags" : [ "pet" ],
"summary" : "Update an existing pet",
"description" : "",
"operationId" : "updatePet",
"consumes" : [ "application/json", "application/xml" ],
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ {
"in" : "body",
"name" : "body",
"description" : "Pet object that needs to be added to the store",
"required" : true,
"schema" : {
"$ref" : "#/definitions/Pet"
}
} ],
"responses" : {
"400" : {
"description" : "Invalid ID supplied"
},
"404" : {
"description" : "Pet not found"
},
"405" : {
"description" : "Validation exception"
}
},
"security" : [ {
"petstore_auth" : [ "write:pets", "read:pets" ]
} ],
"x-contentType" : "application/json",
"x-accepts" : "application/json"
}
},
"/pet/findByStatus" : {
"get" : {
"tags" : [ "pet" ],
"summary" : "Finds Pets by status",
"description" : "Multiple status values can be provided with comma separated strings",
"operationId" : "findPetsByStatus",
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ {
"name" : "status",
"in" : "query",
"description" : "Status values that need to be considered for filter",
"required" : true,
"type" : "array",
"items" : {
"type" : "string",
"default" : "available",
"enum" : [ "available", "pending", "sold" ]
},
"collectionFormat" : "csv"
} ],
"responses" : {
"200" : {
"description" : "successful operation",
"schema" : {
"type" : "array",
"items" : {
"$ref" : "#/definitions/Pet"
}
}
},
"400" : {
"description" : "Invalid status value"
}
},
"security" : [ {
"petstore_auth" : [ "write:pets", "read:pets" ]
} ],
"x-contentType" : "application/json",
"x-accepts" : "application/json"
}
},
"/pet/findByTags" : {
"get" : {
"tags" : [ "pet" ],
"summary" : "Finds Pets by tags",
"description" : "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.",
"operationId" : "findPetsByTags",
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ {
"name" : "tags",
"in" : "query",
"description" : "Tags to filter by",
"required" : true,
"type" : "array",
"items" : {
"type" : "string"
},
"collectionFormat" : "csv"
} ],
"responses" : {
"200" : {
"description" : "successful operation",
"schema" : {
"type" : "array",
"items" : {
"$ref" : "#/definitions/Pet"
}
}
},
"400" : {
"description" : "Invalid tag value"
}
},
"security" : [ {
"petstore_auth" : [ "write:pets", "read:pets" ]
} ],
"x-contentType" : "application/json",
"x-accepts" : "application/json"
}
},
"/pet/{petId}" : {
"get" : {
"tags" : [ "pet" ],
"summary" : "Find pet by ID",
"description" : "Returns a single pet",
"operationId" : "getPetById",
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ {
"name" : "petId",
"in" : "path",
"description" : "ID of pet to return",
"required" : true,
"type" : "integer",
"format" : "int64"
} ],
"responses" : {
"200" : {
"description" : "successful operation",
"schema" : {
"$ref" : "#/definitions/Pet"
}
},
"400" : {
"description" : "Invalid ID supplied"
},
"404" : {
"description" : "Pet not found"
}
},
"security" : [ {
"api_key" : [ ]
} ],
"x-contentType" : "application/json",
"x-accepts" : "application/json"
},
"post" : {
"tags" : [ "pet" ],
"summary" : "Updates a pet in the store with form data",
"description" : "",
"operationId" : "updatePetWithForm",
"consumes" : [ "application/x-www-form-urlencoded" ],
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ {
"name" : "petId",
"in" : "path",
"description" : "ID of pet that needs to be updated",
"required" : true,
"type" : "integer",
"format" : "int64"
}, {
"name" : "name",
"in" : "formData",
"description" : "Updated name of the pet",
"required" : false,
"type" : "string"
}, {
"name" : "status",
"in" : "formData",
"description" : "Updated status of the pet",
"required" : false,
"type" : "string"
} ],
"responses" : {
"405" : {
"description" : "Invalid input"
}
},
"security" : [ {
"petstore_auth" : [ "write:pets", "read:pets" ]
} ],
"x-contentType" : "application/x-www-form-urlencoded",
"x-accepts" : "application/json"
},
"delete" : {
"tags" : [ "pet" ],
"summary" : "Deletes a pet",
"description" : "",
"operationId" : "deletePet",
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ {
"name" : "api_key",
"in" : "header",
"required" : false,
"type" : "string"
}, {
"name" : "petId",
"in" : "path",
"description" : "Pet id to delete",
"required" : true,
"type" : "integer",
"format" : "int64"
} ],
"responses" : {
"400" : {
"description" : "Invalid pet value"
}
},
"security" : [ {
"petstore_auth" : [ "write:pets", "read:pets" ]
} ],
"x-contentType" : "application/json",
"x-accepts" : "application/json"
}
},
"/pet/{petId}/uploadImage" : {
"post" : {
"tags" : [ "pet" ],
"summary" : "uploads an image",
"description" : "",
"operationId" : "uploadFile",
"consumes" : [ "multipart/form-data" ],
"produces" : [ "application/json" ],
"parameters" : [ {
"name" : "petId",
"in" : "path",
"description" : "ID of pet to update",
"required" : true,
"type" : "integer",
"format" : "int64"
}, {
"name" : "additionalMetadata",
"in" : "formData",
"description" : "Additional data to pass to server",
"required" : false,
"type" : "string"
}, {
"name" : "file",
"in" : "formData",
"description" : "file to upload",
"required" : false,
"type" : "file"
} ],
"responses" : {
"200" : {
"description" : "successful operation",
"schema" : {
"$ref" : "#/definitions/ApiResponse"
}
}
},
"security" : [ {
"petstore_auth" : [ "write:pets", "read:pets" ]
} ],
"x-contentType" : "multipart/form-data",
"x-accepts" : "application/json"
}
},
"/store/inventory" : {
"get" : {
"tags" : [ "store" ],
"summary" : "Returns pet inventories by status",
"description" : "Returns a map of status codes to quantities",
"operationId" : "getInventory",
"produces" : [ "application/json" ],
"parameters" : [ ],
"responses" : {
"200" : {
"description" : "successful operation",
"schema" : {
"type" : "object",
"additionalProperties" : {
"type" : "integer",
"format" : "int32"
}
}
}
},
"security" : [ {
"api_key" : [ ]
} ],
"x-contentType" : "application/json",
"x-accepts" : "application/json"
}
},
"/store/order" : {
"post" : {
"tags" : [ "store" ],
"summary" : "Place an order for a pet",
"description" : "",
"operationId" : "placeOrder",
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ {
"in" : "body",
"name" : "body",
"description" : "order placed for purchasing the pet",
"required" : true,
"schema" : {
"$ref" : "#/definitions/Order"
}
} ],
"responses" : {
"200" : {
"description" : "successful operation",
"schema" : {
"$ref" : "#/definitions/Order"
}
},
"400" : {
"description" : "Invalid Order"
}
},
"x-contentType" : "application/json",
"x-accepts" : "application/json"
}
},
"/store/order/{orderId}" : {
"get" : {
"tags" : [ "store" ],
"summary" : "Find purchase order by ID",
"description" : "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions",
"operationId" : "getOrderById",
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ {
"name" : "orderId",
"in" : "path",
"description" : "ID of pet that needs to be fetched",
"required" : true,
"type" : "integer",
"maximum" : 5,
"minimum" : 1,
"format" : "int64"
} ],
"responses" : {
"200" : {
"description" : "successful operation",
"schema" : {
"$ref" : "#/definitions/Order"
}
},
"400" : {
"description" : "Invalid ID supplied"
},
"404" : {
"description" : "Order not found"
}
},
"x-contentType" : "application/json",
"x-accepts" : "application/json"
},
"delete" : {
"tags" : [ "store" ],
"summary" : "Delete purchase order by ID",
"description" : "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors",
"operationId" : "deleteOrder",
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ {
"name" : "orderId",
"in" : "path",
"description" : "ID of the order that needs to be deleted",
"required" : true,
"type" : "string"
} ],
"responses" : {
"400" : {
"description" : "Invalid ID supplied"
},
"404" : {
"description" : "Order not found"
}
},
"x-contentType" : "application/json",
"x-accepts" : "application/json"
}
},
"/user" : {
"post" : {
"tags" : [ "user" ],
"summary" : "Create user",
"description" : "This can only be done by the logged in user.",
"operationId" : "createUser",
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ {
"in" : "body",
"name" : "body",
"description" : "Created user object",
"required" : true,
"schema" : {
"$ref" : "#/definitions/User"
}
} ],
"responses" : {
"default" : {
"description" : "successful operation"
}
},
"x-contentType" : "application/json",
"x-accepts" : "application/json"
}
},
"/user/createWithArray" : {
"post" : {
"tags" : [ "user" ],
"summary" : "Creates list of users with given input array",
"description" : "",
"operationId" : "createUsersWithArrayInput",
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ {
"in" : "body",
"name" : "body",
"description" : "List of user object",
"required" : true,
"schema" : {
"type" : "array",
"items" : {
"$ref" : "#/definitions/User"
}
}
} ],
"responses" : {
"default" : {
"description" : "successful operation"
}
},
"x-contentType" : "application/json",
"x-accepts" : "application/json"
}
},
"/user/createWithList" : {
"post" : {
"tags" : [ "user" ],
"summary" : "Creates list of users with given input array",
"description" : "",
"operationId" : "createUsersWithListInput",
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ {
"in" : "body",
"name" : "body",
"description" : "List of user object",
"required" : true,
"schema" : {
"type" : "array",
"items" : {
"$ref" : "#/definitions/User"
}
}
} ],
"responses" : {
"default" : {
"description" : "successful operation"
}
},
"x-contentType" : "application/json",
"x-accepts" : "application/json"
}
},
"/user/login" : {
"get" : {
"tags" : [ "user" ],
"summary" : "Logs user into the system",
"description" : "",
"operationId" : "loginUser",
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ {
"name" : "username",
"in" : "query",
"description" : "The user name for login",
"required" : true,
"type" : "string"
}, {
"name" : "password",
"in" : "query",
"description" : "The password for login in clear text",
"required" : true,
"type" : "string"
} ],
"responses" : {
"200" : {
"description" : "successful operation",
"schema" : {
"type" : "string"
},
"headers" : {
"X-Rate-Limit" : {
"type" : "integer",
"format" : "int32",
"description" : "calls per hour allowed by the user"
},
"X-Expires-After" : {
"type" : "string",
"format" : "date-time",
"description" : "date in UTC when toekn expires"
}
}
},
"400" : {
"description" : "Invalid username/password supplied"
}
},
"x-contentType" : "application/json",
"x-accepts" : "application/json"
}
},
"/user/logout" : {
"get" : {
"tags" : [ "user" ],
"summary" : "Logs out current logged in user session",
"description" : "",
"operationId" : "logoutUser",
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ ],
"responses" : {
"default" : {
"description" : "successful operation"
}
},
"x-contentType" : "application/json",
"x-accepts" : "application/json"
}
},
"/user/{username}" : {
"get" : {
"tags" : [ "user" ],
"summary" : "Get user by user name",
"description" : "",
"operationId" : "getUserByName",
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ {
"name" : "username",
"in" : "path",
"description" : "The name that needs to be fetched. Use user1 for testing. ",
"required" : true,
"type" : "string"
} ],
"responses" : {
"200" : {
"description" : "successful operation",
"schema" : {
"$ref" : "#/definitions/User"
}
},
"400" : {
"description" : "Invalid username supplied"
},
"404" : {
"description" : "User not found"
}
},
"x-contentType" : "application/json",
"x-accepts" : "application/json"
},
"put" : {
"tags" : [ "user" ],
"summary" : "Updated user",
"description" : "This can only be done by the logged in user.",
"operationId" : "updateUser",
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ {
"name" : "username",
"in" : "path",
"description" : "name that need to be deleted",
"required" : true,
"type" : "string"
}, {
"in" : "body",
"name" : "body",
"description" : "Updated user object",
"required" : true,
"schema" : {
"$ref" : "#/definitions/User"
}
} ],
"responses" : {
"400" : {
"description" : "Invalid user supplied"
},
"404" : {
"description" : "User not found"
}
},
"x-contentType" : "application/json",
"x-accepts" : "application/json"
},
"delete" : {
"tags" : [ "user" ],
"summary" : "Delete user",
"description" : "This can only be done by the logged in user.",
"operationId" : "deleteUser",
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ {
"name" : "username",
"in" : "path",
"description" : "The name that needs to be deleted",
"required" : true,
"type" : "string"
} ],
"responses" : {
"400" : {
"description" : "Invalid username supplied"
},
"404" : {
"description" : "User not found"
}
},
"x-contentType" : "application/json",
"x-accepts" : "application/json"
}
}
},
"securityDefinitions" : {
"petstore_auth" : {
"type" : "oauth2",
"authorizationUrl" : "http://petstore.swagger.io/api/oauth/dialog",
"flow" : "implicit",
"scopes" : {
"write:pets" : "modify pets in your account",
"read:pets" : "read your pets"
}
},
"api_key" : {
"type" : "apiKey",
"name" : "api_key",
"in" : "header"
}
},
"definitions" : {
"Order" : {
"type" : "object",
"properties" : {
"id" : {
"type" : "integer",
"format" : "int64"
},
"petId" : {
"type" : "integer",
"format" : "int64"
},
"quantity" : {
"type" : "integer",
"format" : "int32"
},
"shipDate" : {
"type" : "string",
"format" : "date-time"
},
"status" : {
"type" : "string",
"description" : "Order Status",
"enum" : [ "placed", "approved", "delivered" ]
},
"complete" : {
"type" : "boolean",
"default" : false
}
},
"title" : "Pet Order",
"description" : "An order for a pets from the pet store",
"xml" : {
"name" : "Order"
}
},
"Category" : {
"type" : "object",
"properties" : {
"id" : {
"type" : "integer",
"format" : "int64"
},
"name" : {
"type" : "string"
}
},
"title" : "Pet catehgry",
"description" : "A category for a pet",
"xml" : {
"name" : "Category"
}
},
"User" : {
"type" : "object",
"properties" : {
"id" : {
"type" : "integer",
"format" : "int64"
},
"username" : {
"type" : "string"
},
"firstName" : {
"type" : "string"
},
"lastName" : {
"type" : "string"
},
"email" : {
"type" : "string"
},
"password" : {
"type" : "string"
},
"phone" : {
"type" : "string"
},
"userStatus" : {
"type" : "integer",
"format" : "int32",
"description" : "User Status"
}
},
"title" : "a User",
"description" : "A User who is purchasing from the pet store",
"xml" : {
"name" : "User"
}
},
"Tag" : {
"type" : "object",
"properties" : {
"id" : {
"type" : "integer",
"format" : "int64"
},
"name" : {
"type" : "string"
}
},
"title" : "Pet Tag",
"description" : "A tag for a pet",
"xml" : {
"name" : "Tag"
}
},
"Pet" : {
"type" : "object",
"required" : [ "name", "photoUrls" ],
"properties" : {
"id" : {
"type" : "integer",
"format" : "int64"
},
"category" : {
"$ref" : "#/definitions/Category"
},
"name" : {
"type" : "string",
"example" : "doggie"
},
"photoUrls" : {
"type" : "array",
"xml" : {
"name" : "photoUrl",
"wrapped" : true
},
"items" : {
"type" : "string"
}
},
"tags" : {
"type" : "array",
"xml" : {
"name" : "tag",
"wrapped" : true
},
"items" : {
"$ref" : "#/definitions/Tag"
}
},
"status" : {
"type" : "string",
"description" : "pet status in the store",
"enum" : [ "available", "pending", "sold" ]
}
},
"title" : "a Pet",
"description" : "A pet for sale in the pet store",
"xml" : {
"name" : "Pet"
}
},
"ApiResponse" : {
"type" : "object",
"properties" : {
"code" : {
"type" : "integer",
"format" : "int32"
},
"type" : {
"type" : "string"
},
"message" : {
"type" : "string"
}
},
"title" : "An uploaded response",
"description" : "Describes the result of uploading an image resource"
}
},
"externalDocs" : {
"description" : "Find out more about Swagger",
"url" : "http://swagger.io"
}
}

View File

@@ -0,0 +1,30 @@
#
# 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