Skip to content

#523 render repeated and value-identical schemas in markdown output - #965

Open
Inf1mum wants to merge 1 commit into
OpenAPITools:masterfrom
Inf1mum:fix/523-md-enum-property
Open

Inf1mum wants to merge 1 commit into
OpenAPITools:masterfrom
Inf1mum:fix/523-md-enum-property

Conversation

@Inf1mum

@Inf1mum Inf1mum commented Nov 18, 2026 •

Copy link
Copy Markdown

Fixes #523

MarkdownRender kept a global handledSchemas set (from the 2022 stack-overflow fix) keyed by Schema.equals/hashCode, which are value-based: any second reference to the same component — and any value-identical subtree — was treated as already rendered and silently dropped from the report, so enum changes and nested properties vanished from the .md output.

The set is replaced with an identity-based set of schemas on the current recursion path (added on entry, removed on exit): true recursive definitions still terminate, while repeated references now render in full under every occurrence. Both issue samples now render complete output; 4 new fixture-based regressions (all fail on master). Full reactor mvn test green (272 core tests).


Summary by cubic

Fixes #523: repeated and value-identical schemas were silently dropped from markdown output. MarkdownRender kept a global set of handled schemas keyed by Schema.equals/hashCode, which are value-based, so any second reference to the same component — or any value-identical subtree — was treated as already rendered and its enum changes and nested properties vanished from the report.

Replaced the global set with an identity-based set of schemas on the current recursion path (added on entry, removed on exit), so true recursive definitions still terminate while repeated references now render in full under every occurrence.

  • Adds 4 fixture-based regression tests that all fail on master; full reactor test suite passes (272 core tests).

Written for commit 0d30511. Summary will update on new commits.

View guided diff

…chemas in markdown output

The markdown renderer kept a global set of already-rendered schemas.
Swagger Schema implements equals/hashCode by value, so any second
schema with identical content (or a repeated reference to the same
component) had its whole subtree silently dropped from the report.

Replace the global set with an identity-based set of the schemas on
the current recursion path: recursive definitions still terminate,
while repeated references and value-identical subtrees are now fully
reported.

Signed-off-by: Inf1mum <[email protected]>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 6 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/MarkdownRender.java">

<violation number="1" location="core/src/main/java/org/openapitools/openapidiff/core/output/MarkdownRender.java:46">
P3: This removes the existing protected `handledSchemas` field from a public renderer, breaking subclasses that access it. Preserve `handledSchemas` as the field name (or provide a compatibility alias) while changing its set implementation.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

protected RefPointer<Schema<?>> refPointer = new RefPointer<>(RefType.SCHEMAS);
protected ChangedOpenApi diff;
protected Set<Schema<?>> handledSchemas = new HashSet<>();
protected Set<Schema<?>> visitingSchemas = Collections.newSetFromMap(new IdentityHashMap<>());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: This removes the existing protected handledSchemas field from a public renderer, breaking subclasses that access it. Preserve handledSchemas as the field name (or provide a compatibility alias) while changing its set implementation.

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/MarkdownRender.java, line 46:

<comment>This removes the existing protected `handledSchemas` field from a public renderer, breaking subclasses that access it. Preserve `handledSchemas` as the field name (or provide a compatibility alias) while changing its set implementation.</comment>

<file context>
@@ -42,7 +43,7 @@ public class MarkdownRender implements Render {
   protected RefPointer<Schema<?>> refPointer = new RefPointer<>(RefType.SCHEMAS);
   protected ChangedOpenApi diff;
-  protected Set<Schema<?>> handledSchemas = new HashSet<>();
+  protected Set<Schema<?>> visitingSchemas = Collections.newSetFromMap(new IdentityHashMap<>());
   /**
    * A parameter which indicates whether or not metadata (summary and metadata) changes should be
</file context>
Suggested change
protected Set<Schema<?>> visitingSchemas = Collections.newSetFromMap(new IdentityHashMap<>());
protected Set<Schema<?>> handledSchemas = Collections.newSetFromMap(new IdentityHashMap<>());
protected Set<Schema<?>> visitingSchemas = handledSchemas;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

enum and properties change in schemas not reported in .md file generated after diff check

1 participant