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));
}
use of io.swagger.v3.oas.models.Operation in project vertx-web by vert-x3.
the class OpenAPI3ValidationTest method testDefaultIntQueryParameter.
@Test
public void testDefaultIntQueryParameter() throws Exception {
Operation op = testSpec.getPaths().get("/queryTests/defaultInt").getGet();
OpenAPI3RequestValidationHandler validationHandler = new OpenAPI3RequestValidationHandlerImpl(op, op.getParameters(), testSpec);
loadHandlers("/queryTests/defaultInt", HttpMethod.GET, false, validationHandler, (routingContext) -> {
RequestParameters params = routingContext.get("parsedParameters");
RequestParameter requestParameter = params.queryParameter("parameter");
assertTrue(requestParameter.isInteger());
routingContext.response().setStatusMessage(requestParameter.toString()).end();
});
testRequest(HttpMethod.GET, "/queryTests/defaultInt", 200, "1");
}
use of io.swagger.v3.oas.models.Operation in project vertx-web by vert-x3.
the class OpenAPI3ValidationTest method testDefaultStringQueryParameter.
@Test
public void testDefaultStringQueryParameter() throws Exception {
Operation op = testSpec.getPaths().get("/queryTests/defaultString").getGet();
OpenAPI3RequestValidationHandler validationHandler = new OpenAPI3RequestValidationHandlerImpl(op, op.getParameters(), testSpec);
loadHandlers("/queryTests/defaultString", HttpMethod.GET, false, validationHandler, (routingContext) -> {
RequestParameters params = routingContext.get("parsedParameters");
routingContext.response().setStatusMessage(params.queryParameter("parameter").getString()).end();
});
testRequest(HttpMethod.GET, "/queryTests/defaultString", 200, "aString");
}
use of io.swagger.v3.oas.models.Operation in project vertx-web by vert-x3.
the class OpenAPI3ValidationTest method testFormArrayParameter.
@Test
public void testFormArrayParameter() throws Exception {
Operation op = testSpec.getPaths().get("/formTests/arraytest").getPost();
if (op.getParameters() == null)
op.setParameters(new ArrayList<>());
OpenAPI3RequestValidationHandler validationHandler = new OpenAPI3RequestValidationHandlerImpl(op, op.getParameters(), testSpec);
loadHandlers("/formTests/arraytest", HttpMethod.POST, false, validationHandler, (routingContext) -> {
RequestParameters params = routingContext.get("parsedParameters");
List<String> result = new ArrayList<>();
for (RequestParameter r : params.formParameter("values").getArray()) result.add(r.getInteger().toString());
routingContext.response().setStatusMessage(params.formParameter("id").getString() + serializeInCSVStringArray(result)).end();
});
String id = "anId";
List<String> valuesArray = new ArrayList<>();
for (int i = 0; i < 4; i++) valuesArray.add(getSuccessSample(ParameterType.INT).getInteger().toString());
String values = serializeInCSVStringArray(valuesArray);
MultiMap form = MultiMap.caseInsensitiveMultiMap();
form.add("id", id);
form.add("values", values);
testRequestWithForm(HttpMethod.POST, "/formTests/arraytest", FormType.FORM_URLENCODED, form, 200, id + values);
}
use of io.swagger.v3.oas.models.Operation in project cas by apereo.
the class LoggingConfigurationEndpoint method updateLoggerLevel.
/**
* Looks up the logger in the logger factory,
* and attempts to find the real logger instance
* based on the underlying logging framework
* and retrieve the logger object. Then, updates the level.
* This functionality at this point is heavily dependant
* on the log4j API.
*
* @param loggerName the logger name
* @param loggerLevel the logger level
* @param additive the additive nature of the logger
*/
@WriteOperation
@Operation(summary = "Update logger level for a logger name", parameters = { @Parameter(name = "loggerName", required = true), @Parameter(name = "loggerLevel", required = true), @Parameter(name = "additive") })
public void updateLoggerLevel(@Selector final String loggerName, final String loggerLevel, final boolean additive) {
val loggerConfigs = getLoggerConfigurations();
loggerConfigs.stream().filter(cfg -> cfg.getName().equals(loggerName)).forEachOrdered(cfg -> {
cfg.setLevel(Level.getLevel(loggerLevel));
cfg.setAdditive(additive);
});
this.loggerContext.updateLoggers();
}
Aggregations