fix(resolver): avoid duplicating enum values when nested in allOf#3939
Merged
fix(resolver): avoid duplicating enum values when nested in allOf#3939
Conversation
char0n
approved these changes
May 30, 2025
Contributor
|
This change might have performance implications as we're stepping out of ApiDOM realm into JavaScript realm on possibly big chunks of data. |
char0n
reviewed
Jun 2, 2025
| return (targetElement, sourceElement) => { | ||
| if (isArrayElement(targetElement) && isArrayElement(sourceElement)) { | ||
| const primitiveElements = new ArrayElement([ | ||
| ...targetElement.findElements(isPrimitiveElement), |
Contributor
There was a problem hiding this comment.
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).
char0n
reviewed
Jun 3, 2025
| customMerge: (keyElement) => { | ||
| if (toValue(keyElement) === 'enum') { | ||
| return (targetElement, sourceElement) => { | ||
| if (isArrayElement(targetElement) && isArrayElement(sourceElement)) { |
Contributor
There was a problem hiding this comment.
Suggested change
| if (isArrayElement(targetElement) && isArrayElement(sourceElement)) { | |
| if (includesClasses(['json-schema-enum'], targetElement) && includesClasses(['json-schema-enum'], sourceElement)) { |
char0n
reviewed
Jun 3, 2025
| return a.equals(toValue(b)); | ||
| }; | ||
| const mergedElements = targetElement.concat(sourceElement); | ||
| const uniqueElements = uniqWith(areElementsEqual)(mergedElements.content); |
Contributor
There was a problem hiding this comment.
Suggested change
| const uniqueElements = uniqWith(areElementsEqual)(mergedElements.content); | |
| const clone = cloneShallow(targetElement) | |
| clone.content = uniqWith(areElementsEqual)([...targetElement.content, ...sourceElement.content]); | |
| return clone; |
swagger-bot
pushed a commit
that referenced
this pull request
Jun 3, 2025
## [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))
Contributor
|
🎉 This PR is included in version 3.35.4 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.