Skip to content
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

refactor: work-in-progress proposed refactor of composed schema restrictions #506

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

hudlow
Copy link
Member

@hudlow hudlow commented Oct 12, 2022

Currently one failing test and some missing tests for the new utility, but posting this PR for feedback on the approach.

padamstx and others added 3 commits October 7, 2022 12:14
This commit introduces the new spectral-style
'composed-schema-restrictions' rule, which will verify that
oneOf and anyOf compositions comply with the restrictions
imposed by the SDK generator.

Signed-off-by: Phil Adams <[email protected]>
@hudlow hudlow requested review from dpopp07 and padamstx October 12, 2022 03:46
Copy link
Member

@dpopp07 dpopp07 left a comment

Choose a reason for hiding this comment

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

Okay after re-reading, my only feedback is to add a little detail to one of the comments for overall readability.

The other feedback I had turned out to be irrelevant on second look.

I still think it would be helpful to 1) validate that all schemas in a composed schema are objects and 2) add some additional test cases

}
// Only object schemas have properties
if (isObjectSchema(schema)) {
// Collects all composed property schemas indexed by the name of the property they define
Copy link
Member

@dpopp07 dpopp07 Oct 18, 2022

Choose a reason for hiding this comment

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

Would be easier to read (for me, at least) if this comment elaborated slightly more on the data structure returned by getPropertySchemasByName. Something to let the reader know the map values are lists of schemas all defining properties of common names.

@padamstx
Copy link
Member

...validate that all schemas in a composed schema are objects

Actually, if we encounter a primitive schema that also happens to contain a oneOf/anyOf (perhaps to define different sets of contstraints), we don't really care what is contained in the oneOf/anyOf list because we'll end up just refactoring the oneOf/anyOf list away during pre-processing.
If we're dealing with an object schema that contains a oneOf/anyOf, then its oneOf/anyOf list must contain only object schemas.

@dpopp07
Copy link
Member

dpopp07 commented Oct 18, 2022

Actually, if we encounter a primitive schema that also happens to contain a oneOf/anyOf (perhaps to define different sets of contstraints), we don't really care what is contained in the oneOf/anyOf list because we'll end up just refactoring the oneOf/anyOf list away during pre-processing.
If we're dealing with an object schema that contains a oneOf/anyOf, then its oneOf/anyOf list must contain only object schemas.

Yes, I summarized around that nuance - thanks for clarifying!

@CLAassistant
Copy link

CLAassistant commented Nov 11, 2022

CLA assistant check
All committers have signed the CLA.

@hudlow hudlow changed the base branch from composed-schema-restrictions to main November 11, 2022 05:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants