use of io.swagger.v3.oas.annotations.Operation in project activityinfo by bedatadriven.
the class FormResource method getXlsForm.
@GET
@NoCache
@Path("form.xls")
@Operation(summary = "Get a form's schema as an XLSForm")
public Response getXlsForm() {
assertVisible(formId);
final XlsFormBuilder xlsForm = new XlsFormBuilder(backend.getStorage());
xlsForm.build(formId);
StreamingOutput output = xlsForm::write;
return Response.ok(output, "application/vnd.ms-excel").build();
}
use of io.swagger.v3.oas.annotations.Operation in project activityinfo by bedatadriven.
the class FormResource method getVersionRange.
@GET
@NoCache
@Path("records/versionRange")
@Operation(summary = "Get the records that have changed between two versions of this form")
public FormSyncSet getVersionRange(@QueryParam("localVersion") long localVersion, @QueryParam("version") long version) {
FormStorage collection = assertVisible(formId);
// Compute a predicate that will tell us whether a given
// record should be visible to the user, based on their *current* permissions.
java.util.function.Predicate<ResourceId> visibilityPredicate = computeVisibilityPredicate();
FormSyncSet syncSet;
if (collection instanceof VersionedFormStorage) {
syncSet = ((VersionedFormStorage) collection).getVersionRange(localVersion, version, visibilityPredicate);
} else {
syncSet = FormSyncSet.emptySet(formId);
}
return syncSet;
}
use of io.swagger.v3.oas.annotations.Operation in project activityinfo by bedatadriven.
the class QueryResource method queryRows.
@POST
@Path("rows")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Executes a query over a set of forms in row format")
public Response queryRows(QueryModel model) {
ColumnSetBuilder builder = backend.newQueryBuilder();
final ColumnSet columnSet = builder.build(model);
final StreamingOutput output = outputStream -> {
RowBasedJsonWriter writer = new RowBasedJsonWriter(outputStream, Charsets.UTF_8);
writer.write(columnSet);
writer.flush();
};
return Response.ok(output).type(MediaType.APPLICATION_JSON_TYPE).build();
}
use of io.swagger.v3.oas.annotations.Operation in project activityinfo by bedatadriven.
the class QueryResource method queryColumns.
@POST
@Path("columns")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Executes a query over a set of forms in columnar format")
public Response queryColumns(QueryModel model) {
ColumnSetBuilder builder = backend.newQueryBuilder();
final ColumnSet columnSet = builder.build(model);
final StreamingOutput output = outputStream -> {
ColumnJsonWriter columnSetWriter = new ColumnJsonWriter(outputStream, Charsets.UTF_8);
columnSetWriter.write(columnSet);
columnSetWriter.flush();
};
return Response.ok(output).type(MediaType.APPLICATION_JSON_TYPE).build();
}
use of io.swagger.v3.oas.annotations.Operation in project vertx-web by vert-x3.
the class OpenAPI3ValidationTest method testJsonBody.
@Test
public void testJsonBody() throws Exception {
Operation op = testSpec.getPaths().get("/jsonBodyTest/sampleTest").getPost();
if (op.getParameters() == null)
op.setParameters(new ArrayList<>());
OpenAPI3RequestValidationHandler validationHandler = new OpenAPI3RequestValidationHandlerImpl(op, op.getParameters(), testSpec);
loadHandlers("/jsonBodyTest/sampleTest", 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 object = new JsonObject();
object.put("id", "anId");
List<Integer> valuesArray = new ArrayList<>();
for (int i = 0; i < 4; i++) valuesArray.add(getSuccessSample(ParameterType.INT).getInteger());
object.put("values", valuesArray);
testRequestWithJSON(HttpMethod.POST, "/jsonBodyTest/sampleTest", object, 200, "OK", object);
testRequestWithJSONAndCustomContentType(HttpMethod.POST, "/jsonBodyTest/sampleTest", "application/json; charset=utf-8", object, 200, "OK", object);
testRequestWithJSONAndCustomContentType(HttpMethod.POST, "/jsonBodyTest/sampleTest", "application/superapplication+json", object, 200, "OK", object);
}
Aggregations