Search in sources :

Example 76 with ApiResponses

use of io.swagger.v3.oas.models.responses.ApiResponses in project atlasmap by atlasmap.

the class AtlasService method removeMappingRequest.

/**
 * Remove a mapping file saved on the backend.
 * @param mappingDefinitionId mapping definition ID
 * @return empty response
 */
@DELETE
@Path("/mapping/{mappingDefinitionId}")
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Remove Mapping", description = "Remove a mapping file saved on the server")
@ApiResponses({ @ApiResponse(responseCode = "200", description = "Specified mapping file was removed successfully"), @ApiResponse(responseCode = "204", description = "Mapping file was not found") })
public Response removeMappingRequest(@Parameter(description = "Mapping ID") @PathParam("mappingDefinitionId") Integer mappingDefinitionId) {
    java.nio.file.Path mappingDirPath = Paths.get(getMappingSubDirectory(mappingDefinitionId));
    File mappingDirFile = mappingDirPath.toFile();
    if (mappingDirFile == null || !mappingDirFile.exists()) {
        return Response.noContent().build();
    }
    if (!mappingDirFile.isDirectory()) {
        LOG.warn("Removing invalid file '{}' in a persistent directory", mappingDirFile.getAbsolutePath());
    } else {
        AtlasUtil.deleteDirectory(mappingDirFile);
    }
    return Response.ok().build();
}
Also used : File(java.io.File) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Produces(javax.ws.rs.Produces) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 77 with ApiResponses

use of io.swagger.v3.oas.models.responses.ApiResponses in project atlasmap by atlasmap.

the class AtlasService method resetMappingById.

/**
 * Removes the mapping file and catalogs related to specified ID.
 * @param mappingDefinitionId mapping definition ID
 * @return empty response
 */
@DELETE
@Path("/mapping/RESET/{mappingDefinitionId}")
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Remove Mapping by ID", description = "Remove mapping file and catalogs related to specified ID")
@ApiResponses({ @ApiResponse(responseCode = "200", description = "Mapping file and Catalogs were removed successfully"), @ApiResponse(responseCode = "204", description = "Unable to remove mapping file and Catalogs for the specified ID") })
public Response resetMappingById(@Parameter(description = "Mapping ID") @PathParam("mappingDefinitionId") Integer mappingDefinitionId) {
    LOG.debug("resetMappingById {} ", mappingDefinitionId);
    java.nio.file.Path mappingFolderPath = Paths.get(getMappingSubDirectory(mappingDefinitionId));
    File mappingFolderFile = mappingFolderPath.toFile();
    if (mappingFolderFile == null || !mappingFolderFile.exists()) {
        return Response.ok().build();
    }
    if (!mappingFolderFile.isDirectory()) {
        LOG.warn("{} is not a directory - removing anyway", mappingFolderFile.getAbsolutePath());
    }
    AtlasUtil.deleteDirectory(mappingFolderFile);
    return Response.ok().build();
}
Also used : File(java.io.File) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Produces(javax.ws.rs.Produces) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 78 with ApiResponses

use of io.swagger.v3.oas.models.responses.ApiResponses in project atlasmap by atlasmap.

the class AtlasService method listLibraryClasses.

/**
 * Retrieves a list of available Java library class names from uploaded JARs.
 * @param uriInfo URI info
 * @return class names
 */
@GET
@Path("/library/list")
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "List Library Classes", description = "Retrieves a list of available Java library class names from uploaded JARs.")
@ApiResponses(@ApiResponse(responseCode = "200", content = @Content(schema = @Schema(type = "ArrayList<String>")), description = "Return a list of loadable class names"))
public Response listLibraryClasses(@Context UriInfo uriInfo) {
    ArrayList<String> classNames;
    try {
        classNames = libraryLoader.getLibraryClassNames();
    } catch (Exception e) {
        if (LOG.isDebugEnabled()) {
            LOG.error("Library class retrieval error.", e);
        }
        throw new WebApplicationException("Error retrieving class names from uploaded JARs.");
    }
    byte[] serialized = toJson(classNames);
    if (LOG.isDebugEnabled()) {
        LOG.debug(new String(serialized));
    }
    return Response.ok().entity(serialized).build();
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) WebApplicationException(javax.ws.rs.WebApplicationException) AtlasException(io.atlasmap.api.AtlasException) IOException(java.io.IOException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 79 with ApiResponses

use of io.swagger.v3.oas.models.responses.ApiResponses in project atlasmap by atlasmap.

the class AtlasService method listFieldActions.

/**
 * Retrieves a list of available field action.
 * @param uriInfo URI info
 * @return {@link ActionDetails} serialized to JSON
 */
@GET
@Path("/fieldActions")
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "List FieldActions", description = "Retrieves a list of available field action")
@ApiResponses(@ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = ActionDetails.class)), description = "Return a list of field action detail"))
public Response listFieldActions(@Context UriInfo uriInfo) {
    ActionDetails details = new ActionDetails();
    if (atlasContextFactory == null || atlasContextFactory.getFieldActionService() == null) {
        return Response.ok().entity(toJson(details)).build();
    }
    details.getActionDetail().addAll(atlasContextFactory.getFieldActionService().listActionDetails());
    byte[] serialized = toJson(details);
    if (LOG.isDebugEnabled()) {
        LOG.debug(new String(serialized));
    }
    return Response.ok().entity(serialized).build();
}
Also used : ActionDetails(io.atlasmap.v2.ActionDetails) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 80 with ApiResponses

use of io.swagger.v3.oas.models.responses.ApiResponses in project atlasmap by atlasmap.

the class JsonService method inspect.

/**
 * Inspect a JSON schema or instance and return a Document object.
 * @param requestIn request
 * @return {@link JsonInspectionResponse}
 */
@POST
@Path("/inspect")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
@Operation(summary = "Inspect JSON", description = "Inspect a JSON schema or instance and return a Document object")
@RequestBody(description = "JsonInspectionRequest object", content = @Content(schema = @Schema(implementation = JsonInspectionRequest.class)))
@ApiResponses(@ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = JsonInspectionResponse.class)), description = "Return a Document object represented by JsonDocument"))
public Response inspect(InputStream requestIn) {
    JsonInspectionRequest request = fromJson(requestIn, JsonInspectionRequest.class);
    long startTime = System.currentTimeMillis();
    JsonInspectionResponse response = new JsonInspectionResponse();
    JsonDocument d = null;
    try {
        if (request.getType() == null || request.getJsonData() == null) {
            response.setErrorMessage("Json data and Instance or Schema inspection type must be specified in request");
        } else {
            JsonInspectionService s = new JsonInspectionService();
            String jsonData = cleanJsonData(request.getJsonData());
            if (!validJsonData(jsonData)) {
                response.setErrorMessage("Invalid json payload specified");
            } else {
                switch(request.getType()) {
                    case INSTANCE:
                        d = s.inspectJsonDocument(jsonData);
                        break;
                    case SCHEMA:
                        d = s.inspectJsonSchema(jsonData);
                        break;
                    default:
                        response.setErrorMessage("Unsupported inspection type: " + request.getType());
                        break;
                }
            }
        }
    } catch (Exception e) {
        LOG.error("Error inspecting json: " + e.getMessage(), e);
        response.setErrorMessage(e.getMessage());
    } finally {
        response.setExecutionTime(System.currentTimeMillis() - startTime);
    }
    AtlasUtil.excludeNotRequestedFields(d, request.getInspectPaths());
    response.setJsonDocument(d);
    return Response.ok().entity(toJson(response)).build();
}
Also used : JsonInspectionService(io.atlasmap.json.inspect.JsonInspectionService) JsonInspectionResponse(io.atlasmap.json.v2.JsonInspectionResponse) JsonInspectionRequest(io.atlasmap.json.v2.JsonInspectionRequest) JsonDocument(io.atlasmap.json.v2.JsonDocument) IOException(java.io.IOException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) WebApplicationException(javax.ws.rs.WebApplicationException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses) RequestBody(io.swagger.v3.oas.annotations.parameters.RequestBody)

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