use of io.swagger.v3.oas.annotations.Parameter in project cxf by apache.
the class JaxRs2Extension method extractParameters.
@Override
public ResolvedParameter extractParameters(final List<Annotation> annotations, final Type type, final Set<Type> typesToSkip, final Components components, final Consumes classConsumes, final Consumes methodConsumes, final boolean includeRequestBody, final JsonView jsonViewAnnotation, final Iterator<OpenAPIExtension> chain) {
if (shouldIgnoreType(type, typesToSkip)) {
return new ResolvedParameter();
}
List<Parameter> parameters = annotations.stream().filter(annotation -> annotation instanceof MatrixParam).map(annotation -> {
MatrixParam param = (MatrixParam) annotation;
Parameter mp = new PathParameter().name(param.value());
mp.setStyle(Parameter.StyleEnum.MATRIX);
ResolvedSchema resolvedSchema = ModelConverters.getInstance().readAllAsResolvedSchema(type);
if (resolvedSchema != null) {
mp.setSchema(resolvedSchema.schema);
}
applyBeanValidatorAnnotations(mp, annotations);
return mp;
}).collect(Collectors.toList());
// Only call down to the other items in the chain if no parameters were produced
if (parameters.isEmpty()) {
return super.extractParameters(annotations, type, typesToSkip, components, classConsumes, methodConsumes, includeRequestBody, jsonViewAnnotation, chain);
}
ResolvedParameter resolved = new ResolvedParameter();
resolved.parameters = parameters;
return resolved;
}
use of io.swagger.v3.oas.annotations.Parameter in project vertx-web by vert-x3.
the class OpenAPI3ValidationTest method testQueryParameterArrayExploded.
@Test
public void testQueryParameterArrayExploded() throws Exception {
Operation op = testSpec.getPaths().get("/queryTests/arrayTests/formExploded").getGet();
OpenAPI3RequestValidationHandler validationHandler = new OpenAPI3RequestValidationHandlerImpl(op, op.getParameters(), testSpec);
loadHandlers("/queryTests/arrayTests/formExploded", HttpMethod.GET, false, validationHandler, (routingContext) -> {
RequestParameters params = routingContext.get("parsedParameters");
List<String> result = new ArrayList<>();
for (RequestParameter r : params.queryParameter("parameter").getArray()) result.add(r.getInteger().toString());
routingContext.response().setStatusMessage(serializeInCSVStringArray(result)).end();
});
List<String> values = new ArrayList<>();
values.add("4");
values.add("2");
values.add("26");
StringBuilder stringBuilder = new StringBuilder();
for (String s : values) {
stringBuilder.append("parameter=" + s + "&");
}
stringBuilder.deleteCharAt(stringBuilder.length() - 1);
testRequest(HttpMethod.GET, "/queryTests/arrayTests/formExploded?" + stringBuilder, 200, serializeInCSVStringArray(values));
}
use of io.swagger.v3.oas.annotations.Parameter in project vertx-web by vert-x3.
the class OpenAPI3ValidationTest method testAllowEmptyValueQueryParameter.
@Test
public void testAllowEmptyValueQueryParameter() 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();
});
// Empty value should not be overwritten
testRequest(HttpMethod.GET, "/queryTests/defaultString?parameter=", 200, "");
}
use of io.swagger.v3.oas.annotations.Parameter in project vertx-web by vert-x3.
the class OpenAPI3ValidationTest method testAllOfQueryParam.
@Test
public void testAllOfQueryParam() throws Exception {
Operation op = testSpec.getPaths().get("/queryTests/allOfTest").getGet();
OpenAPI3RequestValidationHandler validationHandler = new OpenAPI3RequestValidationHandlerImpl(op, op.getParameters(), testSpec);
loadHandlers("/queryTests/allOfTest", HttpMethod.GET, false, validationHandler, (routingContext) -> {
RequestParameters params = routingContext.get("parsedParameters");
routingContext.response().setStatusMessage(params.queryParameter("parameter").getObjectValue("a").getInteger().toString() + params.queryParameter("parameter").getObjectValue("b").getBoolean().toString()).end();
});
String a = "5";
String b = "false";
String parameter = "parameter=a," + a + ",b," + b;
testRequest(HttpMethod.GET, "/queryTests/allOfTest?" + parameter, 200, a + b);
}
use of io.swagger.v3.oas.annotations.Parameter in project vertx-web by vert-x3.
the class OpenAPI3ValidationTest method testQueryParameterArrayDefaultStyleFailure.
@Test
public void testQueryParameterArrayDefaultStyleFailure() throws Exception {
Operation op = testSpec.getPaths().get("/queryTests/arrayTests/default").getGet();
OpenAPI3RequestValidationHandler validationHandler = new OpenAPI3RequestValidationHandlerImpl(op, op.getParameters(), testSpec);
loadHandlers("/queryTests/arrayTests/default", HttpMethod.GET, true, validationHandler, (routingContext) -> {
routingContext.response().setStatusMessage("ok").end();
});
List<String> values = new ArrayList<>();
values.add("4");
// multipleOf: 2
values.add("1");
values.add("26");
testRequest(HttpMethod.GET, "/queryTests/arrayTests/default?parameter=" + serializeInCSVStringArray(values), 400, errorMessage(ValidationException.ErrorType.NO_MATCH));
}
Aggregations