Add regression tests for phantom media type changes with byte format examples
Fixes #805
Diagnosis
The report in #805 has two symptoms with one shared root cause, and both appeared for the first time in 2.1.0-beta.12 (clean in 2.1.0-beta.11, as reported):
- swagger-parser deserializes the
exampleof a media type whose schema istype: string/format: byteas abyte[](it has done so since at least parser 2.1.22, so the parser version bumps in the 2.1.1 line were not the trigger). - The examples diff introduced by #671 (merged between 2.1.0-beta.11 and 2.1.0-beta.12) compared those examples with
Objects.equals, which is identity for arrays. Two separate parses of an identical spec produce distinctbyte[]instances, so every media type carrying a byte example was reported as changed even when the specs were identical - the phantom media type changes from the report. - Those media type changes come from the example alone, so no
ChangedSchemais attached.MarkdownRenderandHtmlRenderdereferenced that schema unconditionally, which produced theCannot invoke ... "schema" is nullfailures when generating reports.
All three defects are already fixed on master: #836 switched ChangedExample/ChangedExamples to Objects.deepEquals (value comparison for arrays), #869 added the null schema guard to HtmlRender, and #871 to MarkdownRender/AsciidocRender/ConsoleRender. The issue stayed open because nothing referenced it and nothing covered its exact scenario, so this PR adds that coverage instead of duplicating the fixes.
What this changes
New fixtures taken from the report (six response media types with format: byte examples, plus the shared component responses):
ContentDiffTest: identical specs produce no changes at all (the phantom change regression), and an example-only change is reported as backward compatible metadata changes for exactly the six media types, with no schema change attached (the render NPE precondition).MarkdownRenderTest,HtmlRenderTest,AsciidocRenderTest,ConsoleRenderTest: reports render without failing for the changed-example input.
Verification
- Full test suite green (276 tests in core, 13 in the Maven plugin module).
- CLI on the report's repro, identical specs:
No differences. Specifications are equivalent,--htmland--markdownreports generated,--fail-on-incompatibleexits 0 - matching the 2.1.0-beta.11 verdict. - CLI on the same specs with the six examples changed: backward compatible metadata changes, reports generated.
Summary by cubic
Adds regression tests for #805, where media types with type: string / format: byte examples were reported as changed even when both specs were identical. swagger-parser deserializes those examples as byte[], so the example comparison (since fixed by #836) treated separate parses as different; the renderer null-schema guards (#869, #871) were also already merged. This PR adds fixtures from the issue report to lock in the fixes.
ContentDiffTestverifies identical specs produce no changes and an example-only change is a backward compatible metadata change with no schema attached.- Markdown, HTML, Asciidoc, and Console render tests verify reports render without failing on that changed-example input.