use of io.swagger.v3.oas.annotations.responses.ApiResponses in project atlasmap by atlasmap.
the class AtlasService method listMappings.
/**
* Retrieves a list of mapping file name saved with specified mapping definition ID.
* @param uriInfo URI info
* @param filter filter
* @param mappingDefinitionId mapping definition ID
* @return A list of mapping file name in {@link StringMap}
*/
@GET
@Path("/mappings/{mappingDefinitionId}")
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "List Mappings", description = "Retrieves a list of mapping file name saved with specified mappingDefinitionId")
@ApiResponses(@ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = StringMap.class)), description = "Return a list of a pair of mapping file name and content"))
public Response listMappings(@Context UriInfo uriInfo, @QueryParam("filter") final String filter, @Parameter(description = "Mapping Definition ID") @PathParam("mappingDefinitionId") Integer mappingDefinitionId) {
StringMap sMap = new StringMap();
LOG.debug("listMappings with filter '{}'", filter);
ADMArchiveHandler handler = loadExplodedMappingDirectory(mappingDefinitionId);
AtlasMapping map = handler.getMappingDefinition();
if (map == null) {
return Response.ok().entity(toJson(sMap)).build();
}
StringMapEntry mapEntry = new StringMapEntry();
mapEntry.setName(map.getName());
UriBuilder builder = uriInfo.getBaseUriBuilder().path("v2").path("atlas").path("mapping").path(map.getName());
mapEntry.setValue(builder.build().toString());
sMap.getStringMapEntry().add(mapEntry);
byte[] serialized = toJson(sMap);
if (LOG.isDebugEnabled()) {
LOG.debug(new String(serialized));
}
return Response.ok().entity(serialized).build();
}
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 carbon-apimgt by wso2.
the class OAS3Parser method createOperation.
/**
* Creates a new operation object using the URI template object
*
* @param resource API resource data
* @return a new operation object using the URI template object
*/
private Operation createOperation(SwaggerData.Resource resource) {
Operation operation = new Operation();
populatePathParameters(operation, resource.getPath());
updateOperationManagedInfo(resource, operation);
ApiResponses apiResponses = new ApiResponses();
ApiResponse apiResponse = new ApiResponse();
apiResponse.description("OK");
apiResponses.addApiResponse(APIConstants.SWAGGER_RESPONSE_200, apiResponse);
operation.setResponses(apiResponses);
return operation;
}
use of io.swagger.v3.oas.annotations.responses.ApiResponses in project atlasmap by atlasmap.
the class AtlasService method processMappingRequest.
/**
* Processes mapping by feeding input data.
* @param request request
* @param uriInfo URI info
* @return {@link ProcessMappingResponse} which holds the result of the mappings
*/
@PUT
@Path("/mapping/process")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Process Mapping", description = "Process Mapping by feeding input data")
@RequestBody(description = "Mapping file content", content = @Content(schema = @Schema(implementation = AtlasMapping.class)))
@ApiResponses({ @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = ProcessMappingResponse.class)), description = "Return a mapping result"), @ApiResponse(responseCode = "204", description = "Skipped empty mapping execution") })
public Response processMappingRequest(InputStream request, @Context UriInfo uriInfo) {
ProcessMappingRequest pmr = fromJson(request, ProcessMappingRequest.class);
if (pmr.getAtlasMapping() != null) {
throw new WebApplicationException("Whole mapping execution is not yet supported");
}
Mapping mapping = pmr.getMapping();
if (mapping == null) {
return Response.noContent().build();
}
Audits audits = null;
try {
if (LOG.isDebugEnabled()) {
LOG.debug("Preview request: {}", new String(toJson(mapping)));
}
audits = previewContext.processPreview(mapping);
} catch (AtlasException e) {
throw new WebApplicationException("Unable to process mapping preview", e);
}
ProcessMappingResponse response = new ProcessMappingResponse();
response.setMapping(mapping);
if (audits != null) {
response.setAudits(audits);
}
byte[] serialized = toJson(response);
if (LOG.isDebugEnabled()) {
LOG.debug("Preview outcome: {}", new String(serialized));
}
return Response.ok().entity(serialized).build();
}
use of io.swagger.v3.oas.annotations.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();
}
Aggregations