Search in sources :

Example 36 with Operation

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

the class OpenAPI3ValidationTest method testAllOfQueryParamWithDefault.

@Test
public void testAllOfQueryParamWithDefault() 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 = "";
    String parameter = "parameter=a," + a + ",b," + b;
    testRequest(HttpMethod.GET, "/queryTests/allOfTest?" + parameter, 200, a + "false");
}
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 37 with Operation

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

the class OpenAPI3ValidationTest method testQueryParameterByteFormat.

@Test
public void testQueryParameterByteFormat() throws Exception {
    Operation op = testSpec.getPaths().get("/queryTests/byteFormat").getGet();
    OpenAPI3RequestValidationHandler validationHandler = new OpenAPI3RequestValidationHandlerImpl(op, op.getParameters(), testSpec);
    loadHandlers("/queryTests/byteFormat", HttpMethod.GET, false, validationHandler, (routingContext) -> {
        RequestParameters params = routingContext.get("parsedParameters");
        routingContext.response().setStatusMessage(params.queryParameter("parameter").getString()).end();
    });
    testRequest(HttpMethod.GET, "/queryTests/byteFormat?parameter=Zm9vYmFyCg==", 200, "Zm9vYmFyCg==");
}
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 38 with Operation

use of io.swagger.v3.oas.annotations.Operation in project activityinfo by bedatadriven.

the class FormResource method getRecord.

@GET
@NoCache
@Path("record/{recordId}")
@Produces(JSON_CONTENT_TYPE)
@Operation(summary = "Get a single record")
public FormRecord getRecord(@PathParam("recordId") String recordId) {
    FormStorage form = assertVisible(formId);
    Optional<FormRecord> record = form.get(ResourceId.valueOf(recordId));
    if (!record.isPresent()) {
        throw new NotFoundException("Record " + recordId + " does not exist.");
    }
    PermissionsEnforcer enforcer = backend.newPermissionsEnforcer();
    if (!enforcer.canView(record.get())) {
        throw new NotAuthorizedException();
    }
    return record.get();
}
Also used : VersionedFormStorage(org.activityinfo.store.spi.VersionedFormStorage) FormStorage(org.activityinfo.store.spi.FormStorage) NotFoundException(com.sun.jersey.api.NotFoundException) PermissionsEnforcer(org.activityinfo.store.query.server.PermissionsEnforcer) Operation(io.swagger.v3.oas.annotations.Operation)

Aggregations

Operation (io.swagger.v3.oas.models.Operation)31 OpenAPI3RequestValidationHandlerImpl (io.vertx.ext.web.api.contract.openapi3.impl.OpenAPI3RequestValidationHandlerImpl)28 Test (org.junit.Test)28 RequestParameters (io.vertx.ext.web.api.RequestParameters)21 ArrayList (java.util.ArrayList)12 JsonObject (io.vertx.core.json.JsonObject)7 RequestParameter (io.vertx.ext.web.api.RequestParameter)7 Operation (io.swagger.v3.oas.annotations.Operation)6 MultiMap (io.vertx.core.MultiMap)5 ApiResponse (io.swagger.v3.oas.models.responses.ApiResponse)3 Produces (javax.ws.rs.Produces)3 Charsets (com.google.common.base.Charsets)2 OpenAPIConfiguration (io.swagger.v3.oas.integration.api.OpenAPIConfiguration)2 OpenAPI (io.swagger.v3.oas.models.OpenAPI)2 HttpMethod (io.swagger.v3.oas.models.PathItem.HttpMethod)2 Parameter (io.swagger.v3.oas.models.parameters.Parameter)2 Tag (io.swagger.v3.oas.models.tags.Tag)2 List (java.util.List)2 Consumes (javax.ws.rs.Consumes)2 POST (javax.ws.rs.POST)2