use of io.swagger.v3.oas.models.responses.ApiResponse in project snow-owl by b2ihealthcare.
the class FhirConceptMapTranslateOperationController method translate.
/**
* HTTP POST request to translate a code that belongs to a {@link ConceptMap} specified by its ID.
* @param conceptMapId
* @return translation of the code
*/
@Operation(summary = "Translate a code based on a specific Concept Map", description = "Translate a code from one value set to another, based on the existing value set and specific concept map.")
@ApiResponses({ @ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "404", description = "Not found"), @ApiResponse(responseCode = "400", description = "Bad request") })
@PostMapping(value = "/{conceptMapId:**}/$translate", consumes = AbstractFhirController.APPLICATION_FHIR_JSON)
public Promise<Parameters.Fhir> translate(@Parameter(description = "The id of the conceptMap to base the translation on") @PathVariable("conceptMapId") String conceptMapId, @Parameter(description = "The translate request parameters") @RequestBody Parameters.Fhir body) {
// validation is triggered by builder.build()
final TranslateRequest request = toRequest(body, TranslateRequest.class);
request.setUrl(conceptMapId);
return doTranslate(request);
}
use of io.swagger.v3.oas.models.responses.ApiResponse in project snow-owl by b2ihealthcare.
the class FhirBundleController method getBatchResponse.
@Operation(summary = "Perform batch operations", description = "Executes the FHIR requests included in the bundle provided.")
@ApiResponses({ @ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "400", description = "Bad Request") })
@RequestMapping(value = "/", method = RequestMethod.POST, consumes = AbstractFhirController.APPLICATION_FHIR_JSON)
public Promise<Bundle> getBatchResponse(@Parameter(name = "bundle", description = "The bundle including the list of requests to perform") @RequestBody final Bundle bundle, HttpServletRequest request) throws JsonProcessingException {
Collection<Entry> entries = bundle.getEntry();
Bundle responseBundle = Bundle.builder().language("en").type(BundleType.BATCH_RESPONSE).build();
ObjectNode rootNode = (ObjectNode) objectMapper.valueToTree(responseBundle);
ArrayNode arrayNode = rootNode.putArray("entry");
for (Entry entry : entries) {
FhirBatchRequestProcessor requestProcessor = FhirBatchRequestProcessor.getInstance(entry, objectMapper, this);
requestProcessor.process(arrayNode, request);
}
Bundle treeToValue = objectMapper.treeToValue(rootNode, Bundle.class);
return Promise.immediate(treeToValue);
}
use of io.swagger.v3.oas.models.responses.ApiResponse in project carbon-apimgt by wso2.
the class OASParserUtil method setRefOfApiResponseHeaders.
private static void setRefOfApiResponseHeaders(ApiResponses responses, SwaggerUpdateContext context) {
if (responses != null) {
for (ApiResponse response : responses.values()) {
Map<String, Header> headers = response.getHeaders();
if (headers != null) {
for (Header header : headers.values()) {
Content content = header.getContent();
extractReferenceFromContent(content, context);
}
}
}
}
}
use of io.swagger.v3.oas.models.responses.ApiResponse in project carbon-apimgt by wso2.
the class OASParserUtil method processReferenceObjectMap.
private static void processReferenceObjectMap(SwaggerUpdateContext context) {
// Get a deep copy of the reference objects in order to prevent Concurrent modification exception
// since we may need to update the reference object mapping while iterating through it
Map<String, Set<String>> referenceObjectsMappingCopy = getReferenceObjectsCopy(context.getReferenceObjectMapping());
int preRefObjectCount = getReferenceObjectCount(context.getReferenceObjectMapping());
Set<Components> aggregatedComponents = context.getAggregatedComponents();
for (Components sourceComponents : aggregatedComponents) {
for (Map.Entry<String, Set<String>> refCategoryEntry : referenceObjectsMappingCopy.entrySet()) {
String category = refCategoryEntry.getKey();
if (REQUEST_BODIES.equalsIgnoreCase(category)) {
Map<String, RequestBody> sourceRequestBodies = sourceComponents.getRequestBodies();
if (sourceRequestBodies != null) {
for (String refKey : refCategoryEntry.getValue()) {
RequestBody requestBody = sourceRequestBodies.get(refKey);
setRefOfRequestBody(requestBody, context);
}
}
}
if (SCHEMAS.equalsIgnoreCase(category)) {
Map<String, Schema> sourceSchemas = sourceComponents.getSchemas();
if (sourceSchemas != null) {
for (String refKey : refCategoryEntry.getValue()) {
Schema schema = sourceSchemas.get(refKey);
extractReferenceFromSchema(schema, context);
}
}
}
if (PARAMETERS.equalsIgnoreCase(category)) {
Map<String, Parameter> parameters = sourceComponents.getParameters();
if (parameters != null) {
for (String refKey : refCategoryEntry.getValue()) {
Parameter parameter = parameters.get(refKey);
// Extract the parameter reference only if it exists in the source definition
if (parameter != null) {
Content content = parameter.getContent();
if (content != null) {
extractReferenceFromContent(content, context);
} else {
String ref = parameter.get$ref();
if (ref != null) {
extractReferenceWithoutSchema(ref, context);
}
}
}
}
}
}
if (RESPONSES.equalsIgnoreCase(category)) {
Map<String, ApiResponse> responses = sourceComponents.getResponses();
if (responses != null) {
for (String refKey : refCategoryEntry.getValue()) {
ApiResponse response = responses.get(refKey);
// Extract the response reference only if it exists in the source definition
if (response != null) {
Content content = response.getContent();
extractReferenceFromContent(content, context);
}
}
}
}
if (HEADERS.equalsIgnoreCase(category)) {
Map<String, Header> headers = sourceComponents.getHeaders();
if (headers != null) {
for (String refKey : refCategoryEntry.getValue()) {
Header header = headers.get(refKey);
Content content = header.getContent();
extractReferenceFromContent(content, context);
}
}
}
}
int postRefObjectCount = getReferenceObjectCount(context.getReferenceObjectMapping());
if (postRefObjectCount > preRefObjectCount) {
processReferenceObjectMap(context);
}
}
}
use of io.swagger.v3.oas.models.responses.ApiResponse in project atlasmap by atlasmap.
the class CsvService method inspect.
/**
* Inspect a CSV instance and return a Document object.
* @param request request
* @param format format
* @param delimiter delimiter
* @param firstRecordAsHeader first record as header
* @param skipHeaderRecord skip header record
* @param headers headers
* @param commentMarker comment marker
* @param escape escape
* @param ignoreEmptyLines ignore empty lines
* @param ignoreHeaderCase ignore header case
* @param ignoreSurroundingSpaces ignore surrounding spaces
* @param nullString null string
* @param quote quote
* @param allowDuplicateHeaderNames allow duplicate header names
* @param allowMissingColumnNames allow missing column names
* @return {@link CsvInspectionResponse}
* @throws IOException unexpected error
*/
@POST
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
@Path("/inspect")
@Operation(summary = "Inspect CSV", description = "Inspect a CSV instance and return a Document object")
@RequestBody(description = "Csv", content = @Content(mediaType = "text/csv", schema = @Schema(implementation = String.class)))
@ApiResponses(@ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = CsvInspectionResponse.class)), description = "Return a Document object"))
public Response inspect(InputStream request, @QueryParam("format") String format, @QueryParam("delimiter") String delimiter, @QueryParam("firstRecordAsHeader") Boolean firstRecordAsHeader, @QueryParam("skipRecordHeader") Boolean skipHeaderRecord, @QueryParam("headers") String headers, @QueryParam("commentMarker") String commentMarker, @QueryParam("escape") String escape, @QueryParam("ignoreEmptyLines") Boolean ignoreEmptyLines, @QueryParam("ignoreHeaderCase") Boolean ignoreHeaderCase, @QueryParam("ignoreSurroundingSpaces") Boolean ignoreSurroundingSpaces, @QueryParam("nullString") String nullString, @QueryParam("quote") String quote, @QueryParam("allowDuplicateHeaderNames") Boolean allowDuplicateHeaderNames, @QueryParam("allowMissingColumnNames") Boolean allowMissingColumnNames) throws IOException {
long startTime = System.currentTimeMillis();
CsvInspectionResponse response = new CsvInspectionResponse();
try {
if (LOG.isDebugEnabled()) {
LOG.debug("Options: delimiter={}, firstRecordAsHeader={}", delimiter, firstRecordAsHeader);
}
CsvConfig csvConfig = new CsvConfig(format);
if (delimiter != null) {
csvConfig.setDelimiter(delimiter.charAt(0));
}
csvConfig.setFirstRecordAsHeader(firstRecordAsHeader);
csvConfig.setSkipHeaderRecord(skipHeaderRecord);
csvConfig.setHeaders(headers);
if (commentMarker != null) {
csvConfig.setCommentMarker(commentMarker.charAt(0));
}
if (escape != null) {
csvConfig.setEscape(escape.charAt(0));
}
csvConfig.setIgnoreEmptyLines(ignoreEmptyLines);
csvConfig.setIgnoreHeaderCase(ignoreHeaderCase);
csvConfig.setIgnoreSurroundingSpaces(ignoreSurroundingSpaces);
csvConfig.setNullString(nullString);
if (quote != null) {
csvConfig.setQuote(quote.charAt(0));
}
csvConfig.setAllowDuplicateHeaderNames(allowDuplicateHeaderNames);
csvConfig.setAllowMissingColumnNames(allowMissingColumnNames);
CsvFieldReader csvFieldReader = new CsvFieldReader(csvConfig);
csvFieldReader.setDocument(request);
Document document = csvFieldReader.readSchema();
response.setCsvDocument(document);
request.close();
} catch (Exception e) {
LOG.error("Error inspecting CSV: " + e.getMessage(), e);
response.setErrorMessage(e.getMessage());
} finally {
request.close();
;
response.setExecutionTime(System.currentTimeMillis() - startTime);
}
if (LOG.isDebugEnabled()) {
LOG.debug(("Response: {}" + new ObjectMapper().writeValueAsString(response)));
}
return Response.ok().entity(toJson(response)).build();
}
Aggregations