Replace with javadocs only if no info was already provided by Swagger annotations
@@ -44,14 +44,20 @@ import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.PathItem.HttpMethod;
import io.swagger.v3.oas.models.parameters.Parameter;
+import io.swagger.v3.oas.models.responses.ApiResponse;
import io.swagger.v3.oas.models.servers.Server;
import io.swagger.v3.oas.models.tags.Tag;
public class OpenApiCustomizer {
+
private boolean dynamicBasePath;
+
private boolean replaceTags;
+
private DocumentationProvider javadocProvider;
+
private List<ClassResourceInfo> cris;
+
private String applicationPath;
public OpenAPIConfiguration customize(final OpenAPIConfiguration configuration) {
@@ -118,24 +124,31 @@ public class OpenApiCustomizer {
if (methods.containsKey(key) && javadocProvider != null) {
OperationResourceInfo ori = methods.get(key);
+ if (StringUtils.isBlank(subentry.getValue().getSummary())) {
subentry.getValue().setSummary(javadocProvider.getMethodDoc(ori));
+ }
if (subentry.getValue().getParameters() == null) {
List<Parameter> parameters = new ArrayList<>();
addParameters(parameters);
subentry.getValue().setParameters(parameters);
} else {
for (int i = 0; i < subentry.getValue().getParameters().size(); i++) {
+ if (StringUtils.isBlank(subentry.getValue().getParameters().get(i).getDescription())) {
subentry.getValue().getParameters().get(i).
setDescription(javadocProvider.getMethodParameterDoc(ori, i));
}
+ }
addParameters(subentry.getValue().getParameters());
}
if (subentry.getValue().getResponses() != null
&& !subentry.getValue().getResponses().isEmpty()) {
- subentry.getValue().getResponses().entrySet().iterator().next().getValue().
- setDescription(javadocProvider.getMethodResponseDoc(ori));
+ ApiResponse response =
+ subentry.getValue().getResponses().entrySet().iterator().next().getValue();
+ if (StringUtils.isBlank(response.getDescription())) {
+ response.setDescription(javadocProvider.getMethodResponseDoc(ori));
+ }
}
}
}
