What I needed to do was:
SwaggerConfiguration oasConfig = new SwaggerConfiguration()
.openApi(baseModel)
.readerClass(MyCustomReader.class.getName()) // <- HERE
.prettyPrint(true)
.resourcePackages(Set.of("my.api.package"));
io.swagger.v3.jaxrs2.Reader;
and overriding the read
methodpublic class MyCustomReader extends Reader {
@Override
public OpenAPI read(Class<?> cls,
String parentPath,
String parentMethod,
boolean isSubresource,
RequestBody parentRequestBody,
ApiResponses apiResponses,
Set<String> parentTags,
List<Parameter> parentParameters,
Set<Class<?>> scannedResources)
{
OpenAPI openAPI = super.read(cls, parentPath, parentMethod, isSubresource, parentRequestBody, apiResponses,
parentTags, parentParameters, scannedResources);
return populateMissingDescriptions(openAPI);
}
public static OpenAPI populateMissingDescriptions(OpenAPI openAPI) {
if (openAPI.getPaths() != null) {
for (Entry<String, PathItem> entry : openAPI.getPaths().entrySet()) {
String path = entry.getKey();
PathItem pathItem = entry.getValue();
for (Operation operation : pathItem.readOperations()) {
if (operation.getResponses() != null) {
for (Entry<String, ApiResponse> e : operation.getResponses().entrySet()) {
String status = e.getKey();
ApiResponse response = e.getValue();
if (response.getDescription() == null) {
response.setDescription("");
}
}
}
}
}
}
return openAPI;
}
}