-
Notifications
You must be signed in to change notification settings - Fork 762
fix(resolver): avoid duplicating enum values when nested in allOf #3939
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
Conversation
This change might have performance implications as we're stepping out of ApiDOM realm into JavaScript realm on possibly big chunks of data. |
return (targetElement, sourceElement) => { | ||
if (isArrayElement(targetElement) && isArrayElement(sourceElement)) { | ||
const primitiveElements = new ArrayElement([ | ||
...targetElement.findElements(isPrimitiveElement), |
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.
isPrimitiveElement
is more about distinction between generic APiDOM elements and Semantic ones. info
(from OpenAPI spec) vs object
. So this doesn't really do what is was intended to do.
Let's try to put all element inside one array, and R.uniqWith
with custom comparator which always returns false to array/object and bool for antyhing elase (use .equals
for ApiDOM realm comparisons).
customMerge: (keyElement) => { | ||
if (toValue(keyElement) === 'enum') { | ||
return (targetElement, sourceElement) => { | ||
if (isArrayElement(targetElement) && isArrayElement(sourceElement)) { |
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.
if (isArrayElement(targetElement) && isArrayElement(sourceElement)) { | |
if (includesClasses(['json-schema-enum'], targetElement) && includesClasses(['json-schema-enum'], sourceElement)) { |
return a.equals(toValue(b)); | ||
}; | ||
const mergedElements = targetElement.concat(sourceElement); | ||
const uniqueElements = uniqWith(areElementsEqual)(mergedElements.content); |
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.
const uniqueElements = uniqWith(areElementsEqual)(mergedElements.content); | |
const clone = cloneShallow(targetElement) | |
clone.content = uniqWith(areElementsEqual)([...targetElement.content, ...sourceElement.content]); | |
return clone; |
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.
One comment.
## [3.35.4](v3.35.3...v3.35.4) (2025-06-03) ### Bug Fixes * **resolver:** avoid duplicating enum values when nested in allOf ([#3939](#3939)) ([6caddd7](6caddd7))
🎉 This PR is included in version 3.35.4 🎉 The release is available on: Your semantic-release bot 📦🚀 |
No description provided.