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

Handle required schema object keys which are not in properties #462

Merged
merged 2 commits into from
May 12, 2020

Conversation

kylef
Copy link
Member

@kylef kylef commented May 12, 2020

Currently the OAS 2 parser losses information about required keys which are not found in properties. For example in the following schema:

type: object
required: name

Would produce an object element with no keys. With this patch we created the member element which contains the key and the required type attribute.

@kylef kylef added the bug Something isn't working label May 12, 2020
@kylef kylef force-pushed the kylef/oas2-required branch from f784a04 to 02afaa3 Compare May 12, 2020 15:55
@kylef kylef added the openapi2 label May 12, 2020
Copy link
Contributor

@opichals opichals left a comment

Choose a reason for hiding this comment

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

LGTM.

Perhaps I'd rather push to the content array already created but that's just a not required nit comment.

member.attributes.set('typeAttributes', ['required']);
return member;
});
element.content = element.content.concat(requiredMembers);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
element.content = element.content.concat(requiredMembers);
element.content.push(...requiredMembers);

Copy link
Member Author

Choose a reason for hiding this comment

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

Added 6457f33 which does the same for the other two cases in this file.

Copy link
Member Author

Choose a reason for hiding this comment

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

and thanks, I didn't think of doing it like that

@kylef kylef force-pushed the kylef/oas2-required branch from 02afaa3 to 6457f33 Compare May 12, 2020 16:43
@kylef kylef merged commit 4018f11 into master May 12, 2020
@kylef kylef deleted the kylef/oas2-required branch May 12, 2020 17:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working openapi2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants