Search in sources :

Example 6 with Parameter

use of io.swagger.v3.oas.annotations.Parameter in project vertx-web by vert-x3.

the class OpenAPI3ValidationTest method testDefaultFloatQueryParameter.

@Test
public void testDefaultFloatQueryParameter() throws Exception {
    Operation op = testSpec.getPaths().get("/queryTests/defaultFloat").getGet();
    OpenAPI3RequestValidationHandler validationHandler = new OpenAPI3RequestValidationHandlerImpl(op, op.getParameters(), testSpec);
    loadHandlers("/queryTests/defaultFloat", HttpMethod.GET, false, validationHandler, (routingContext) -> {
        RequestParameters params = routingContext.get("parsedParameters");
        RequestParameter requestParameter = params.queryParameter("parameter");
        assertTrue(requestParameter.isFloat());
        routingContext.response().setStatusMessage(requestParameter.toString()).end();
    });
    testRequest(HttpMethod.GET, "/queryTests/defaultFloat", 200, "1.0");
}
Also used : OpenAPI3RequestValidationHandlerImpl(io.vertx.ext.web.api.contract.openapi3.impl.OpenAPI3RequestValidationHandlerImpl) RequestParameter(io.vertx.ext.web.api.RequestParameter) Operation(io.swagger.v3.oas.models.Operation) RequestParameters(io.vertx.ext.web.api.RequestParameters) Test(org.junit.Test)

Example 7 with Parameter

use of io.swagger.v3.oas.annotations.Parameter in project vertx-web by vert-x3.

the class OpenAPI3ValidationTest method testQueryParameterAnyOf.

@Test
public void testQueryParameterAnyOf() throws Exception {
    Operation op = testSpec.getPaths().get("/queryTests/anyOfTest").getGet();
    OpenAPI3RequestValidationHandler validationHandler = new OpenAPI3RequestValidationHandlerImpl(op, op.getParameters(), testSpec);
    loadHandlers("/queryTests/anyOfTest", HttpMethod.GET, false, validationHandler, (routingContext) -> {
        RequestParameters params = routingContext.get("parsedParameters");
        routingContext.response().setStatusMessage(params.queryParameter("parameter").getBoolean().toString()).end();
    });
    testRequest(HttpMethod.GET, "/queryTests/anyOfTest?parameter=true", 200, "true");
}
Also used : OpenAPI3RequestValidationHandlerImpl(io.vertx.ext.web.api.contract.openapi3.impl.OpenAPI3RequestValidationHandlerImpl) Operation(io.swagger.v3.oas.models.Operation) RequestParameters(io.vertx.ext.web.api.RequestParameters) Test(org.junit.Test)

Example 8 with Parameter

use of io.swagger.v3.oas.annotations.Parameter 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");
}
Also used : OpenAPI3RequestValidationHandlerImpl(io.vertx.ext.web.api.contract.openapi3.impl.OpenAPI3RequestValidationHandlerImpl) RequestParameter(io.vertx.ext.web.api.RequestParameter) Operation(io.swagger.v3.oas.models.Operation) RequestParameters(io.vertx.ext.web.api.RequestParameters) Test(org.junit.Test)

Example 9 with Parameter

use of io.swagger.v3.oas.annotations.Parameter 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");
}
Also used : OpenAPI3RequestValidationHandlerImpl(io.vertx.ext.web.api.contract.openapi3.impl.OpenAPI3RequestValidationHandlerImpl) RequestParameter(io.vertx.ext.web.api.RequestParameter) Operation(io.swagger.v3.oas.models.Operation) RequestParameters(io.vertx.ext.web.api.RequestParameters) Test(org.junit.Test)

Example 10 with Parameter

use of io.swagger.v3.oas.annotations.Parameter 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");
}
Also used : OpenAPI3RequestValidationHandlerImpl(io.vertx.ext.web.api.contract.openapi3.impl.OpenAPI3RequestValidationHandlerImpl) Operation(io.swagger.v3.oas.models.Operation) RequestParameters(io.vertx.ext.web.api.RequestParameters) Test(org.junit.Test)

Aggregations

Operation (io.swagger.v3.oas.models.Operation)15 OpenAPI3RequestValidationHandlerImpl (io.vertx.ext.web.api.contract.openapi3.impl.OpenAPI3RequestValidationHandlerImpl)14 Test (org.junit.Test)14 RequestParameters (io.vertx.ext.web.api.RequestParameters)11 Parameter (io.swagger.v3.oas.models.parameters.Parameter)5 RequestParameter (io.vertx.ext.web.api.RequestParameter)5 ArrayList (java.util.ArrayList)5 Map (java.util.Map)4 HashMap (java.util.HashMap)3 List (java.util.List)3 Schema (io.swagger.v3.oas.models.media.Schema)2 ApiResponse (io.swagger.v3.oas.models.responses.ApiResponse)2 Optional (java.util.Optional)2 Collectors (java.util.stream.Collectors)2 JsonView (com.fasterxml.jackson.annotation.JsonView)1 ModelConverters (io.swagger.v3.core.converter.ModelConverters)1 ResolvedSchema (io.swagger.v3.core.converter.ResolvedSchema)1 ResolvedParameter (io.swagger.v3.jaxrs2.ResolvedParameter)1 AbstractOpenAPIExtension (io.swagger.v3.jaxrs2.ext.AbstractOpenAPIExtension)1 OpenAPIExtension (io.swagger.v3.jaxrs2.ext.OpenAPIExtension)1