Fix code
'io.smallrye.openapi.api.models.media.ContentImpl' is deprecated since version 4.0 and marked for removal
package com.banank.platform.services.profile.exception.utils;
import org.eclipse.microprofile.openapi.OASFilter;
import org.eclipse.microprofile.openapi.models.Operation;
import org.eclipse.microprofile.openapi.models.responses.APIResponse;
import org.eclipse.microprofile.openapi.models.responses.APIResponses;
import io.smallrye.openapi.api.models.media.ContentImpl;
import io.smallrye.openapi.api.models.media.MediaTypeImpl;
import io.smallrye.openapi.api.models.responses.APIResponseImpl;
import io.smallrye.openapi.api.models.responses.APIResponsesImpl;
import java.util.List;
import java.util.Map;
public class PlatformApiOASFilter implements OASFilter {
@Override
public Operation updateOperation(Operation operation) {
if (operation == null || operation.getOperationId() == null) {
return operation;
}
String operationId = operation.getOperationId();
for (Map.Entry<String, List<PlatformApiResponse>> entry : ApiPlatformRegistry.getAll().entrySet()) {
String[] parts = entry.getKey().split("#");
String className = parts[0];
String methodName = parts[1];
if (!operationId.contains(className) || !operationId.contains(methodName)) {
continue;
}
APIResponses responses = operation.getResponses();
if (responses == null) {
responses = new APIResponsesImpl();
operation.setResponses(responses);
}
for (PlatformApiResponse error : entry.getValue()) {
APIResponse apiResponse = new APIResponseImpl()
.description(error.description());
if (error.content().length > 0) {
ContentImpl content = new ContentImpl();
for (var c : error.content()) {
content.addMediaType(c.mediaType(), new MediaTypeImpl());
}
apiResponse.setContent(content);
}
responses.addAPIResponse(error.responseCode(), apiResponse);
}
}
return operation;
}
}
Method does not override method from its superclass