Skip to content

Commit 71e7dfc

Browse files
authored
Merge pull request #65 from quen2404/fix/issue-64-npe-request-content
Fix NPE when only description changed in request content
2 parents 59eb9db + 6e97950 commit 71e7dfc

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/main/java/com/qdesrame/openapi/diff/output/MarkdownRender.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ protected String listEndpoints(List<ChangedOperation> changedOperations) {
104104
if (operation.resultRequestBody().isDifferent()) {
105105
details
106106
.append(titleH5("Request:"))
107+
.append(metadata("Description", operation.getRequestBody().getDescription()))
107108
.append(bodyContent(operation.getRequestBody().getContent()));
108109
}
109110
if (operation.resultApiResponses().isDifferent()) {
@@ -212,6 +213,9 @@ protected String itemHeader(String title, String mediaType, String description)
212213
}
213214

214215
protected String bodyContent(String prefix, ChangedContent changedContent) {
216+
if (changedContent == null) {
217+
return "";
218+
}
215219
StringBuilder sb = new StringBuilder("\n");
216220
sb.append(listContent(prefix, "New content type", changedContent.getIncreased()));
217221
sb.append(listContent(prefix, "Deleted content type", changedContent.getMissing()));
@@ -499,7 +503,7 @@ protected String metadata(String beginning, String name, ChangedMetadata changed
499503
if (changedMetadata == null) {
500504
return "";
501505
}
502-
if (isUnchanged(changedMetadata) && showChangedMetadata) {
506+
if (!isUnchanged(changedMetadata) && showChangedMetadata) {
503507
return format(
504508
"Changed %s:\n%s\nto:\n%s\n\n",
505509
name,

0 commit comments

Comments
 (0)