Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -560,9 +560,13 @@ private LiTag li_changedParam(ChangedParameter changeParam) {
}
if (changeDescription) {
li.withText(" Notes ")
.with(del(leftParam.getDescription()).withClass(COMMENT))
.with(
del(null == leftParam.getDescription() ? "" : leftParam.getDescription())
.withClass(COMMENT))
.withText(" change into ")
.with(span(rightParam.getDescription()).withClass(COMMENT));
.with(
span(null == rightParam.getDescription() ? "" : rightParam.getDescription())
.withClass(COMMENT));
}
return li;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,33 @@ public void issue865_renderWithShowAllChangesDoesNotFailWhenSchemaIsNullButExamp
render.render(diff, outputStreamWriter);
assertThat(outputStream.toString()).isNotBlank();
}

@Test
public void issue364_renderShowsOldAndNewNotesForChangedParameter() {
HtmlRender render = new HtmlRender();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(outputStream);
ChangedOpenApi diff =
OpenApiCompare.fromLocations(
"issue-364-param-notes-1.json", "issue-364-param-notes-2.json");
render.render(diff, outputStreamWriter);
assertThat(outputStream.toString())
.contains("<del class=\"comment\">Number of pets returned</del>");
assertThat(outputStream.toString())
.contains("<span class=\"comment\">Maximum number of pets returned</span>");
}

@Test
public void issue364_renderDoesNotShowNullWhenParameterGainsNotes() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: The new tests never exercise a removed description, so the new-side null guard in li_changedParam is untested. Add a fixture where a parameter's description is deleted in the right spec and assert no null is rendered. The second test also re-renders the same diff as the first, so consider folding its doesNotContain(">null<") check into the first test.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At core/src/test/java/org/openapitools/openapidiff/core/output/HtmlRenderTest.java, line 63:

<comment>The new tests never exercise a removed description, so the new-side null guard in `li_changedParam` is untested. Add a fixture where a parameter's description is deleted in the right spec and assert no `null` is rendered. The second test also re-renders the same diff as the first, so consider folding its `doesNotContain(">null<")` check into the first test.</comment>

<file context>
@@ -43,4 +43,33 @@ public void issue865_renderWithShowAllChangesDoesNotFailWhenSchemaIsNullButExamp
+  }
+
+  @Test
+  public void issue364_renderDoesNotShowNullWhenParameterGainsNotes() {
+    HtmlRender render = new HtmlRender();
+    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
</file context>

HtmlRender render = new HtmlRender();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(outputStream);
ChangedOpenApi diff =
OpenApiCompare.fromLocations(
"issue-364-param-notes-1.json", "issue-364-param-notes-2.json");
render.render(diff, outputStreamWriter);
assertThat(outputStream.toString()).doesNotContain(">null<");
assertThat(outputStream.toString())
.contains("<span class=\"comment\">Filter expression</span>");
}
}
39 changes: 39 additions & 0 deletions core/src/test/resources/issue-364-param-notes-1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"openapi": "3.0.0",
"info": {
"description": "myDesc",
"title": "myTitle",
"version": "1.0.0"
},
"paths": {
"/pets": {
"get": {
"operationId": "listPets",
"parameters": [
{
"name": "limit",
"in": "query",
"required": false,
"description": "Number of pets returned",
"schema": {
"type": "integer"
}
},
{
"name": "filter",
"in": "query",
"required": false,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "successful operation"
}
}
}
}
}
}
40 changes: 40 additions & 0 deletions core/src/test/resources/issue-364-param-notes-2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"openapi": "3.0.0",
"info": {
"description": "myDesc",
"title": "myTitle",
"version": "1.0.0"
},
"paths": {
"/pets": {
"get": {
"operationId": "listPets",
"parameters": [
{
"name": "limit",
"in": "query",
"required": false,
"description": "Maximum number of pets returned",
"schema": {
"type": "integer"
}
},
{
"name": "filter",
"in": "query",
"required": false,
"description": "Filter expression",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "successful operation"
}
}
}
}
}
}