Repository navigation
Show changed enum values in console output #946
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -77,6 +77,18 @@ public void renderShowsWhatsChangedSectionWithCorrectFormattingWhenEndpointIsCha | |
| .containsSubsequence("- GET /widgets", "Parameter:", "- Changed query-param-1 in query"); | ||
| } | ||
|
|
||
| @Test | ||
| public void renderShowsChangedEnumValuesWhenResponseEnumValueIsAdded() { | ||
| 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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3: This test only covers the added-enum branch. Prompt for AI agents |
||
| render.render(diff, outputStreamWriter); | ||
| assertThat(outputStream.toString()) | ||
| .containsSubsequence( | ||
| "Schema: Broken compatibility", "Added enum value: [n].someProperty ENUM_VALUE_3"); | ||
| } | ||
|
|
||
| @Test | ||
| public void issue870_renderDoesNotFailWhenSchemaIsNullButExampleChanged() { | ||
| ConsoleRender render = new ConsoleRender(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| openapi: 3.0.0 | ||
| info: | ||
| description: myDesc | ||
| title: myTitle | ||
| version: 1.0.0 | ||
| paths: | ||
| /resources1/{id}/resources2: | ||
| get: | ||
| operationId: listResources2 | ||
| parameters: | ||
| - name: id | ||
| in: path | ||
| required: true | ||
| schema: | ||
| type: string | ||
| responses: | ||
| '200': | ||
| description: successful operation | ||
| content: | ||
| application/json: | ||
| schema: | ||
| type: array | ||
| items: | ||
| type: object | ||
| properties: | ||
| someProperty: | ||
| type: string | ||
| enum: | ||
| - ENUM_VALUE_1 | ||
| - ENUM_VALUE_2 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| openapi: 3.0.0 | ||
| info: | ||
| description: myDesc | ||
| title: myTitle | ||
| version: 1.0.0 | ||
| paths: | ||
| /resources1/{id}/resources2: | ||
| get: | ||
| operationId: listResources2 | ||
| parameters: | ||
| - name: id | ||
| in: path | ||
| required: true | ||
| schema: | ||
| type: string | ||
| responses: | ||
| '200': | ||
| description: successful operation | ||
| content: | ||
| application/json: | ||
| schema: | ||
| type: array | ||
| items: | ||
| type: object | ||
| properties: | ||
| someProperty: | ||
| type: string | ||
| enum: | ||
| - ENUM_VALUE_1 | ||
| - ENUM_VALUE_2 | ||
| - ENUM_VALUE_3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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