Search in sources :

Example 56 with RequestBody

use of io.swagger.v3.oas.annotations.parameters.RequestBody in project snow-owl by b2ihealthcare.

the class SnomedConceptRestService method create.

@Operation(summary = "Create Concept", description = "Creates a new Concept directly on a path.")
@ApiResponses({ @ApiResponse(responseCode = "201", description = "Concept created on task"), @ApiResponse(responseCode = "404", description = "Branch not found") })
@PostMapping(consumes = { AbstractRestService.JSON_MEDIA_TYPE })
@ResponseStatus(HttpStatus.CREATED)
public ResponseEntity<Void> create(@Parameter(description = "The resource path", required = true) @PathVariable(value = "path") final String path, @Parameter(description = "Concept parameters") @RequestBody final SnomedResourceRequest<SnomedConceptRestInput> body, @RequestHeader(value = X_AUTHOR, required = false) final String author) {
    final SnomedConceptRestInput change = body.getChange();
    final String commitComment = body.getCommitComment();
    final String defaultModuleId = body.getDefaultModuleId();
    final String createdConceptId = change.toRequestBuilder().commit().setDefaultModuleId(defaultModuleId).setAuthor(author).setCommitComment(commitComment).build(path).execute(getBus()).getSync(COMMIT_TIMEOUT, TimeUnit.MINUTES).getResultAs(String.class);
    return ResponseEntity.created(getResourceLocationURI(path, createdConceptId)).build();
}
Also used : SnomedConceptRestInput(com.b2international.snowowl.snomed.core.rest.domain.SnomedConceptRestInput) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 57 with RequestBody

use of io.swagger.v3.oas.annotations.parameters.RequestBody in project snow-owl by b2ihealthcare.

the class SnomedReferenceSetRestService method create.

@Operation(summary = "Create a reference set", description = "Creates a new reference set directly on a path. Creates the corresponding identifier concept as well based on the given JSON body." + "<p>Reference Set type and referenced component type properties are immutable and cannot be modified, " + "thus there is no update endpoint for reference sets. " + "To update the corresponding identifier concept properties, use the concept update endpoint.</p>")
@ApiResponses({ @ApiResponse(responseCode = "201", description = "Created"), @ApiResponse(responseCode = "404", description = "Branch not found") })
@PostMapping(consumes = { AbstractRestService.JSON_MEDIA_TYPE })
@ResponseStatus(HttpStatus.CREATED)
public ResponseEntity<Void> create(@Parameter(description = "The resource path", required = true) @PathVariable(value = "path") final String path, @Parameter(description = "Reference set parameters") @RequestBody final SnomedResourceRequest<SnomedRefSetRestInput> body, @RequestHeader(value = X_AUTHOR, required = false) final String author) {
    final SnomedRefSetRestInput change = body.getChange();
    final String commitComment = body.getCommitComment();
    final String defaultModuleId = body.getDefaultModuleId();
    final String createdRefSetId = change.toRequestBuilder().commit().setDefaultModuleId(defaultModuleId).setAuthor(author).setCommitComment(commitComment).build(path).execute(getBus()).getSync(COMMIT_TIMEOUT, TimeUnit.MINUTES).getResultAs(String.class);
    return ResponseEntity.created(getResourceLocationURI(path, createdRefSetId)).build();
}
Also used : SnomedRefSetRestInput(com.b2international.snowowl.snomed.core.rest.domain.SnomedRefSetRestInput) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 58 with RequestBody

use of io.swagger.v3.oas.annotations.parameters.RequestBody in project snow-owl by b2ihealthcare.

the class FhirCodeSystemValidateCodeOperationController method validateCode.

/**
 * POST-based $validate-code end-point.
 * All parameters are in the request body, except the codeSystemId
 * @param body - FHIR parameters
 * @return out - FHIR parameters
 */
@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 = "404", description = "Not found"), @ApiResponse(responseCode = "400", description = "Bad request") })
@PostMapping(value = "/{codeSystemId:**}/$validate-code", consumes = AbstractFhirController.APPLICATION_FHIR_JSON)
public Promise<Parameters.Fhir> validateCode(@Parameter(description = "The id of the code system to validate against") @PathVariable("codeSystemId") String codeSystemId, @Parameter(description = "The validate-code request parameters") @RequestBody Parameters.Fhir body) {
    final ValidateCodeRequest request = toRequest(body, ValidateCodeRequest.class);
    // Validate for parameters that are not allowed on the instance level
    if (request.getUrl() != null) {
        throw new BadRequestException("Parameter 'url' cannot be specified when the code system ID is set.", "ValidateCodeRequest.url");
    }
    if (request.getCoding() != null) {
        throw new BadRequestException("Parameter 'coding' cannot be specified when the code system ID is set.", "ValidateCodeRequest.coding");
    }
    if (request.getCodeableConcept() != null) {
        throw new BadRequestException("Parameter 'codeableConcept' cannot be specified when the code system ID is set.", "ValidateCodeRequest.codeableConcept");
    }
    if (request.getCodeSystem() != null) {
        throw new BadRequestException("Validation against external code systems is not supported", "ValidateCodeRequest.codeSystem");
    }
    // before execution set the codesystem to the path variable
    request.setUrl(new Uri(codeSystemId));
    return FhirRequests.codeSystems().prepareValidateCode().setRequest(request).buildAsync().execute(getBus()).then(this::toResponse);
}
Also used : BadRequestException(com.b2international.snowowl.fhir.core.exceptions.BadRequestException) ValidateCodeRequest(com.b2international.snowowl.fhir.core.model.codesystem.ValidateCodeRequest) Uri(com.b2international.snowowl.fhir.core.model.dt.Uri) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 59 with RequestBody

use of io.swagger.v3.oas.annotations.parameters.RequestBody 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 60 with RequestBody

use of io.swagger.v3.oas.annotations.parameters.RequestBody 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)

Aggregations

Test (org.testng.annotations.Test)67 OpenAPI (io.swagger.v3.oas.models.OpenAPI)62 RequestBody (io.swagger.v3.oas.models.parameters.RequestBody)59 Schema (io.swagger.v3.oas.models.media.Schema)46 Operation (io.swagger.v3.oas.annotations.Operation)41 ArraySchema (io.swagger.v3.oas.models.media.ArraySchema)40 MediaType (io.swagger.v3.oas.models.media.MediaType)36 StringSchema (io.swagger.v3.oas.models.media.StringSchema)35 IntegerSchema (io.swagger.v3.oas.models.media.IntegerSchema)32 ObjectSchema (io.swagger.v3.oas.models.media.ObjectSchema)32 Content (io.swagger.v3.oas.models.media.Content)31 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)28 Operation (io.swagger.v3.oas.models.Operation)27 PathItem (io.swagger.v3.oas.models.PathItem)23 ComposedSchema (io.swagger.v3.oas.models.media.ComposedSchema)21 OpenAPIV3Parser (io.swagger.v3.parser.OpenAPIV3Parser)19 Parameter (io.swagger.v3.oas.models.parameters.Parameter)15 SwaggerParseResult (io.swagger.v3.parser.core.models.SwaggerParseResult)14 Components (io.swagger.v3.oas.models.Components)13 ApiResponse (io.swagger.v3.oas.models.responses.ApiResponse)12