Repository navigation
Conversation
…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 <vadimlazuk5@gmail.com>
There was a problem hiding this comment.
All reported issues were addressed across 6 files
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
… MarkdownRender The rename to visitingSchemas removed the protected handledSchemas field from a public renderer, breaking subclasses that read or clear it. Keep the established name and only change the set implementation to the identity-based one. Adds a regression test exercising the field. Signed-off-by: Vadim Lazuk <vadimlazuk5@gmail.com>
There was a problem hiding this comment.
1 issue found across 2 files (changes from recent commits).
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:385">
P2: The path-scoped guard stops true cycles, but it no longer memoizes shared subtrees. A component reachable through many paths is re-rendered in full each time, so output and runtime can grow exponentially with the depth of shared component nesting on large specs. Consider bounding the expansion (for example a depth or total-output limit) or memoizing rendered fragments per schema when the content does not depend on the path.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
| sb.append(schema(deepness, (ComposedSchema) schema, context)); | ||
| } else if (schema instanceof ArraySchema) { | ||
| sb.append(items(deepness, resolve(((ArraySchema) schema).getItems()), context)); | ||
| if (!handledSchemas.add(schema)) return ""; |
There was a problem hiding this comment.
P2: The path-scoped guard stops true cycles, but it no longer memoizes shared subtrees. A component reachable through many paths is re-rendered in full each time, so output and runtime can grow exponentially with the depth of shared component nesting on large specs. Consider bounding the expansion (for example a depth or total-output limit) or memoizing rendered fragments per schema when the content does not depend on the path.
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 385:
<comment>The path-scoped guard stops true cycles, but it no longer memoizes shared subtrees. A component reachable through many paths is re-rendered in full each time, so output and runtime can grow exponentially with the depth of shared component nesting on large specs. Consider bounding the expansion (for example a depth or total-output limit) or memoizing rendered fragments per schema when the content does not depend on the path.</comment>
<file context>
@@ -382,7 +382,7 @@ protected String schema(int deepness, ComposedSchema schema, DiffContext context
protected String schema(int deepness, Schema schema, DiffContext context) {
- if (!visitingSchemas.add(schema)) return "";
+ if (!handledSchemas.add(schema)) return "";
try {
StringBuilder sb = new StringBuilder();
</file context>
There was a problem hiding this comment.
The factual core is right: before this PR, handledSchemas (added in 72517cc for #331, the recursive-definitions stack-overflow fix) was a global, value-based HashSet with no removal, so already-visited subtrees were skipped everywhere. But that memo is exactly what #523 reported: a component reached from a second path, or any value-identical schema, was silently dropped from the report.
Measured on this branch: temporarily restoring the old global-memo semantics makes both regression tests added for #523 fail — each repeated enum/property value renders once (expected: 2 but was: 1), because the second reference site returns an empty string. So memoizing again would re-break #523.
True cycles still terminate under the current code (identity-based, path-scoped, removed on exit), so there is no unbounded recursion on recursive specs; the growth case needs a shared component DAG nested many levels deep. Keeping #523's completeness while bounding that expansion requires a visible output change — a back-link for shared subtrees or a depth/output limit — which is a rendering-semantics decision I would not fold into a bug-fix PR. Happy to follow up with either if the maintainer prefers bounded output.
Fixes #523
MarkdownRenderkept a globalhandledSchemasset (from the 2022 stack-overflow fix) keyed bySchema.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 testgreen (272 core tests).Summary by cubic
Fixes #523: repeated and value-identical schemas were silently dropped from markdown output, hiding enum changes and nested properties from the report.
MarkdownRenderkept a global set of handled schemas keyed by value-basedSchema.equals/hashCode, so any second reference to the same component — or any identical subtree — was treated as already rendered.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 render in full under every occurrence. The change keeps the existing protected
handledSchemasfield name so subclasses that read or clear it keep working.master; full reactor test suite passes (272 core tests).Written for commit 11b6afe. Summary will update on new commits.