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.
1 issue 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/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>
Add a request-body enum-decrease fixture pair and assert the console render prints the Removed enum value row, covering the removed-value branch of enumValues() in the incompatibilities listing. Signed-off-by: Vadim Lazuk <vadimlazuk5@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 fixture pairs
enum_diff_1.yaml/enum_diff_2.yamlfor added response enum values andenum_diff_request_body_1.yaml/enum_diff_request_body_2.yamlfor removed request enum values, with matching assertions inConsoleRenderTestandMarkdownRenderTest.Written for commit be1dd2b. Summary will update on new commits.