Skip to content
This repository was archived by the owner on Nov 8, 2024. It is now read-only.

Fix duplicity in generated scheme with swapped order of member object wit fixed-type#714

Merged
klokane merged 1 commit intomasterfrom
klokane/fix-scheme-duplicity
Jun 18, 2019
Merged

Fix duplicity in generated scheme with swapped order of member object wit fixed-type#714
klokane merged 1 commit intomasterfrom
klokane/fix-scheme-duplicity

Conversation

@klokane
Copy link
Copy Markdown
Contributor

@klokane klokane commented Jun 18, 2019

Closes #664

@klokane klokane requested review from kylef and tjanc June 18, 2019 09:55
bool hasEqualMembers(const Object& lhs, const Object& rhs)
{
using itemType = typename Object::container_type::const_reference;
for (itemType item : lhs.data) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If I understand this logic correctly, if there is the following I think they'll be treated as equal.

LHS:

+ name: doe

RHS:

+ name: doe
+ additional: true

Since the logic loops over lhs members and verifies they are equal to rhs. Additional RHS members are ignored.

Perhaps a guard that the length of lhs and rhs are equal at the top of the function would solve this problem?

Copy link
Copy Markdown
Contributor Author

@klokane klokane Jun 18, 2019

Choose a reason for hiding this comment

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

There is on upper level checked count of members is equal.

https://github.com/apiaryio/drafter/pull/714/files#diff-c71b7d4a5846e44057ccc118bacbe934R59

So situation you describe should not happen. But if you like I can make it in one step.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@klokane you're right, I overlooked that part.

@klokane klokane merged commit 910162c into master Jun 18, 2019
@klokane klokane deleted the klokane/fix-scheme-duplicity branch June 18, 2019 14:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

De-duplicate equal object entries in schema "anyOf" field for fixed-type array

2 participants