Repository navigation
Conversation
MarkdownRender reports added and removed enum values, but ConsoleRender stayed silent about them, so the default CLI output gave no hint about what broke backward compatibility when an enum value was added to a response schema (or removed from a request schema). Mirror the enum change reporting in ConsoleRender with terse rows in the existing incompatibilities listing, keeping the property path prefix convention used by neighboring rows. Fixes OpenAPITools#620 Signed-off-by: Inf1mum <vadimlazuk5@gmail.com>
There was a problem hiding this comment.
2 issues found across 5 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. 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. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="core/src/test/java/org/openapitools/openapidiff/core/output/ConsoleRenderTest.java">
<violation number="1" location="core/src/test/java/org/openapitools/openapidiff/core/output/ConsoleRenderTest.java:85">
P3: This test only covers the added-enum branch. `ConsoleRender.enumValues` also emits `Removed enum value` lines, which the PR description calls out, but no console test asserts that output. Add a case with a removed value (for example, swap the fixture order) and assert the `Removed enum value: [n].someProperty ...` line.</violation>
</file>
<file name="core/src/main/java/org/openapitools/openapidiff/core/output/ConsoleRender.java">
<violation number="1" location="core/src/main/java/org/openapitools/openapidiff/core/output/ConsoleRender.java:201">
P2: This prints every enum change inside the 'Broken compatibility' block, including directions that are compatible for this context. For example, a response enum value removed next to a missing property would be reported as 'Removed enum value', though that removal does not break compatibility. Filter by direction, for example by checking `changedEnum.isItemsChanged()` per side and the request/response context.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
| String type = type(schema.getOldSchema()) + " -> " + type(schema.getNewSchema()); | ||
| sb.append(property(propName, "Changed property type", type)); | ||
| } | ||
| if (schema.getEnumeration() != null) { |
There was a problem hiding this comment.
P2: This prints every enum change inside the 'Broken compatibility' block, including directions that are compatible for this context. For example, a response enum value removed next to a missing property would be reported as 'Removed enum value', though that removal does not break compatibility. Filter by direction, for example by checking changedEnum.isItemsChanged() per side and the request/response context.
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/main/java/org/openapitools/openapidiff/core/output/ConsoleRender.java, line 201:
<comment>This prints every enum change inside the 'Broken compatibility' block, including directions that are compatible for this context. For example, a response enum value removed next to a missing property would be reported as 'Removed enum value', though that removal does not break compatibility. Filter by direction, for example by checking `changedEnum.isItemsChanged()` per side and the request/response context.</comment>
<file context>
@@ -197,6 +198,9 @@ private String incompatibilities(String propName, final ChangedSchema schema) {
String type = type(schema.getOldSchema()) + " -> " + type(schema.getNewSchema());
sb.append(property(propName, "Changed property type", type));
}
+ if (schema.getEnumeration() != null) {
+ sb.append(enumValues(propName, schema.getEnumeration()));
+ }
</file context>
| ConsoleRender render = new ConsoleRender(); | ||
| ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); | ||
| OutputStreamWriter outputStreamWriter = new OutputStreamWriter(outputStream); | ||
| ChangedOpenApi diff = OpenApiCompare.fromLocations("enum_diff_1.yaml", "enum_diff_2.yaml"); |
There was a problem hiding this comment.
P3: This test only covers the added-enum branch. ConsoleRender.enumValues also emits Removed enum value lines, which the PR description calls out, but no console test asserts that output. Add a case with a removed value (for example, swap the fixture order) and assert the Removed enum value: [n].someProperty ... line.
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/ConsoleRenderTest.java, line 85:
<comment>This test only covers the added-enum branch. `ConsoleRender.enumValues` also emits `Removed enum value` lines, which the PR description calls out, but no console test asserts that output. Add a case with a removed value (for example, swap the fixture order) and assert the `Removed enum value: [n].someProperty ...` line.</comment>
<file context>
@@ -77,6 +77,18 @@ public void renderShowsWhatsChangedSectionWithCorrectFormattingWhenEndpointIsCha
+ ConsoleRender render = new ConsoleRender();
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ OutputStreamWriter outputStreamWriter = new OutputStreamWriter(outputStream);
+ ChangedOpenApi diff = OpenApiCompare.fromLocations("enum_diff_1.yaml", "enum_diff_2.yaml");
+ render.render(diff, outputStreamWriter);
+ assertThat(outputStream.toString())
</file context>
Fixes #620
What changed
MarkdownRender reports added and removed enum values, but the default CLI (console) output stayed silent about them. Following the example from the issue, diffing two specs where an enum value is added to a response schema used to print only:
with no hint about what actually broke backward compatibility.
ConsoleRender now mirrors the enum change reporting of MarkdownRender inside its existing incompatibilities listing, keeping the terse style of the neighboring console rows and the dotted property-path prefix convention:
Removed enum values are reported the same way (
Removed enum value: ...), e.g. when a value disappears from a request schema.Fixtures and tests
enum_diff_1.yaml/enum_diff_2.yamlreproducing the scenario from the issue (response array items with an enum property that gainsENUM_VALUE_3).ConsoleRenderTest: asserts the console output reports the added enum value underSchema: Broken compatibility.MarkdownRenderTest: asserts the equivalent markdown output (Added enum value/ENUM_VALUE_3) on the same fixture pair, guarding existing markdown behavior.Scope note
This PR is a first slice of the renderer parity work sketched in the issue: it covers schema enum-value changes in ConsoleRender only, no renderer rewrite. The gaps mentioned in the issue discussion remain possible follow-ups:
getOneOfSchema()the way MarkdownRender does (reported by the community in the issue comments).Validation
mvnw -pl core test: 272 tests, 0 failuresmvnw -pl cli test: build success (module has no test sources)Summary by cubic
Fixes the console (
ConsoleRender) staying silent about added and removed enum values, so the default CLI output now prints rows likeAdded enum value: [n].someProperty ENUM_VALUE_3under the broken-compatibility listing, matching whatMarkdownRenderalready reports. Compatible schema changes still print no details, andgetOneOfSchema()is still not walked; this is a first slice of renderer parity with no renderer rewrite.Adds a fixture pair (
enum_diff_1.yaml/enum_diff_2.yaml) that adds an enum value to a response schema, plus matching assertions inConsoleRenderTestandMarkdownRenderTest.Written for commit 0fbb4ae. Summary will update on new commits.