Search in sources :

Example 41 with ApiResponses

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;
}
Also used : PathItem(io.swagger.v3.oas.models.PathItem) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) MethodDeclaration(com.github.javaparser.ast.body.MethodDeclaration) Operation(io.swagger.v3.oas.models.Operation) ApiResponses(io.swagger.v3.oas.models.responses.ApiResponses)

Example 42 with ApiResponses

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();
    });
}
Also used : UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder) MvcUriComponentsBuilder(org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder) URI(java.net.URI) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 43 with ApiResponses

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();
}
Also used : SnomedDescriptionRestInput(com.b2international.snowowl.snomed.core.rest.domain.SnomedDescriptionRestInput) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 44 with ApiResponses

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();
}
Also used : SnomedRefSetMemberRestInput(com.b2international.snowowl.snomed.core.rest.domain.SnomedRefSetMemberRestInput) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 45 with ApiResponses

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);
}
Also used : SnomedMemberRestUpdate(com.b2international.snowowl.snomed.core.rest.domain.SnomedMemberRestUpdate) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

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)47 ProtectedApi (org.gluu.oxtrust.service.filter.ProtectedApi)47 ApiResponse (io.swagger.v3.oas.models.responses.ApiResponse)46 Operation (io.swagger.v3.oas.models.Operation)39 OpenAPI (io.swagger.v3.oas.models.OpenAPI)34 PathItem (io.swagger.v3.oas.models.PathItem)34 Test (org.testng.annotations.Test)31 ArrayList (java.util.ArrayList)23 Schema (io.swagger.v3.oas.models.media.Schema)22 StringSchema (io.swagger.v3.oas.models.media.StringSchema)21 Content (io.swagger.v3.oas.models.media.Content)20 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