use of io.swagger.v3.oas.annotations.responses.ApiResponses in project flow by vaadin.
the class OpenAPIObjectGenerator method createPathItems.
private Map<String, PathItem> createPathItems(String endpointName, String tagName, ClassOrInterfaceDeclaration typeDeclaration, ResolvedTypeParametersMap resolvedTypeParametersMap, CompilationUnit compilationUnit) {
Map<String, PathItem> newPathItems = new HashMap<>();
Collection<MethodDeclaration> methods = typeDeclaration.getMethods();
for (MethodDeclaration methodDeclaration : methods) {
if (isAccessForbidden(typeDeclaration, methodDeclaration)) {
continue;
}
String methodName = methodDeclaration.getNameAsString();
Operation post = createPostOperation(methodDeclaration);
if (methodDeclaration.getParameters().isNonEmpty()) {
post.setRequestBody(createRequestBody(methodDeclaration, resolvedTypeParametersMap));
}
ApiResponses responses = createApiResponses(methodDeclaration, resolvedTypeParametersMap);
post.setResponses(responses);
post.tags(Collections.singletonList(tagName));
PathItem pathItem = new PathItem().post(post);
String pathName = "/" + endpointName + "/" + methodName;
pathItem.readOperationsMap().forEach((httpMethod, operation) -> operation.setOperationId(String.join("_", endpointName, methodName, httpMethod.name())));
newPathItems.put(pathName, pathItem);
}
Stream.concat(typeDeclaration.getExtendedTypes().stream(), typeDeclaration.getImplementedTypes().stream()).map(resolvedType -> getDeclarationAndResolvedTypeParametersMap(resolvedType, resolvedTypeParametersMap)).filter(Objects::nonNull).forEach(pair -> newPathItems.putAll(createPathItems(endpointName, tagName, pair.a, pair.b, compilationUnit)));
return newPathItems;
}
use of io.swagger.v3.oas.annotations.responses.ApiResponses in project snow-owl by b2ihealthcare.
the class SnomedClassificationRestService method beginClassification.
@Operation(summary = "Start a classification on a branch", description = "Classification runs are async jobs. The call to this method immediately returns with a unique URL " + "pointing to the classification run.<p>The URL can be used to fetch the state of the classification " + "to determine whether it's completed or not.")
@ApiResponses({ @ApiResponse(responseCode = "201", description = "Created"), @ApiResponse(responseCode = "404", description = "Branch not found") })
@PostMapping(consumes = { AbstractRestService.JSON_MEDIA_TYPE })
@ResponseStatus(value = HttpStatus.CREATED)
public Promise<ResponseEntity<?>> beginClassification(@Parameter(description = "Classification parameters") @RequestBody final ClassificationRunRestInput request, @RequestHeader(value = X_AUTHOR, required = false) final String author) {
ApiValidation.checkInput(request);
final UriComponentsBuilder linkTo = MvcUriComponentsBuilder.fromController(SnomedClassificationRestService.class);
return ClassificationRequests.prepareCreateClassification().setReasonerId(request.getReasonerId()).setUserId(author).build(request.getPath()).execute(getBus()).then(id -> {
final URI resourceUri = linkTo.pathSegment(id).build().toUri();
return ResponseEntity.created(resourceUri).build();
});
}
use of io.swagger.v3.oas.annotations.responses.ApiResponses in project snow-owl by b2ihealthcare.
the class SnomedDescriptionRestService method create.
@Operation(summary = "Create Description", description = "Creates a new Description directly on a version.")
@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 = "Description parameters") @RequestBody final SnomedResourceRequest<SnomedDescriptionRestInput> body, @RequestHeader(value = X_AUTHOR, required = false) final String author) {
final SnomedDescriptionRestInput change = body.getChange();
final String commitComment = body.getCommitComment();
final String defaultModuleId = body.getDefaultModuleId();
final String createdDescriptionId = 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, createdDescriptionId)).build();
}
use of io.swagger.v3.oas.annotations.responses.ApiResponses in project snow-owl by b2ihealthcare.
the class SnomedReferenceSetMemberRestService method create.
@Operation(summary = "Create a reference set member", description = "Creates a new reference set member directly on a branch. " + "On top of the basic member properties you can include other properties relevant for specific reference set member types." + "For example: query type reference set members support _query_ and _refsetDescription_ properties. " + "_Query_ defines the ESCG query of the new member, while the _refsetDescription_ will be used as the description of the new target simple type reference set.")
@ApiResponses({ @ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "404", description = "Branch not found") })
@PostMapping(consumes = { AbstractRestService.JSON_MEDIA_TYPE })
public ResponseEntity<Void> create(@Parameter(description = "The resource path", required = true) @PathVariable(value = "path") final String path, @Parameter(description = "Reference set member parameters") @RequestBody final SnomedResourceRequest<SnomedRefSetMemberRestInput> body, @RequestHeader(value = X_AUTHOR, required = false) final String author) {
final SnomedRefSetMemberRestInput change = body.getChange();
final String commitComment = body.getCommitComment();
final String defaultModuleId = body.getDefaultModuleId();
final String id = change.getId();
// Check for correct UUID format in id input
UUID.fromString(id);
final String createdRefSetMemberId = 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, createdRefSetMemberId)).build();
}
use of io.swagger.v3.oas.annotations.responses.ApiResponses in project snow-owl by b2ihealthcare.
the class SnomedReferenceSetMemberRestService method update.
@Operation(summary = "Update Reference Set Member", description = "Updates properties of the specified Reference Set Member." + "The following properties are allowed to change (other properties will be simply ignored):" + "- activity status flag (active)" + "- module Concept (moduleId)" + "- query field of query type reference set members")
@ApiResponses({ @ApiResponse(responseCode = "204", description = "No Content"), @ApiResponse(responseCode = "404", description = "Branch or member not found") })
@PutMapping(value = "/{id}", consumes = { AbstractRestService.JSON_MEDIA_TYPE })
@ResponseStatus(HttpStatus.NO_CONTENT)
public void update(@Parameter(description = "The resource path", required = true) @PathVariable(value = "path") final String path, @Parameter(description = "The reference set member identifier") @PathVariable(value = "id") final String memberId, @Parameter(description = "Updated Reference Set parameters") @RequestBody final SnomedResourceRequest<SnomedMemberRestUpdate> body, @Parameter(description = "Force update flag") @RequestParam(defaultValue = "false", required = false) final Boolean force, @RequestHeader(value = X_AUTHOR, required = false) final String author) {
final SnomedMemberRestUpdate update = body.getChange();
final String commitComment = body.getCommitComment();
final String defaultModuleId = body.getDefaultModuleId();
SnomedRequests.prepareUpdateMember(memberId).setSource(update.getSource()).force(force).commit().setDefaultModuleId(defaultModuleId).setAuthor(author).setCommitComment(commitComment).build(path).execute(getBus()).getSync(COMMIT_TIMEOUT, TimeUnit.MINUTES);
}
Aggregations