mirror of
https://github.com/jlengrand/openapi-generator.git
synced 2026-05-17 00:21:19 +00:00
Update Vert.x Web template to Vert.x 4 (#7364)
* Update Vert.x Web template to Vert.x 4 Signed-off-by: Francesco Guardiani <francescoguard@gmail.com> * Bad pom Signed-off-by: Francesco Guardiani <francescoguard@gmail.com> * Bad pom 2 Signed-off-by: Francesco Guardiani <francescoguard@gmail.com> * Stick to Java 8 Signed-off-by: Francesco Guardiani <francescoguard@gmail.com> * Latest vert.x 4 Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
This commit is contained in:
committed by
GitHub
parent
ea559b5e20
commit
80bef2f79a
@@ -0,0 +1,37 @@
|
||||
package org.openapitools.vertxweb.server;
|
||||
|
||||
public class ApiResponse<T> {
|
||||
private final T data;
|
||||
private final int statusCode;
|
||||
|
||||
public ApiResponse() {
|
||||
this(200, null);
|
||||
}
|
||||
|
||||
public ApiResponse(T data) {
|
||||
this(200, data);
|
||||
}
|
||||
|
||||
public ApiResponse(int statusCode) {
|
||||
this(statusCode, null);
|
||||
}
|
||||
|
||||
public ApiResponse(int statusCode, T data) {
|
||||
this.statusCode = statusCode;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public boolean hasData() {
|
||||
return data != null;
|
||||
}
|
||||
|
||||
public T getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public int getStatusCode() {
|
||||
return statusCode;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package org.openapitools.vertxweb.server;
|
||||
|
||||
import io.vertx.core.AbstractVerticle;
|
||||
import io.vertx.core.Promise;
|
||||
import io.vertx.core.http.HttpServerOptions;
|
||||
import io.vertx.ext.web.Router;
|
||||
import io.vertx.ext.web.RoutingContext;
|
||||
import io.vertx.ext.web.openapi.RouterFactory;
|
||||
import io.vertx.ext.web.openapi.RouterFactoryOptions;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.openapitools.vertxweb.server.api.PetApiHandler;
|
||||
import org.openapitools.vertxweb.server.api.StoreApiHandler;
|
||||
import org.openapitools.vertxweb.server.api.UserApiHandler;
|
||||
|
||||
public class HttpServerVerticle extends AbstractVerticle {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(HttpServerVerticle.class);
|
||||
private static final String specFile = "src/main/resources/openapi.yaml";
|
||||
|
||||
|
||||
private final PetApiHandler petHandler = new PetApiHandler();
|
||||
private final StoreApiHandler storeHandler = new StoreApiHandler();
|
||||
private final UserApiHandler userHandler = new UserApiHandler();
|
||||
|
||||
@Override
|
||||
public void start(Promise<Void> startPromise) {
|
||||
RouterFactory.create(vertx, specFile)
|
||||
.map(factory -> {
|
||||
factory.setOptions(new RouterFactoryOptions()
|
||||
// For production use case, you need to enable this flag and provide the proper security handler
|
||||
.setRequireSecurityHandlers(false)
|
||||
);
|
||||
|
||||
petHandler.mount(factory);
|
||||
storeHandler.mount(factory);
|
||||
userHandler.mount(factory);
|
||||
|
||||
Router router = factory.createRouter();
|
||||
router.errorHandler(400, this::validationFailureHandler);
|
||||
|
||||
return router;
|
||||
})
|
||||
.compose(router ->
|
||||
vertx.createHttpServer()
|
||||
.requestHandler(router)
|
||||
.listen(8080)
|
||||
)
|
||||
.onSuccess(server -> logger.info("Http verticle deploy successful"))
|
||||
.onFailure(t -> logger.error("Http verticle failed to deploy", t))
|
||||
// Complete the start promise
|
||||
.<Void>mapEmpty().onComplete(startPromise);
|
||||
}
|
||||
|
||||
private void validationFailureHandler(RoutingContext rc) {
|
||||
rc.response().setStatusCode(400)
|
||||
.end("Bad Request : " + rc.failure().getMessage());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.openapitools.vertxweb.server.api;
|
||||
|
||||
import io.vertx.ext.web.FileUpload;
|
||||
import org.openapitools.vertxweb.server.model.ModelApiResponse;
|
||||
import org.openapitools.vertxweb.server.model.Pet;
|
||||
|
||||
import org.openapitools.vertxweb.server.ApiResponse;
|
||||
|
||||
import io.vertx.core.Future;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface PetApi {
|
||||
Future<ApiResponse<Pet>> addPet(Pet pet);
|
||||
Future<ApiResponse<Void>> deletePet(Long petId, String apiKey);
|
||||
Future<ApiResponse<List<Pet>>> findPetsByStatus(List<String> status);
|
||||
Future<ApiResponse<List<Pet>>> findPetsByTags(List<String> tags);
|
||||
Future<ApiResponse<Pet>> getPetById(Long petId);
|
||||
Future<ApiResponse<Pet>> updatePet(Pet pet);
|
||||
Future<ApiResponse<Void>> updatePetWithForm(Long petId, JsonObject formBody);
|
||||
Future<ApiResponse<ModelApiResponse>> uploadFile(Long petId, FileUpload file);
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
package org.openapitools.vertxweb.server.api;
|
||||
|
||||
import io.vertx.ext.web.FileUpload;
|
||||
import org.openapitools.vertxweb.server.model.ModelApiResponse;
|
||||
import org.openapitools.vertxweb.server.model.Pet;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import io.vertx.core.json.jackson.DatabindCodec;
|
||||
import io.vertx.ext.web.openapi.RouterFactory;
|
||||
import io.vertx.ext.web.validation.RequestParameters;
|
||||
import io.vertx.ext.web.validation.RequestParameter;
|
||||
import io.vertx.ext.web.validation.ValidationHandler;
|
||||
import io.vertx.ext.web.RoutingContext;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class PetApiHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(PetApiHandler.class);
|
||||
|
||||
private final PetApi apiImpl;
|
||||
|
||||
public PetApiHandler() {
|
||||
this.apiImpl = new PetApiImpl();
|
||||
}
|
||||
|
||||
public void mount(RouterFactory factory) {
|
||||
factory.operation("addPet").handler(this::addPet);
|
||||
factory.operation("deletePet").handler(this::deletePet);
|
||||
factory.operation("findPetsByStatus").handler(this::findPetsByStatus);
|
||||
factory.operation("findPetsByTags").handler(this::findPetsByTags);
|
||||
factory.operation("getPetById").handler(this::getPetById);
|
||||
factory.operation("updatePet").handler(this::updatePet);
|
||||
factory.operation("updatePetWithForm").handler(this::updatePetWithForm);
|
||||
factory.operation("uploadFile").handler(this::uploadFile);
|
||||
}
|
||||
|
||||
private void addPet(RoutingContext routingContext) {
|
||||
logger.info("addPet()");
|
||||
|
||||
// Param extraction
|
||||
RequestParameters requestParameters = routingContext.get(ValidationHandler.REQUEST_CONTEXT_KEY);
|
||||
|
||||
RequestParameter body = requestParameters.body();
|
||||
Pet pet = body != null ? DatabindCodec.mapper().convertValue(body.get(), new TypeReference<Pet>(){}) : null;
|
||||
|
||||
logger.debug("Parameter pet is {}", pet);
|
||||
|
||||
apiImpl.addPet(pet)
|
||||
.onSuccess(apiResponse -> {
|
||||
routingContext.response().setStatusCode(apiResponse.getStatusCode());
|
||||
if (apiResponse.hasData()) {
|
||||
routingContext.json(apiResponse.getData());
|
||||
} else {
|
||||
routingContext.response().end();
|
||||
}
|
||||
})
|
||||
.onFailure(routingContext::fail);
|
||||
}
|
||||
|
||||
private void deletePet(RoutingContext routingContext) {
|
||||
logger.info("deletePet()");
|
||||
|
||||
// Param extraction
|
||||
RequestParameters requestParameters = routingContext.get(ValidationHandler.REQUEST_CONTEXT_KEY);
|
||||
|
||||
Long petId = requestParameters.pathParameter("petId") != null ? requestParameters.pathParameter("petId").getLong() : null;
|
||||
String apiKey = requestParameters.headerParameter("api_key") != null ? requestParameters.headerParameter("api_key").getString() : null;
|
||||
|
||||
logger.debug("Parameter petId is {}", petId);
|
||||
logger.debug("Parameter apiKey is {}", apiKey);
|
||||
|
||||
apiImpl.deletePet(petId, apiKey)
|
||||
.onSuccess(apiResponse -> {
|
||||
routingContext.response().setStatusCode(apiResponse.getStatusCode());
|
||||
if (apiResponse.hasData()) {
|
||||
routingContext.json(apiResponse.getData());
|
||||
} else {
|
||||
routingContext.response().end();
|
||||
}
|
||||
})
|
||||
.onFailure(routingContext::fail);
|
||||
}
|
||||
|
||||
private void findPetsByStatus(RoutingContext routingContext) {
|
||||
logger.info("findPetsByStatus()");
|
||||
|
||||
// Param extraction
|
||||
RequestParameters requestParameters = routingContext.get(ValidationHandler.REQUEST_CONTEXT_KEY);
|
||||
|
||||
List<String> status = requestParameters.queryParameter("status") != null ? DatabindCodec.mapper().convertValue(requestParameters.queryParameter("status").get(), new TypeReference<List<String>>(){}) : null;
|
||||
|
||||
logger.debug("Parameter status is {}", status);
|
||||
|
||||
apiImpl.findPetsByStatus(status)
|
||||
.onSuccess(apiResponse -> {
|
||||
routingContext.response().setStatusCode(apiResponse.getStatusCode());
|
||||
if (apiResponse.hasData()) {
|
||||
routingContext.json(apiResponse.getData());
|
||||
} else {
|
||||
routingContext.response().end();
|
||||
}
|
||||
})
|
||||
.onFailure(routingContext::fail);
|
||||
}
|
||||
|
||||
private void findPetsByTags(RoutingContext routingContext) {
|
||||
logger.info("findPetsByTags()");
|
||||
|
||||
// Param extraction
|
||||
RequestParameters requestParameters = routingContext.get(ValidationHandler.REQUEST_CONTEXT_KEY);
|
||||
|
||||
List<String> tags = requestParameters.queryParameter("tags") != null ? DatabindCodec.mapper().convertValue(requestParameters.queryParameter("tags").get(), new TypeReference<List<String>>(){}) : null;
|
||||
|
||||
logger.debug("Parameter tags is {}", tags);
|
||||
|
||||
apiImpl.findPetsByTags(tags)
|
||||
.onSuccess(apiResponse -> {
|
||||
routingContext.response().setStatusCode(apiResponse.getStatusCode());
|
||||
if (apiResponse.hasData()) {
|
||||
routingContext.json(apiResponse.getData());
|
||||
} else {
|
||||
routingContext.response().end();
|
||||
}
|
||||
})
|
||||
.onFailure(routingContext::fail);
|
||||
}
|
||||
|
||||
private void getPetById(RoutingContext routingContext) {
|
||||
logger.info("getPetById()");
|
||||
|
||||
// Param extraction
|
||||
RequestParameters requestParameters = routingContext.get(ValidationHandler.REQUEST_CONTEXT_KEY);
|
||||
|
||||
Long petId = requestParameters.pathParameter("petId") != null ? requestParameters.pathParameter("petId").getLong() : null;
|
||||
|
||||
logger.debug("Parameter petId is {}", petId);
|
||||
|
||||
apiImpl.getPetById(petId)
|
||||
.onSuccess(apiResponse -> {
|
||||
routingContext.response().setStatusCode(apiResponse.getStatusCode());
|
||||
if (apiResponse.hasData()) {
|
||||
routingContext.json(apiResponse.getData());
|
||||
} else {
|
||||
routingContext.response().end();
|
||||
}
|
||||
})
|
||||
.onFailure(routingContext::fail);
|
||||
}
|
||||
|
||||
private void updatePet(RoutingContext routingContext) {
|
||||
logger.info("updatePet()");
|
||||
|
||||
// Param extraction
|
||||
RequestParameters requestParameters = routingContext.get(ValidationHandler.REQUEST_CONTEXT_KEY);
|
||||
|
||||
RequestParameter body = requestParameters.body();
|
||||
Pet pet = body != null ? DatabindCodec.mapper().convertValue(body.get(), new TypeReference<Pet>(){}) : null;
|
||||
|
||||
logger.debug("Parameter pet is {}", pet);
|
||||
|
||||
apiImpl.updatePet(pet)
|
||||
.onSuccess(apiResponse -> {
|
||||
routingContext.response().setStatusCode(apiResponse.getStatusCode());
|
||||
if (apiResponse.hasData()) {
|
||||
routingContext.json(apiResponse.getData());
|
||||
} else {
|
||||
routingContext.response().end();
|
||||
}
|
||||
})
|
||||
.onFailure(routingContext::fail);
|
||||
}
|
||||
|
||||
private void updatePetWithForm(RoutingContext routingContext) {
|
||||
logger.info("updatePetWithForm()");
|
||||
|
||||
// Param extraction
|
||||
RequestParameters requestParameters = routingContext.get(ValidationHandler.REQUEST_CONTEXT_KEY);
|
||||
|
||||
Long petId = requestParameters.pathParameter("petId") != null ? requestParameters.pathParameter("petId").getLong() : null;
|
||||
RequestParameter body = requestParameters.body();
|
||||
JsonObject formBody = body != null ? body.getJsonObject() : null;
|
||||
|
||||
logger.debug("Parameter petId is {}", petId);
|
||||
logger.debug("Parameter formBody is {}", formBody);
|
||||
|
||||
apiImpl.updatePetWithForm(petId, formBody)
|
||||
.onSuccess(apiResponse -> {
|
||||
routingContext.response().setStatusCode(apiResponse.getStatusCode());
|
||||
if (apiResponse.hasData()) {
|
||||
routingContext.json(apiResponse.getData());
|
||||
} else {
|
||||
routingContext.response().end();
|
||||
}
|
||||
})
|
||||
.onFailure(routingContext::fail);
|
||||
}
|
||||
|
||||
private void uploadFile(RoutingContext routingContext) {
|
||||
logger.info("uploadFile()");
|
||||
|
||||
// Param extraction
|
||||
RequestParameters requestParameters = routingContext.get(ValidationHandler.REQUEST_CONTEXT_KEY);
|
||||
|
||||
Long petId = requestParameters.pathParameter("petId") != null ? requestParameters.pathParameter("petId").getLong() : null;
|
||||
FileUpload file = routingContext.fileUploads().iterator().next();
|
||||
|
||||
logger.debug("Parameter petId is {}", petId);
|
||||
logger.debug("Parameter file is {}", file);
|
||||
|
||||
apiImpl.uploadFile(petId, file)
|
||||
.onSuccess(apiResponse -> {
|
||||
routingContext.response().setStatusCode(apiResponse.getStatusCode());
|
||||
if (apiResponse.hasData()) {
|
||||
routingContext.json(apiResponse.getData());
|
||||
} else {
|
||||
routingContext.response().end();
|
||||
}
|
||||
})
|
||||
.onFailure(routingContext::fail);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package org.openapitools.vertxweb.server.api;
|
||||
|
||||
import io.vertx.ext.web.FileUpload;
|
||||
import org.openapitools.vertxweb.server.model.ModelApiResponse;
|
||||
import org.openapitools.vertxweb.server.model.Pet;
|
||||
|
||||
import org.openapitools.vertxweb.server.ApiResponse;
|
||||
|
||||
import io.vertx.core.Future;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import io.vertx.ext.web.handler.impl.HttpStatusException;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
// Implement this class
|
||||
|
||||
public class PetApiImpl implements PetApi {
|
||||
public Future<ApiResponse<Pet>> addPet(Pet pet) {
|
||||
return Future.failedFuture(new HttpStatusException(501));
|
||||
}
|
||||
|
||||
public Future<ApiResponse<Void>> deletePet(Long petId, String apiKey) {
|
||||
return Future.failedFuture(new HttpStatusException(501));
|
||||
}
|
||||
|
||||
public Future<ApiResponse<List<Pet>>> findPetsByStatus(List<String> status) {
|
||||
return Future.failedFuture(new HttpStatusException(501));
|
||||
}
|
||||
|
||||
public Future<ApiResponse<List<Pet>>> findPetsByTags(List<String> tags) {
|
||||
return Future.failedFuture(new HttpStatusException(501));
|
||||
}
|
||||
|
||||
public Future<ApiResponse<Pet>> getPetById(Long petId) {
|
||||
return Future.failedFuture(new HttpStatusException(501));
|
||||
}
|
||||
|
||||
public Future<ApiResponse<Pet>> updatePet(Pet pet) {
|
||||
return Future.failedFuture(new HttpStatusException(501));
|
||||
}
|
||||
|
||||
public Future<ApiResponse<Void>> updatePetWithForm(Long petId, JsonObject formBody) {
|
||||
return Future.failedFuture(new HttpStatusException(501));
|
||||
}
|
||||
|
||||
public Future<ApiResponse<ModelApiResponse>> uploadFile(Long petId, FileUpload file) {
|
||||
return Future.failedFuture(new HttpStatusException(501));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.openapitools.vertxweb.server.api;
|
||||
|
||||
import org.openapitools.vertxweb.server.model.Order;
|
||||
|
||||
import org.openapitools.vertxweb.server.ApiResponse;
|
||||
|
||||
import io.vertx.core.Future;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface StoreApi {
|
||||
Future<ApiResponse<Void>> deleteOrder(String orderId);
|
||||
Future<ApiResponse<Map<String, Integer>>> getInventory();
|
||||
Future<ApiResponse<Order>> getOrderById(Long orderId);
|
||||
Future<ApiResponse<Order>> placeOrder(Order order);
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
package org.openapitools.vertxweb.server.api;
|
||||
|
||||
import org.openapitools.vertxweb.server.model.Order;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import io.vertx.core.json.jackson.DatabindCodec;
|
||||
import io.vertx.ext.web.openapi.RouterFactory;
|
||||
import io.vertx.ext.web.validation.RequestParameters;
|
||||
import io.vertx.ext.web.validation.RequestParameter;
|
||||
import io.vertx.ext.web.validation.ValidationHandler;
|
||||
import io.vertx.ext.web.RoutingContext;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class StoreApiHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(StoreApiHandler.class);
|
||||
|
||||
private final StoreApi apiImpl;
|
||||
|
||||
public StoreApiHandler() {
|
||||
this.apiImpl = new StoreApiImpl();
|
||||
}
|
||||
|
||||
public void mount(RouterFactory factory) {
|
||||
factory.operation("deleteOrder").handler(this::deleteOrder);
|
||||
factory.operation("getInventory").handler(this::getInventory);
|
||||
factory.operation("getOrderById").handler(this::getOrderById);
|
||||
factory.operation("placeOrder").handler(this::placeOrder);
|
||||
}
|
||||
|
||||
private void deleteOrder(RoutingContext routingContext) {
|
||||
logger.info("deleteOrder()");
|
||||
|
||||
// Param extraction
|
||||
RequestParameters requestParameters = routingContext.get(ValidationHandler.REQUEST_CONTEXT_KEY);
|
||||
|
||||
String orderId = requestParameters.pathParameter("orderId") != null ? requestParameters.pathParameter("orderId").getString() : null;
|
||||
|
||||
logger.debug("Parameter orderId is {}", orderId);
|
||||
|
||||
apiImpl.deleteOrder(orderId)
|
||||
.onSuccess(apiResponse -> {
|
||||
routingContext.response().setStatusCode(apiResponse.getStatusCode());
|
||||
if (apiResponse.hasData()) {
|
||||
routingContext.json(apiResponse.getData());
|
||||
} else {
|
||||
routingContext.response().end();
|
||||
}
|
||||
})
|
||||
.onFailure(routingContext::fail);
|
||||
}
|
||||
|
||||
private void getInventory(RoutingContext routingContext) {
|
||||
logger.info("getInventory()");
|
||||
|
||||
// Param extraction
|
||||
RequestParameters requestParameters = routingContext.get(ValidationHandler.REQUEST_CONTEXT_KEY);
|
||||
|
||||
|
||||
|
||||
apiImpl.getInventory()
|
||||
.onSuccess(apiResponse -> {
|
||||
routingContext.response().setStatusCode(apiResponse.getStatusCode());
|
||||
if (apiResponse.hasData()) {
|
||||
routingContext.json(apiResponse.getData());
|
||||
} else {
|
||||
routingContext.response().end();
|
||||
}
|
||||
})
|
||||
.onFailure(routingContext::fail);
|
||||
}
|
||||
|
||||
private void getOrderById(RoutingContext routingContext) {
|
||||
logger.info("getOrderById()");
|
||||
|
||||
// Param extraction
|
||||
RequestParameters requestParameters = routingContext.get(ValidationHandler.REQUEST_CONTEXT_KEY);
|
||||
|
||||
Long orderId = requestParameters.pathParameter("orderId") != null ? requestParameters.pathParameter("orderId").getLong() : null;
|
||||
|
||||
logger.debug("Parameter orderId is {}", orderId);
|
||||
|
||||
apiImpl.getOrderById(orderId)
|
||||
.onSuccess(apiResponse -> {
|
||||
routingContext.response().setStatusCode(apiResponse.getStatusCode());
|
||||
if (apiResponse.hasData()) {
|
||||
routingContext.json(apiResponse.getData());
|
||||
} else {
|
||||
routingContext.response().end();
|
||||
}
|
||||
})
|
||||
.onFailure(routingContext::fail);
|
||||
}
|
||||
|
||||
private void placeOrder(RoutingContext routingContext) {
|
||||
logger.info("placeOrder()");
|
||||
|
||||
// Param extraction
|
||||
RequestParameters requestParameters = routingContext.get(ValidationHandler.REQUEST_CONTEXT_KEY);
|
||||
|
||||
RequestParameter body = requestParameters.body();
|
||||
Order order = body != null ? DatabindCodec.mapper().convertValue(body.get(), new TypeReference<Order>(){}) : null;
|
||||
|
||||
logger.debug("Parameter order is {}", order);
|
||||
|
||||
apiImpl.placeOrder(order)
|
||||
.onSuccess(apiResponse -> {
|
||||
routingContext.response().setStatusCode(apiResponse.getStatusCode());
|
||||
if (apiResponse.hasData()) {
|
||||
routingContext.json(apiResponse.getData());
|
||||
} else {
|
||||
routingContext.response().end();
|
||||
}
|
||||
})
|
||||
.onFailure(routingContext::fail);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package org.openapitools.vertxweb.server.api;
|
||||
|
||||
import org.openapitools.vertxweb.server.model.Order;
|
||||
|
||||
import org.openapitools.vertxweb.server.ApiResponse;
|
||||
|
||||
import io.vertx.core.Future;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import io.vertx.ext.web.handler.impl.HttpStatusException;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
// Implement this class
|
||||
|
||||
public class StoreApiImpl implements StoreApi {
|
||||
public Future<ApiResponse<Void>> deleteOrder(String orderId) {
|
||||
return Future.failedFuture(new HttpStatusException(501));
|
||||
}
|
||||
|
||||
public Future<ApiResponse<Map<String, Integer>>> getInventory() {
|
||||
return Future.failedFuture(new HttpStatusException(501));
|
||||
}
|
||||
|
||||
public Future<ApiResponse<Order>> getOrderById(Long orderId) {
|
||||
return Future.failedFuture(new HttpStatusException(501));
|
||||
}
|
||||
|
||||
public Future<ApiResponse<Order>> placeOrder(Order order) {
|
||||
return Future.failedFuture(new HttpStatusException(501));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package org.openapitools.vertxweb.server.api;
|
||||
|
||||
import org.openapitools.vertxweb.server.model.User;
|
||||
|
||||
import org.openapitools.vertxweb.server.ApiResponse;
|
||||
|
||||
import io.vertx.core.Future;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface UserApi {
|
||||
Future<ApiResponse<Void>> createUser(User user);
|
||||
Future<ApiResponse<Void>> createUsersWithArrayInput(List<User> user);
|
||||
Future<ApiResponse<Void>> createUsersWithListInput(List<User> user);
|
||||
Future<ApiResponse<Void>> deleteUser(String username);
|
||||
Future<ApiResponse<User>> getUserByName(String username);
|
||||
Future<ApiResponse<String>> loginUser(String username, String password);
|
||||
Future<ApiResponse<Void>> logoutUser();
|
||||
Future<ApiResponse<Void>> updateUser(String username, User user);
|
||||
}
|
||||
@@ -0,0 +1,222 @@
|
||||
package org.openapitools.vertxweb.server.api;
|
||||
|
||||
import org.openapitools.vertxweb.server.model.User;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import io.vertx.core.json.jackson.DatabindCodec;
|
||||
import io.vertx.ext.web.openapi.RouterFactory;
|
||||
import io.vertx.ext.web.validation.RequestParameters;
|
||||
import io.vertx.ext.web.validation.RequestParameter;
|
||||
import io.vertx.ext.web.validation.ValidationHandler;
|
||||
import io.vertx.ext.web.RoutingContext;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class UserApiHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(UserApiHandler.class);
|
||||
|
||||
private final UserApi apiImpl;
|
||||
|
||||
public UserApiHandler() {
|
||||
this.apiImpl = new UserApiImpl();
|
||||
}
|
||||
|
||||
public void mount(RouterFactory factory) {
|
||||
factory.operation("createUser").handler(this::createUser);
|
||||
factory.operation("createUsersWithArrayInput").handler(this::createUsersWithArrayInput);
|
||||
factory.operation("createUsersWithListInput").handler(this::createUsersWithListInput);
|
||||
factory.operation("deleteUser").handler(this::deleteUser);
|
||||
factory.operation("getUserByName").handler(this::getUserByName);
|
||||
factory.operation("loginUser").handler(this::loginUser);
|
||||
factory.operation("logoutUser").handler(this::logoutUser);
|
||||
factory.operation("updateUser").handler(this::updateUser);
|
||||
}
|
||||
|
||||
private void createUser(RoutingContext routingContext) {
|
||||
logger.info("createUser()");
|
||||
|
||||
// Param extraction
|
||||
RequestParameters requestParameters = routingContext.get(ValidationHandler.REQUEST_CONTEXT_KEY);
|
||||
|
||||
RequestParameter body = requestParameters.body();
|
||||
User user = body != null ? DatabindCodec.mapper().convertValue(body.get(), new TypeReference<User>(){}) : null;
|
||||
|
||||
logger.debug("Parameter user is {}", user);
|
||||
|
||||
apiImpl.createUser(user)
|
||||
.onSuccess(apiResponse -> {
|
||||
routingContext.response().setStatusCode(apiResponse.getStatusCode());
|
||||
if (apiResponse.hasData()) {
|
||||
routingContext.json(apiResponse.getData());
|
||||
} else {
|
||||
routingContext.response().end();
|
||||
}
|
||||
})
|
||||
.onFailure(routingContext::fail);
|
||||
}
|
||||
|
||||
private void createUsersWithArrayInput(RoutingContext routingContext) {
|
||||
logger.info("createUsersWithArrayInput()");
|
||||
|
||||
// Param extraction
|
||||
RequestParameters requestParameters = routingContext.get(ValidationHandler.REQUEST_CONTEXT_KEY);
|
||||
|
||||
RequestParameter body = requestParameters.body();
|
||||
List<User> user = body != null ? DatabindCodec.mapper().convertValue(body.get(), new TypeReference<List<User>>(){}) : null;
|
||||
|
||||
logger.debug("Parameter user is {}", user);
|
||||
|
||||
apiImpl.createUsersWithArrayInput(user)
|
||||
.onSuccess(apiResponse -> {
|
||||
routingContext.response().setStatusCode(apiResponse.getStatusCode());
|
||||
if (apiResponse.hasData()) {
|
||||
routingContext.json(apiResponse.getData());
|
||||
} else {
|
||||
routingContext.response().end();
|
||||
}
|
||||
})
|
||||
.onFailure(routingContext::fail);
|
||||
}
|
||||
|
||||
private void createUsersWithListInput(RoutingContext routingContext) {
|
||||
logger.info("createUsersWithListInput()");
|
||||
|
||||
// Param extraction
|
||||
RequestParameters requestParameters = routingContext.get(ValidationHandler.REQUEST_CONTEXT_KEY);
|
||||
|
||||
RequestParameter body = requestParameters.body();
|
||||
List<User> user = body != null ? DatabindCodec.mapper().convertValue(body.get(), new TypeReference<List<User>>(){}) : null;
|
||||
|
||||
logger.debug("Parameter user is {}", user);
|
||||
|
||||
apiImpl.createUsersWithListInput(user)
|
||||
.onSuccess(apiResponse -> {
|
||||
routingContext.response().setStatusCode(apiResponse.getStatusCode());
|
||||
if (apiResponse.hasData()) {
|
||||
routingContext.json(apiResponse.getData());
|
||||
} else {
|
||||
routingContext.response().end();
|
||||
}
|
||||
})
|
||||
.onFailure(routingContext::fail);
|
||||
}
|
||||
|
||||
private void deleteUser(RoutingContext routingContext) {
|
||||
logger.info("deleteUser()");
|
||||
|
||||
// Param extraction
|
||||
RequestParameters requestParameters = routingContext.get(ValidationHandler.REQUEST_CONTEXT_KEY);
|
||||
|
||||
String username = requestParameters.pathParameter("username") != null ? requestParameters.pathParameter("username").getString() : null;
|
||||
|
||||
logger.debug("Parameter username is {}", username);
|
||||
|
||||
apiImpl.deleteUser(username)
|
||||
.onSuccess(apiResponse -> {
|
||||
routingContext.response().setStatusCode(apiResponse.getStatusCode());
|
||||
if (apiResponse.hasData()) {
|
||||
routingContext.json(apiResponse.getData());
|
||||
} else {
|
||||
routingContext.response().end();
|
||||
}
|
||||
})
|
||||
.onFailure(routingContext::fail);
|
||||
}
|
||||
|
||||
private void getUserByName(RoutingContext routingContext) {
|
||||
logger.info("getUserByName()");
|
||||
|
||||
// Param extraction
|
||||
RequestParameters requestParameters = routingContext.get(ValidationHandler.REQUEST_CONTEXT_KEY);
|
||||
|
||||
String username = requestParameters.pathParameter("username") != null ? requestParameters.pathParameter("username").getString() : null;
|
||||
|
||||
logger.debug("Parameter username is {}", username);
|
||||
|
||||
apiImpl.getUserByName(username)
|
||||
.onSuccess(apiResponse -> {
|
||||
routingContext.response().setStatusCode(apiResponse.getStatusCode());
|
||||
if (apiResponse.hasData()) {
|
||||
routingContext.json(apiResponse.getData());
|
||||
} else {
|
||||
routingContext.response().end();
|
||||
}
|
||||
})
|
||||
.onFailure(routingContext::fail);
|
||||
}
|
||||
|
||||
private void loginUser(RoutingContext routingContext) {
|
||||
logger.info("loginUser()");
|
||||
|
||||
// Param extraction
|
||||
RequestParameters requestParameters = routingContext.get(ValidationHandler.REQUEST_CONTEXT_KEY);
|
||||
|
||||
String username = requestParameters.queryParameter("username") != null ? requestParameters.queryParameter("username").getString() : null;
|
||||
String password = requestParameters.queryParameter("password") != null ? requestParameters.queryParameter("password").getString() : null;
|
||||
|
||||
logger.debug("Parameter username is {}", username);
|
||||
logger.debug("Parameter password is {}", password);
|
||||
|
||||
apiImpl.loginUser(username, password)
|
||||
.onSuccess(apiResponse -> {
|
||||
routingContext.response().setStatusCode(apiResponse.getStatusCode());
|
||||
if (apiResponse.hasData()) {
|
||||
routingContext.json(apiResponse.getData());
|
||||
} else {
|
||||
routingContext.response().end();
|
||||
}
|
||||
})
|
||||
.onFailure(routingContext::fail);
|
||||
}
|
||||
|
||||
private void logoutUser(RoutingContext routingContext) {
|
||||
logger.info("logoutUser()");
|
||||
|
||||
// Param extraction
|
||||
RequestParameters requestParameters = routingContext.get(ValidationHandler.REQUEST_CONTEXT_KEY);
|
||||
|
||||
|
||||
|
||||
apiImpl.logoutUser()
|
||||
.onSuccess(apiResponse -> {
|
||||
routingContext.response().setStatusCode(apiResponse.getStatusCode());
|
||||
if (apiResponse.hasData()) {
|
||||
routingContext.json(apiResponse.getData());
|
||||
} else {
|
||||
routingContext.response().end();
|
||||
}
|
||||
})
|
||||
.onFailure(routingContext::fail);
|
||||
}
|
||||
|
||||
private void updateUser(RoutingContext routingContext) {
|
||||
logger.info("updateUser()");
|
||||
|
||||
// Param extraction
|
||||
RequestParameters requestParameters = routingContext.get(ValidationHandler.REQUEST_CONTEXT_KEY);
|
||||
|
||||
String username = requestParameters.pathParameter("username") != null ? requestParameters.pathParameter("username").getString() : null;
|
||||
RequestParameter body = requestParameters.body();
|
||||
User user = body != null ? DatabindCodec.mapper().convertValue(body.get(), new TypeReference<User>(){}) : null;
|
||||
|
||||
logger.debug("Parameter username is {}", username);
|
||||
logger.debug("Parameter user is {}", user);
|
||||
|
||||
apiImpl.updateUser(username, user)
|
||||
.onSuccess(apiResponse -> {
|
||||
routingContext.response().setStatusCode(apiResponse.getStatusCode());
|
||||
if (apiResponse.hasData()) {
|
||||
routingContext.json(apiResponse.getData());
|
||||
} else {
|
||||
routingContext.response().end();
|
||||
}
|
||||
})
|
||||
.onFailure(routingContext::fail);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package org.openapitools.vertxweb.server.api;
|
||||
|
||||
import org.openapitools.vertxweb.server.model.User;
|
||||
|
||||
import org.openapitools.vertxweb.server.ApiResponse;
|
||||
|
||||
import io.vertx.core.Future;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import io.vertx.ext.web.handler.impl.HttpStatusException;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
// Implement this class
|
||||
|
||||
public class UserApiImpl implements UserApi {
|
||||
public Future<ApiResponse<Void>> createUser(User user) {
|
||||
return Future.failedFuture(new HttpStatusException(501));
|
||||
}
|
||||
|
||||
public Future<ApiResponse<Void>> createUsersWithArrayInput(List<User> user) {
|
||||
return Future.failedFuture(new HttpStatusException(501));
|
||||
}
|
||||
|
||||
public Future<ApiResponse<Void>> createUsersWithListInput(List<User> user) {
|
||||
return Future.failedFuture(new HttpStatusException(501));
|
||||
}
|
||||
|
||||
public Future<ApiResponse<Void>> deleteUser(String username) {
|
||||
return Future.failedFuture(new HttpStatusException(501));
|
||||
}
|
||||
|
||||
public Future<ApiResponse<User>> getUserByName(String username) {
|
||||
return Future.failedFuture(new HttpStatusException(501));
|
||||
}
|
||||
|
||||
public Future<ApiResponse<String>> loginUser(String username, String password) {
|
||||
return Future.failedFuture(new HttpStatusException(501));
|
||||
}
|
||||
|
||||
public Future<ApiResponse<Void>> logoutUser() {
|
||||
return Future.failedFuture(new HttpStatusException(501));
|
||||
}
|
||||
|
||||
public Future<ApiResponse<Void>> updateUser(String username, User user) {
|
||||
return Future.failedFuture(new HttpStatusException(501));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package org.openapitools.vertxweb.server.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 ");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package org.openapitools.vertxweb.server.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class InlineObject {
|
||||
|
||||
private String name;
|
||||
private String status;
|
||||
|
||||
public InlineObject () {
|
||||
|
||||
}
|
||||
|
||||
public InlineObject (String name, String status) {
|
||||
this.name = name;
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("name")
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("status")
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
InlineObject inlineObject = (InlineObject) o;
|
||||
return Objects.equals(name, inlineObject.name) &&
|
||||
Objects.equals(status, inlineObject.status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name, status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class InlineObject {\n");
|
||||
|
||||
sb.append(" name: ").append(toIndentedString(name)).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 ");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package org.openapitools.vertxweb.server.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.vertx.ext.web.FileUpload;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class InlineObject1 {
|
||||
|
||||
private String additionalMetadata;
|
||||
private FileUpload file;
|
||||
|
||||
public InlineObject1 () {
|
||||
|
||||
}
|
||||
|
||||
public InlineObject1 (String additionalMetadata, FileUpload file) {
|
||||
this.additionalMetadata = additionalMetadata;
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("additionalMetadata")
|
||||
public String getAdditionalMetadata() {
|
||||
return additionalMetadata;
|
||||
}
|
||||
public void setAdditionalMetadata(String additionalMetadata) {
|
||||
this.additionalMetadata = additionalMetadata;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("file")
|
||||
public FileUpload getFile() {
|
||||
return file;
|
||||
}
|
||||
public void setFile(FileUpload file) {
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
InlineObject1 inlineObject1 = (InlineObject1) o;
|
||||
return Objects.equals(additionalMetadata, inlineObject1.additionalMetadata) &&
|
||||
Objects.equals(file, inlineObject1.file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(additionalMetadata, file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class InlineObject1 {\n");
|
||||
|
||||
sb.append(" additionalMetadata: ").append(toIndentedString(additionalMetadata)).append("\n");
|
||||
sb.append(" file: ").append(toIndentedString(file)).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 ");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package org.openapitools.vertxweb.server.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 ");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
package org.openapitools.vertxweb.server.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 ");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
package org.openapitools.vertxweb.server.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.vertxweb.server.model.Category;
|
||||
import org.openapitools.vertxweb.server.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 ");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package org.openapitools.vertxweb.server.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 ");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
package org.openapitools.vertxweb.server.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 ");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,851 @@
|
||||
openapi: 3.0.0
|
||||
info:
|
||||
description: This is a sample server Petstore server. For this sample, you can use
|
||||
the api key `special-key` to test the authorization filters.
|
||||
license:
|
||||
name: Apache-2.0
|
||||
url: https://www.apache.org/licenses/LICENSE-2.0.html
|
||||
title: OpenAPI Petstore
|
||||
version: 1.0.0
|
||||
externalDocs:
|
||||
description: Find out more about Swagger
|
||||
url: http://swagger.io
|
||||
servers:
|
||||
- url: http://petstore.swagger.io/v2
|
||||
tags:
|
||||
- description: Everything about your Pets
|
||||
name: pet
|
||||
- description: Access to Petstore orders
|
||||
name: store
|
||||
- description: Operations about user
|
||||
name: user
|
||||
paths:
|
||||
/pet:
|
||||
post:
|
||||
operationId: addPet
|
||||
requestBody:
|
||||
$ref: '#/components/requestBodies/Pet'
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
description: successful operation
|
||||
"405":
|
||||
description: Invalid input
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write:pets
|
||||
- read:pets
|
||||
summary: Add a new pet to the store
|
||||
tags:
|
||||
- pet
|
||||
x-contentType: application/json
|
||||
x-accepts: application/json
|
||||
put:
|
||||
operationId: updatePet
|
||||
requestBody:
|
||||
$ref: '#/components/requestBodies/Pet'
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
description: successful operation
|
||||
"400":
|
||||
description: Invalid ID supplied
|
||||
"404":
|
||||
description: Pet not found
|
||||
"405":
|
||||
description: Validation exception
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write:pets
|
||||
- read:pets
|
||||
summary: Update an existing pet
|
||||
tags:
|
||||
- pet
|
||||
x-contentType: application/json
|
||||
x-accepts: application/json
|
||||
/pet/findByStatus:
|
||||
get:
|
||||
description: Multiple status values can be provided with comma separated strings
|
||||
operationId: findPetsByStatus
|
||||
parameters:
|
||||
- description: Status values that need to be considered for filter
|
||||
explode: false
|
||||
in: query
|
||||
name: status
|
||||
required: true
|
||||
schema:
|
||||
items:
|
||||
default: available
|
||||
enum:
|
||||
- available
|
||||
- pending
|
||||
- sold
|
||||
type: string
|
||||
type: array
|
||||
style: form
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
items:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
type: array
|
||||
application/json:
|
||||
schema:
|
||||
items:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
type: array
|
||||
description: successful operation
|
||||
"400":
|
||||
description: Invalid status value
|
||||
security:
|
||||
- petstore_auth:
|
||||
- read:pets
|
||||
summary: Finds Pets by status
|
||||
tags:
|
||||
- pet
|
||||
x-accepts: application/json
|
||||
/pet/findByTags:
|
||||
get:
|
||||
deprecated: true
|
||||
description: Multiple tags can be provided with comma separated strings. Use
|
||||
tag1, tag2, tag3 for testing.
|
||||
operationId: findPetsByTags
|
||||
parameters:
|
||||
- description: Tags to filter by
|
||||
explode: false
|
||||
in: query
|
||||
name: tags
|
||||
required: true
|
||||
schema:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
style: form
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
items:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
type: array
|
||||
application/json:
|
||||
schema:
|
||||
items:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
type: array
|
||||
description: successful operation
|
||||
"400":
|
||||
description: Invalid tag value
|
||||
security:
|
||||
- petstore_auth:
|
||||
- read:pets
|
||||
summary: Finds Pets by tags
|
||||
tags:
|
||||
- pet
|
||||
x-accepts: application/json
|
||||
/pet/{petId}:
|
||||
delete:
|
||||
operationId: deletePet
|
||||
parameters:
|
||||
- explode: false
|
||||
in: header
|
||||
name: api_key
|
||||
required: false
|
||||
schema:
|
||||
type: string
|
||||
style: simple
|
||||
- description: Pet id to delete
|
||||
explode: false
|
||||
in: path
|
||||
name: petId
|
||||
required: true
|
||||
schema:
|
||||
format: int64
|
||||
type: integer
|
||||
style: simple
|
||||
responses:
|
||||
"400":
|
||||
description: Invalid pet value
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write:pets
|
||||
- read:pets
|
||||
summary: Deletes a pet
|
||||
tags:
|
||||
- pet
|
||||
x-accepts: application/json
|
||||
get:
|
||||
description: Returns a single pet
|
||||
operationId: getPetById
|
||||
parameters:
|
||||
- description: ID of pet to return
|
||||
explode: false
|
||||
in: path
|
||||
name: petId
|
||||
required: true
|
||||
schema:
|
||||
format: int64
|
||||
type: integer
|
||||
style: simple
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
description: successful operation
|
||||
"400":
|
||||
description: Invalid ID supplied
|
||||
"404":
|
||||
description: Pet not found
|
||||
security:
|
||||
- api_key: []
|
||||
summary: Find pet by ID
|
||||
tags:
|
||||
- pet
|
||||
x-accepts: application/json
|
||||
post:
|
||||
operationId: updatePetWithForm
|
||||
parameters:
|
||||
- description: ID of pet that needs to be updated
|
||||
explode: false
|
||||
in: path
|
||||
name: petId
|
||||
required: true
|
||||
schema:
|
||||
format: int64
|
||||
type: integer
|
||||
style: simple
|
||||
requestBody:
|
||||
$ref: '#/components/requestBodies/inline_object'
|
||||
content:
|
||||
application/x-www-form-urlencoded:
|
||||
schema:
|
||||
properties:
|
||||
name:
|
||||
description: Updated name of the pet
|
||||
type: string
|
||||
status:
|
||||
description: Updated status of the pet
|
||||
type: string
|
||||
type: object
|
||||
responses:
|
||||
"405":
|
||||
description: Invalid input
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write:pets
|
||||
- read:pets
|
||||
summary: Updates a pet in the store with form data
|
||||
tags:
|
||||
- pet
|
||||
x-contentType: application/x-www-form-urlencoded
|
||||
x-accepts: application/json
|
||||
/pet/{petId}/uploadImage:
|
||||
post:
|
||||
operationId: uploadFile
|
||||
parameters:
|
||||
- description: ID of pet to update
|
||||
explode: false
|
||||
in: path
|
||||
name: petId
|
||||
required: true
|
||||
schema:
|
||||
format: int64
|
||||
type: integer
|
||||
style: simple
|
||||
requestBody:
|
||||
$ref: '#/components/requestBodies/inline_object_1'
|
||||
content:
|
||||
multipart/form-data:
|
||||
schema:
|
||||
properties:
|
||||
additionalMetadata:
|
||||
description: Additional data to pass to server
|
||||
type: string
|
||||
file:
|
||||
description: file to upload
|
||||
format: binary
|
||||
type: string
|
||||
type: object
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ApiResponse'
|
||||
description: successful operation
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write:pets
|
||||
- read:pets
|
||||
summary: uploads an image
|
||||
tags:
|
||||
- pet
|
||||
x-contentType: multipart/form-data
|
||||
x-accepts: application/json
|
||||
/store/inventory:
|
||||
get:
|
||||
description: Returns a map of status codes to quantities
|
||||
operationId: getInventory
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
additionalProperties:
|
||||
format: int32
|
||||
type: integer
|
||||
type: object
|
||||
description: successful operation
|
||||
security:
|
||||
- api_key: []
|
||||
summary: Returns pet inventories by status
|
||||
tags:
|
||||
- store
|
||||
x-accepts: application/json
|
||||
/store/order:
|
||||
post:
|
||||
operationId: placeOrder
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Order'
|
||||
description: order placed for purchasing the pet
|
||||
required: true
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Order'
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Order'
|
||||
description: successful operation
|
||||
"400":
|
||||
description: Invalid Order
|
||||
summary: Place an order for a pet
|
||||
tags:
|
||||
- store
|
||||
x-contentType: application/json
|
||||
x-accepts: application/json
|
||||
/store/order/{orderId}:
|
||||
delete:
|
||||
description: For valid response try integer IDs with value < 1000. Anything
|
||||
above 1000 or nonintegers will generate API errors
|
||||
operationId: deleteOrder
|
||||
parameters:
|
||||
- description: ID of the order that needs to be deleted
|
||||
explode: false
|
||||
in: path
|
||||
name: orderId
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
style: simple
|
||||
responses:
|
||||
"400":
|
||||
description: Invalid ID supplied
|
||||
"404":
|
||||
description: Order not found
|
||||
summary: Delete purchase order by ID
|
||||
tags:
|
||||
- store
|
||||
x-accepts: application/json
|
||||
get:
|
||||
description: For valid response try integer IDs with value <= 5 or > 10. Other
|
||||
values will generated exceptions
|
||||
operationId: getOrderById
|
||||
parameters:
|
||||
- description: ID of pet that needs to be fetched
|
||||
explode: false
|
||||
in: path
|
||||
name: orderId
|
||||
required: true
|
||||
schema:
|
||||
format: int64
|
||||
maximum: 5
|
||||
minimum: 1
|
||||
type: integer
|
||||
style: simple
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Order'
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Order'
|
||||
description: successful operation
|
||||
"400":
|
||||
description: Invalid ID supplied
|
||||
"404":
|
||||
description: Order not found
|
||||
summary: Find purchase order by ID
|
||||
tags:
|
||||
- store
|
||||
x-accepts: application/json
|
||||
/user:
|
||||
post:
|
||||
description: This can only be done by the logged in user.
|
||||
operationId: createUser
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/User'
|
||||
description: Created user object
|
||||
required: true
|
||||
responses:
|
||||
default:
|
||||
description: successful operation
|
||||
security:
|
||||
- api_key: []
|
||||
summary: Create user
|
||||
tags:
|
||||
- user
|
||||
x-contentType: application/json
|
||||
x-accepts: application/json
|
||||
/user/createWithArray:
|
||||
post:
|
||||
operationId: createUsersWithArrayInput
|
||||
requestBody:
|
||||
$ref: '#/components/requestBodies/UserArray'
|
||||
responses:
|
||||
default:
|
||||
description: successful operation
|
||||
security:
|
||||
- api_key: []
|
||||
summary: Creates list of users with given input array
|
||||
tags:
|
||||
- user
|
||||
x-contentType: application/json
|
||||
x-accepts: application/json
|
||||
/user/createWithList:
|
||||
post:
|
||||
operationId: createUsersWithListInput
|
||||
requestBody:
|
||||
$ref: '#/components/requestBodies/UserArray'
|
||||
responses:
|
||||
default:
|
||||
description: successful operation
|
||||
security:
|
||||
- api_key: []
|
||||
summary: Creates list of users with given input array
|
||||
tags:
|
||||
- user
|
||||
x-contentType: application/json
|
||||
x-accepts: application/json
|
||||
/user/login:
|
||||
get:
|
||||
operationId: loginUser
|
||||
parameters:
|
||||
- description: The user name for login
|
||||
explode: true
|
||||
in: query
|
||||
name: username
|
||||
required: true
|
||||
schema:
|
||||
pattern: ^[a-zA-Z0-9]+[a-zA-Z0-9\.\-_]*[a-zA-Z0-9]+$
|
||||
type: string
|
||||
style: form
|
||||
- description: The password for login in clear text
|
||||
explode: true
|
||||
in: query
|
||||
name: password
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
style: form
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
type: string
|
||||
application/json:
|
||||
schema:
|
||||
type: string
|
||||
description: successful operation
|
||||
headers:
|
||||
Set-Cookie:
|
||||
description: Cookie authentication key for use with the `api_key` apiKey
|
||||
authentication.
|
||||
explode: false
|
||||
schema:
|
||||
example: AUTH_KEY=abcde12345; Path=/; HttpOnly
|
||||
type: string
|
||||
style: simple
|
||||
X-Rate-Limit:
|
||||
description: calls per hour allowed by the user
|
||||
explode: false
|
||||
schema:
|
||||
format: int32
|
||||
type: integer
|
||||
style: simple
|
||||
X-Expires-After:
|
||||
description: date in UTC when toekn expires
|
||||
explode: false
|
||||
schema:
|
||||
format: date-time
|
||||
type: string
|
||||
style: simple
|
||||
"400":
|
||||
description: Invalid username/password supplied
|
||||
summary: Logs user into the system
|
||||
tags:
|
||||
- user
|
||||
x-accepts: application/json
|
||||
/user/logout:
|
||||
get:
|
||||
operationId: logoutUser
|
||||
responses:
|
||||
default:
|
||||
description: successful operation
|
||||
security:
|
||||
- api_key: []
|
||||
summary: Logs out current logged in user session
|
||||
tags:
|
||||
- user
|
||||
x-accepts: application/json
|
||||
/user/{username}:
|
||||
delete:
|
||||
description: This can only be done by the logged in user.
|
||||
operationId: deleteUser
|
||||
parameters:
|
||||
- description: The name that needs to be deleted
|
||||
explode: false
|
||||
in: path
|
||||
name: username
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
style: simple
|
||||
responses:
|
||||
"400":
|
||||
description: Invalid username supplied
|
||||
"404":
|
||||
description: User not found
|
||||
security:
|
||||
- api_key: []
|
||||
summary: Delete user
|
||||
tags:
|
||||
- user
|
||||
x-accepts: application/json
|
||||
get:
|
||||
operationId: getUserByName
|
||||
parameters:
|
||||
- description: The name that needs to be fetched. Use user1 for testing.
|
||||
explode: false
|
||||
in: path
|
||||
name: username
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
style: simple
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/User'
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/User'
|
||||
description: successful operation
|
||||
"400":
|
||||
description: Invalid username supplied
|
||||
"404":
|
||||
description: User not found
|
||||
summary: Get user by user name
|
||||
tags:
|
||||
- user
|
||||
x-accepts: application/json
|
||||
put:
|
||||
description: This can only be done by the logged in user.
|
||||
operationId: updateUser
|
||||
parameters:
|
||||
- description: name that need to be deleted
|
||||
explode: false
|
||||
in: path
|
||||
name: username
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
style: simple
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/User'
|
||||
description: Updated user object
|
||||
required: true
|
||||
responses:
|
||||
"400":
|
||||
description: Invalid user supplied
|
||||
"404":
|
||||
description: User not found
|
||||
security:
|
||||
- api_key: []
|
||||
summary: Updated user
|
||||
tags:
|
||||
- user
|
||||
x-contentType: application/json
|
||||
x-accepts: application/json
|
||||
components:
|
||||
requestBodies:
|
||||
UserArray:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
items:
|
||||
$ref: '#/components/schemas/User'
|
||||
type: array
|
||||
description: List of user object
|
||||
required: true
|
||||
Pet:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
description: Pet object that needs to be added to the store
|
||||
required: true
|
||||
inline_object:
|
||||
content:
|
||||
application/x-www-form-urlencoded:
|
||||
schema:
|
||||
$ref: '#/components/schemas/inline_object'
|
||||
inline_object_1:
|
||||
content:
|
||||
multipart/form-data:
|
||||
schema:
|
||||
$ref: '#/components/schemas/inline_object_1'
|
||||
schemas:
|
||||
Order:
|
||||
description: An order for a pets from the pet store
|
||||
example:
|
||||
petId: 6
|
||||
quantity: 1
|
||||
id: 0
|
||||
shipDate: 2000-01-23T04:56:07.000+00:00
|
||||
complete: false
|
||||
status: placed
|
||||
properties:
|
||||
id:
|
||||
format: int64
|
||||
type: integer
|
||||
petId:
|
||||
format: int64
|
||||
type: integer
|
||||
quantity:
|
||||
format: int32
|
||||
type: integer
|
||||
shipDate:
|
||||
format: date-time
|
||||
type: string
|
||||
status:
|
||||
description: Order Status
|
||||
enum:
|
||||
- placed
|
||||
- approved
|
||||
- delivered
|
||||
type: string
|
||||
complete:
|
||||
default: false
|
||||
type: boolean
|
||||
title: Pet Order
|
||||
type: object
|
||||
xml:
|
||||
name: Order
|
||||
Category:
|
||||
description: A category for a pet
|
||||
example:
|
||||
name: name
|
||||
id: 6
|
||||
properties:
|
||||
id:
|
||||
format: int64
|
||||
type: integer
|
||||
name:
|
||||
pattern: ^[a-zA-Z0-9]+[a-zA-Z0-9\.\-_]*[a-zA-Z0-9]+$
|
||||
type: string
|
||||
title: Pet category
|
||||
type: object
|
||||
xml:
|
||||
name: Category
|
||||
User:
|
||||
description: A User who is purchasing from the pet store
|
||||
example:
|
||||
firstName: firstName
|
||||
lastName: lastName
|
||||
password: password
|
||||
userStatus: 6
|
||||
phone: phone
|
||||
id: 0
|
||||
email: email
|
||||
username: username
|
||||
properties:
|
||||
id:
|
||||
format: int64
|
||||
type: integer
|
||||
username:
|
||||
type: string
|
||||
firstName:
|
||||
type: string
|
||||
lastName:
|
||||
type: string
|
||||
email:
|
||||
type: string
|
||||
password:
|
||||
type: string
|
||||
phone:
|
||||
type: string
|
||||
userStatus:
|
||||
description: User Status
|
||||
format: int32
|
||||
type: integer
|
||||
title: a User
|
||||
type: object
|
||||
xml:
|
||||
name: User
|
||||
Tag:
|
||||
description: A tag for a pet
|
||||
example:
|
||||
name: name
|
||||
id: 1
|
||||
properties:
|
||||
id:
|
||||
format: int64
|
||||
type: integer
|
||||
name:
|
||||
type: string
|
||||
title: Pet Tag
|
||||
type: object
|
||||
xml:
|
||||
name: Tag
|
||||
Pet:
|
||||
description: A pet for sale in the pet store
|
||||
example:
|
||||
photoUrls:
|
||||
- photoUrls
|
||||
- photoUrls
|
||||
name: doggie
|
||||
id: 0
|
||||
category:
|
||||
name: name
|
||||
id: 6
|
||||
tags:
|
||||
- name: name
|
||||
id: 1
|
||||
- name: name
|
||||
id: 1
|
||||
status: available
|
||||
properties:
|
||||
id:
|
||||
format: int64
|
||||
type: integer
|
||||
category:
|
||||
$ref: '#/components/schemas/Category'
|
||||
name:
|
||||
example: doggie
|
||||
type: string
|
||||
photoUrls:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
xml:
|
||||
name: photoUrl
|
||||
wrapped: true
|
||||
tags:
|
||||
items:
|
||||
$ref: '#/components/schemas/Tag'
|
||||
type: array
|
||||
xml:
|
||||
name: tag
|
||||
wrapped: true
|
||||
status:
|
||||
description: pet status in the store
|
||||
enum:
|
||||
- available
|
||||
- pending
|
||||
- sold
|
||||
type: string
|
||||
required:
|
||||
- name
|
||||
- photoUrls
|
||||
title: a Pet
|
||||
type: object
|
||||
xml:
|
||||
name: Pet
|
||||
ApiResponse:
|
||||
description: Describes the result of uploading an image resource
|
||||
example:
|
||||
code: 0
|
||||
type: type
|
||||
message: message
|
||||
properties:
|
||||
code:
|
||||
format: int32
|
||||
type: integer
|
||||
type:
|
||||
type: string
|
||||
message:
|
||||
type: string
|
||||
title: An uploaded response
|
||||
type: object
|
||||
inline_object:
|
||||
properties:
|
||||
name:
|
||||
description: Updated name of the pet
|
||||
type: string
|
||||
status:
|
||||
description: Updated status of the pet
|
||||
type: string
|
||||
type: object
|
||||
inline_object_1:
|
||||
properties:
|
||||
additionalMetadata:
|
||||
description: Additional data to pass to server
|
||||
type: string
|
||||
file:
|
||||
description: file to upload
|
||||
format: binary
|
||||
type: string
|
||||
type: object
|
||||
securitySchemes:
|
||||
petstore_auth:
|
||||
flows:
|
||||
implicit:
|
||||
authorizationUrl: http://petstore.swagger.io/api/oauth/dialog
|
||||
scopes:
|
||||
write:pets: modify pets in your account
|
||||
read:pets: read your pets
|
||||
type: oauth2
|
||||
api_key:
|
||||
in: header
|
||||
name: api_key
|
||||
type: apiKey
|
||||
Reference in New Issue
Block a user