use of io.swagger.v3.oas.models.Operation in project vertx-web by vert-x3.
the class OpenAPI3ValidationTest method testDefaultDoubleQueryParameter.
@Test
public void testDefaultDoubleQueryParameter() throws Exception {
Operation op = testSpec.getPaths().get("/queryTests/defaultDouble").getGet();
OpenAPI3RequestValidationHandler validationHandler = new OpenAPI3RequestValidationHandlerImpl(op, op.getParameters(), testSpec);
loadHandlers("/queryTests/defaultDouble", HttpMethod.GET, false, validationHandler, (routingContext) -> {
RequestParameters params = routingContext.get("parsedParameters");
RequestParameter requestParameter = params.queryParameter("parameter");
assertTrue(requestParameter.isDouble());
routingContext.response().setStatusMessage(requestParameter.toString()).end();
});
testRequest(HttpMethod.GET, "/queryTests/defaultDouble", 200, "1.0");
}
use of io.swagger.v3.oas.models.Operation in project vertx-web by vert-x3.
the class OpenAPI3ValidationTest method testCircularReferences.
@Test
@Ignore
public void testCircularReferences() throws Exception {
Operation op = testSpec.getPaths().get("/circularReferences").getPost();
OpenAPI3RequestValidationHandler validationHandler = new OpenAPI3RequestValidationHandlerImpl(op, op.getParameters(), testSpec);
loadHandlers("/circularReferences", HttpMethod.POST, false, validationHandler, (routingContext) -> {
RequestParameters params = routingContext.get("parsedParameters");
routingContext.response().setStatusCode(200).setStatusMessage("OK").putHeader("Content-Type", "application/json").end(params.body().getJsonObject().encode());
});
JsonObject obj = new JsonObject("{\n" + " \"a\": {\n" + " \"a\": [\n" + " {\n" + " \"a\": {\n" + " \"a\": []\n" + " },\n" + " \"b\": \"hi\",\n" + " \"c\": 10\n" + " }\n" + " ]\n" + " },\n" + " \"b\": \"hello\",\n" + " \"c\": 6\n" + "}");
testRequestWithJSON(HttpMethod.POST, "/circularReferences", obj, 200, "OK", obj);
}
use of io.swagger.v3.oas.models.Operation in project vertx-web by vert-x3.
the class OpenAPI3ValidationTest method testLoadSampleOperationObject.
@Test
public void testLoadSampleOperationObject() throws Exception {
Operation op = testSpec.getPaths().get("/pets").getGet();
OpenAPI3RequestValidationHandler validationHandler = new OpenAPI3RequestValidationHandlerImpl(op, op.getParameters(), testSpec);
router.get("/pets").handler(validationHandler);
router.get("/pets").handler(routingContext -> {
routingContext.response().setStatusMessage("ok").end();
}).failureHandler(generateFailureHandler(false));
testRequest(HttpMethod.GET, "/pets", 200, "ok");
}
use of io.swagger.v3.oas.models.Operation in project vertx-web by vert-x3.
the class OpenAPI3ValidationTest method testPathParameter.
@Test
public void testPathParameter() throws Exception {
Operation op = testSpec.getPaths().get("/pets/{petId}").getGet();
OpenAPI3RequestValidationHandler validationHandler = new OpenAPI3RequestValidationHandlerImpl(op, op.getParameters(), testSpec);
loadHandlers("/pets/:petId", HttpMethod.GET, false, validationHandler, (routingContext) -> {
RequestParameters params = routingContext.get("parsedParameters");
routingContext.response().setStatusMessage(params.pathParameter("petId").getInteger().toString()).end();
});
testRequest(HttpMethod.GET, "/pets/3", 200, "3");
}
use of io.swagger.v3.oas.models.Operation in project vertx-web by vert-x3.
the class OpenAPI3ValidationTest method testPathParameterFailure.
@Test
public void testPathParameterFailure() throws Exception {
Operation op = testSpec.getPaths().get("/pets/{petId}").getGet();
OpenAPI3RequestValidationHandler validationHandler = new OpenAPI3RequestValidationHandlerImpl(op, op.getParameters(), testSpec);
loadHandlers("/pets/:petId", HttpMethod.GET, true, validationHandler, (routingContext) -> {
routingContext.response().setStatusMessage("ok").end();
});
testRequest(HttpMethod.GET, "/pets/three", 400, errorMessage(ValidationException.ErrorType.NO_MATCH));
}
Aggregations