Search in sources :

Example 61 with ApiResponses

use of io.swagger.v3.oas.models.responses.ApiResponses in project snow-owl by b2ihealthcare.

the class FhirCodeSystemValidateCodeOperationController method validateCodeByUrl.

/**
 * HTTP Get request to validate that a coded value is in the code system specified by the URI parameter
 * The code system is identified by its Code System ID within the path
 * If the operation is not called at the instance level, one of the parameters "url" or "codeSystem" must be provided.
 * The operation returns a result (true / false), an error message, and the recommended display for the code.
 * When invoking this operation, a client SHALL provide one (and only one) of the parameters (code+system, coding, or codeableConcept).
 * Other parameters (including version and display) are optional.
 *
 * @param url the code system to validate against
 * @param code to code to validate
 * @param version the version of the code system to validate against
 * @param date the date for which the validation should be checked
 * @param isAbstract If this parameter has a value of true, the client is stating that the validation is being performed in a context
 * 			where a concept designated as 'abstract' is appropriate/allowed.
 *
 * @return validation results as {@link OperationOutcome}
 */
@Operation(summary = "Validate a code in a code system", description = "Validate that a coded value is in a code system.")
@ApiResponses({ @ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "400", description = "Bad request"), @ApiResponse(responseCode = "404", description = "Code system not found") })
@GetMapping("/$validate-code")
public Promise<Parameters.Fhir> validateCodeByUrl(@Parameter(description = "The uri of the code system to validate against") @RequestParam("url") String url, @Parameter(description = "The code to be validated") @RequestParam(value = "code") final String code, @Parameter(description = "The version of the code system") @RequestParam(value = "version") final Optional<String> version, @Parameter(description = "The display string of the code") @RequestParam(value = "display") final Optional<String> display, @Parameter(description = "The date stamp of the code system to validate against") @RequestParam(value = "date") final Optional<String> date, @Parameter(description = "The abstract status of the code") @RequestParam(value = "abstract") final Optional<Boolean> isAbstract) {
    ValidateCodeRequest.Builder builder = ValidateCodeRequest.builder().url(url).code(code).version(version.orElse(null)).display(display.orElse(null)).isAbstract(isAbstract.orElse(null));
    if (date.isPresent()) {
        builder.date(date.get());
    }
    // Convert to FHIR parameters and delegate to the POST call
    Json json = new Parameters.Json(builder.build());
    Fhir fhir = new Parameters.Fhir(json.parameters());
    return validateCode(fhir);
}
Also used : Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) Json(com.b2international.snowowl.fhir.core.model.dt.Parameters.Json) ValidateCodeRequest(com.b2international.snowowl.fhir.core.model.codesystem.ValidateCodeRequest) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 62 with ApiResponses

use of io.swagger.v3.oas.models.responses.ApiResponses in project snow-owl by b2ihealthcare.

the class FhirCodeSystemSubsumesOperationController method subsumes.

/*
	 * Subsumes POST method without codeSystemId and body
	 */
@Operation(summary = "Subsumption testing", description = "Test the subsumption relationship between code/Coding A and code/Coding B given the semantics of subsumption in the underlying code system (see hierarchyMeaning).")
@ApiResponses({ @ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "404", description = "Not found"), @ApiResponse(responseCode = "400", description = "Bad request") })
@PostMapping(value = "/$subsumes", consumes = AbstractFhirController.APPLICATION_FHIR_JSON)
public Promise<Parameters.Fhir> subsumes(@Parameter(description = "The lookup request parameters") @RequestBody Parameters.Fhir body) {
    SubsumptionRequest request = toRequest(body, SubsumptionRequest.class);
    validateSubsumptionRequest(request);
    return FhirRequests.codeSystems().prepareSubsumes().setRequest(request).buildAsync().execute(getBus()).then(this::toResponse);
}
Also used : SubsumptionRequest(com.b2international.snowowl.fhir.core.model.codesystem.SubsumptionRequest) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 63 with ApiResponses

use of io.swagger.v3.oas.models.responses.ApiResponses 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);
}
Also used : TranslateRequest(com.b2international.snowowl.fhir.core.model.conceptmap.TranslateRequest) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 64 with ApiResponses

use of io.swagger.v3.oas.models.responses.ApiResponses 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);
}
Also used : Entry(com.b2international.snowowl.fhir.core.model.Entry) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Bundle(com.b2international.snowowl.fhir.core.model.Bundle) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 65 with ApiResponses

use of io.swagger.v3.oas.models.responses.ApiResponses in project swagger-core by swagger-api.

the class ApiResponsesDeserializer method deserialize.

@Override
public ApiResponses deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
    final ObjectMapper mapper;
    if (openapi31) {
        mapper = Json31.mapper();
    } else {
        mapper = Json.mapper();
    }
    ApiResponses result = new ApiResponses();
    JsonNode node = jp.getCodec().readTree(jp);
    ObjectNode objectNode = (ObjectNode) node;
    Map<String, Object> extensions = new LinkedHashMap<>();
    for (Iterator<String> it = objectNode.fieldNames(); it.hasNext(); ) {
        String childName = it.next();
        JsonNode child = objectNode.get(childName);
        // if name start with `x-` consider it an extension
        if (childName.startsWith("x-")) {
            extensions.put(childName, mapper.convertValue(child, Object.class));
        } else {
            result.put(childName, mapper.convertValue(child, ApiResponse.class));
        }
    }
    if (!extensions.isEmpty()) {
        result.setExtensions(extensions);
    }
    return result;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) JsonNode(com.fasterxml.jackson.databind.JsonNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ApiResponses(io.swagger.v3.oas.models.responses.ApiResponses) ApiResponse(io.swagger.v3.oas.models.responses.ApiResponse) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

Operation (io.swagger.v3.oas.annotations.Operation)99 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)99 ApiResponses (io.swagger.v3.oas.models.responses.ApiResponses)48 ApiResponse (io.swagger.v3.oas.models.responses.ApiResponse)47 ProtectedApi (org.gluu.oxtrust.service.filter.ProtectedApi)47 Operation (io.swagger.v3.oas.models.Operation)39 PathItem (io.swagger.v3.oas.models.PathItem)35 OpenAPI (io.swagger.v3.oas.models.OpenAPI)34 Test (org.testng.annotations.Test)31 ArrayList (java.util.ArrayList)23 Schema (io.swagger.v3.oas.models.media.Schema)22 Content (io.swagger.v3.oas.models.media.Content)21 StringSchema (io.swagger.v3.oas.models.media.StringSchema)21 MediaType (io.swagger.v3.oas.models.media.MediaType)20 ObjectSchema (io.swagger.v3.oas.models.media.ObjectSchema)19 IntegerSchema (io.swagger.v3.oas.models.media.IntegerSchema)17 Path (javax.ws.rs.Path)17 Produces (javax.ws.rs.Produces)17 ArraySchema (io.swagger.v3.oas.models.media.ArraySchema)16 Components (io.swagger.v3.oas.models.Components)10