use of io.swagger.v3.oas.models.parameters.RequestBody in project atlasmap by atlasmap.
the class AtlasService method processMappingRequest.
/**
* Processes mapping by feeding input data.
* @param request request
* @param uriInfo URI info
* @return {@link ProcessMappingResponse} which holds the result of the mappings
*/
@PUT
@Path("/mapping/process")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Process Mapping", description = "Process Mapping by feeding input data")
@RequestBody(description = "Mapping file content", content = @Content(schema = @Schema(implementation = AtlasMapping.class)))
@ApiResponses({ @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = ProcessMappingResponse.class)), description = "Return a mapping result"), @ApiResponse(responseCode = "204", description = "Skipped empty mapping execution") })
public Response processMappingRequest(InputStream request, @Context UriInfo uriInfo) {
ProcessMappingRequest pmr = fromJson(request, ProcessMappingRequest.class);
if (pmr.getAtlasMapping() != null) {
throw new WebApplicationException("Whole mapping execution is not yet supported");
}
Mapping mapping = pmr.getMapping();
if (mapping == null) {
return Response.noContent().build();
}
Audits audits = null;
try {
if (LOG.isDebugEnabled()) {
LOG.debug("Preview request: {}", new String(toJson(mapping)));
}
audits = previewContext.processPreview(mapping);
} catch (AtlasException e) {
throw new WebApplicationException("Unable to process mapping preview", e);
}
ProcessMappingResponse response = new ProcessMappingResponse();
response.setMapping(mapping);
if (audits != null) {
response.setAudits(audits);
}
byte[] serialized = toJson(response);
if (LOG.isDebugEnabled()) {
LOG.debug("Preview outcome: {}", new String(serialized));
}
return Response.ok().entity(serialized).build();
}
use of io.swagger.v3.oas.models.parameters.RequestBody in project atlasmap by atlasmap.
the class JsonService method inspect.
/**
* Inspect a JSON schema or instance and return a Document object.
* @param requestIn request
* @return {@link JsonInspectionResponse}
*/
@POST
@Path("/inspect")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
@Operation(summary = "Inspect JSON", description = "Inspect a JSON schema or instance and return a Document object")
@RequestBody(description = "JsonInspectionRequest object", content = @Content(schema = @Schema(implementation = JsonInspectionRequest.class)))
@ApiResponses(@ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = JsonInspectionResponse.class)), description = "Return a Document object represented by JsonDocument"))
public Response inspect(InputStream requestIn) {
JsonInspectionRequest request = fromJson(requestIn, JsonInspectionRequest.class);
long startTime = System.currentTimeMillis();
JsonInspectionResponse response = new JsonInspectionResponse();
JsonDocument d = null;
try {
if (request.getType() == null || request.getJsonData() == null) {
response.setErrorMessage("Json data and Instance or Schema inspection type must be specified in request");
} else {
JsonInspectionService s = new JsonInspectionService();
String jsonData = cleanJsonData(request.getJsonData());
if (!validJsonData(jsonData)) {
response.setErrorMessage("Invalid json payload specified");
} else {
switch(request.getType()) {
case INSTANCE:
d = s.inspectJsonDocument(jsonData);
break;
case SCHEMA:
d = s.inspectJsonSchema(jsonData);
break;
default:
response.setErrorMessage("Unsupported inspection type: " + request.getType());
break;
}
}
}
} catch (Exception e) {
LOG.error("Error inspecting json: " + e.getMessage(), e);
response.setErrorMessage(e.getMessage());
} finally {
response.setExecutionTime(System.currentTimeMillis() - startTime);
}
AtlasUtil.excludeNotRequestedFields(d, request.getInspectPaths());
response.setJsonDocument(d);
return Response.ok().entity(toJson(response)).build();
}
use of io.swagger.v3.oas.models.parameters.RequestBody in project snow-owl by b2ihealthcare.
the class CodeSystemUpgradeRestService method upgrade.
@Operation(summary = "Start a Code System dependency upgrade (EXPERIMENTAL)", description = "Starts the upgrade process of a Code System to a newer extensionOf Code System dependency than the current extensionOf.")
@ApiResponses({ @ApiResponse(responseCode = "201", description = "Upgrade created"), @ApiResponse(responseCode = "400", description = "Code System cannot be upgraded") })
@PostMapping(consumes = { AbstractRestService.JSON_MEDIA_TYPE })
@ResponseStatus(HttpStatus.CREATED)
public Promise<ResponseEntity<Void>> upgrade(@RequestBody final UpgradeRestInput body) {
final UriComponentsBuilder uriBuilder = createURIBuilder();
final ResourceURI upgradeOf = new ResourceURI(body.getUpgradeOf());
final IEventBus bus = getBus();
return // TODO move this to generic resource controller
CodeSystemRequests.prepareGetCodeSystem(upgradeOf.getResourceId()).buildAsync().execute(bus).thenWith(codeSystem -> {
return CodeSystemRequests.prepareUpgrade(upgradeOf, new ResourceURI(body.getExtensionOf())).setResourceId(body.getCodeSystemId()).buildAsync().execute(bus);
}).then(upgradeCodeSystemId -> {
return ResponseEntity.created(uriBuilder.pathSegment(upgradeCodeSystemId).build().toUri()).build();
});
}
use of io.swagger.v3.oas.models.parameters.RequestBody in project snow-owl by b2ihealthcare.
the class CodeSystemUpgradeRestService method sync.
@Operation(summary = "Synchronize upgrade codesystem with the original codesystem (EXPERIMENTAL)", description = "Synchronize any changes on the original code system with the upgrade code system.")
@ApiResponses({ @ApiResponse(responseCode = "204", description = "Upgrade code system synchronized"), @ApiResponse(responseCode = "400", description = "Code system could not be synchronized with the downstream code system") })
@PostMapping(value = "/sync/", consumes = { AbstractRestService.JSON_MEDIA_TYPE })
@ResponseStatus(HttpStatus.NO_CONTENT)
public void sync(@RequestBody final CodeSystemUpgradeSyncRestInput body) {
final String codeSystemId = body.getCodeSystemId();
final ResourceURI source = body.getSource();
final CodeSystem codeSystem = CodeSystemRequests.prepareSearchCodeSystem().filterById(codeSystemId).buildAsync().execute(getBus()).getSync(1, TimeUnit.MINUTES).first().orElseThrow(() -> new NotFoundException("Code System", codeSystemId));
CodeSystemRequests.prepareUpgradeSynchronization(codeSystem.getResourceURI(), source).buildAsync().execute(getBus());
}
use of io.swagger.v3.oas.models.parameters.RequestBody in project snow-owl by b2ihealthcare.
the class RepositoryBranchRestService method createBranch.
@Operation(summary = "Create a new branch", description = "Create a new branch in the SNOMED CT repository.")
@ApiResponses({ @ApiResponse(responseCode = "201", description = "Created"), @ApiResponse(responseCode = "400", description = "Bad Request") })
@RequestMapping(method = RequestMethod.POST, consumes = { AbstractRestService.JSON_MEDIA_TYPE, MediaType.APPLICATION_JSON_VALUE })
@ResponseStatus(HttpStatus.CREATED)
public Promise<ResponseEntity<Void>> createBranch(@RequestBody CreateBranchRestRequest request) {
ApiValidation.checkInput(request);
final URI location = getResourceLocationURI(request.path());
return RepositoryRequests.branching().prepareCreate().setParent(request.getParent()).setName(request.getName()).setMetadata(request.metadata()).build(repositoryId).execute(getBus()).then(success -> ResponseEntity.created(location).build());
}
Aggregations