Skip to content
Merged
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 @@ -342,13 +342,15 @@ private LiTag li_missingRequest(String name, MediaType request) {
}

private LiTag li_changedRequest(String name, ChangedMediaType request) {
LiTag li =
li().with(div_changedSchema(request.getSchema()))
.withText(String.format("Changed body: '%s'", name));
if (request.isIncompatible() && !showAllChanges) {
incompatibilities(li, request.getSchema());
} else if (showAllChanges) {
allChanges(li, request.getSchema());
LiTag li = li().withText(String.format("Changed body: '%s'", name));
ChangedSchema schema = request.getSchema();
if (schema != null) {
li.with(div_changedSchema(schema));
if (request.isIncompatible() && !showAllChanges) {
incompatibilities(li, schema);
} else if (showAllChanges) {
allChanges(li, schema);
}
}
return li;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,28 @@ public void renderDoesNotFailWhenPropertyHasBeenRemoved() {
render.render(diff, outputStreamWriter);
assertThat(outputStream.toString()).isNotBlank();
}

@Test
public void issue865_renderDoesNotFailWhenSchemaIsNullButExampleChanged() {
HtmlRender render = new HtmlRender();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(outputStream);
ChangedOpenApi diff =
OpenApiCompare.fromLocations(
"issue-865-null-schema-1.yaml", "issue-865-null-schema-2.yaml");
render.render(diff, outputStreamWriter);
assertThat(outputStream.toString()).isNotBlank();
}

@Test
public void issue865_renderWithShowAllChangesDoesNotFailWhenSchemaIsNullButExampleChanged() {
HtmlRender render = new HtmlRender(true);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(outputStream);
ChangedOpenApi diff =
OpenApiCompare.fromLocations(
"issue-865-null-schema-1.yaml", "issue-865-null-schema-2.yaml");
render.render(diff, outputStreamWriter);
assertThat(outputStream.toString()).isNotBlank();
}
}
21 changes: 21 additions & 0 deletions core/src/test/resources/issue-865-null-schema-1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
openapi: 3.0.2
info:
description: Test for null schema issue
title: Null Schema Test
version: 1.0.0
paths:
/test:
post:
requestBody:
content:
application/json:
example: original example
schema:
type: string
responses:
'200':
description: Success
content:
application/json:
schema:
type: string
21 changes: 21 additions & 0 deletions core/src/test/resources/issue-865-null-schema-2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
openapi: 3.0.2
info:
description: Test for null schema issue
title: Null Schema Test
version: 1.0.0
paths:
/test:
post:
requestBody:
content:
application/json:
example: updated example
schema:
type: string
responses:
'200':
description: Success
content:
application/json:
schema:
type: string