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

chore: simplify tracing of known type and required in nested rules #179

Merged
merged 1 commit into from
Jan 31, 2024

Conversation

ChALkeR
Copy link
Contributor

@ChALkeR ChALkeR commented Jan 26, 2024

After #177 and #178.

E.g. in allOf/oneOf, we just rely on the checks in parent rule, but only for type/required checks.

In the following schema, the nested allOf will just check for { required: ['yyy'] }:

{
  type: 'object',
  required: ['xxx','zzz'],
  allOf: [{
    type: 'object',
    required: ['xxx', 'yyy']
  }]
}

Properties/items can't be inherited as they affect evaluation checks, which should be isolated from the parent.

The new if (definitelyType(...typearr)) return null line which replaced manual check in history is now able to catch more cases, which can be seen in generated code diffs, when we got type information from a ref (compare after #178 is landed, or just review d997a64).

This also will make #176 (nested discriminators) stop complaining with just a single type: 'object' check on the top level.

@codecov-commenter
Copy link

codecov-commenter commented Jan 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (c87a7cc) 99.54% compared to head (8057cf2) 99.54%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
Files Coverage Δ
src/compile.js 99.29% <100.00%> (-0.01%) ⬇️

@mvayngrib
Copy link

@kklash could u review? i can't seem to request a review via the UI

@mvayngrib
Copy link

mvayngrib commented Jan 29, 2024

@ChALkeR ChALkeR force-pushed the chalker/fix-discriminator-typecheck/0 branch from 75dd90b to c87a7cc Compare January 29, 2024 13:12
@ChALkeR ChALkeR force-pushed the chalker/fix-discriminator-typecheck/1 branch from d997a64 to 8057cf2 Compare January 29, 2024 13:17
@ChALkeR
Copy link
Contributor Author

ChALkeR commented Jan 29, 2024

@mvayngrib Done!

@ChALkeR
Copy link
Contributor Author

ChALkeR commented Jan 29, 2024

This will still need a formal rebase after #177 and #178 land.

Copy link
Contributor

@kklash kklash left a comment

Choose a reason for hiding this comment

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

utACK

mvayngrib
mvayngrib previously approved these changes Jan 29, 2024
Copy link

@mvayngrib mvayngrib left a comment

Choose a reason for hiding this comment

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

utACK

take with a grain of salt, cause i'm a bit out of my depth and can't invest the time to understand this deeply atm 😓

kklash
kklash previously approved these changes Jan 31, 2024
Base automatically changed from chalker/fix-discriminator-typecheck/0 to master January 31, 2024 17:35
@ChALkeR ChALkeR dismissed stale reviews from kklash and mvayngrib January 31, 2024 17:35

The base branch was changed.

@ChALkeR
Copy link
Contributor Author

ChALkeR commented Jan 31, 2024

This apparently now needs a rebase and re-reviews.

E.g. in allOf/oneOf, we just rely on the checks in parent rule,
but only for type/required checks.

In the following schema, the nested allOf will just check
for `{ required: ['yyy'] }`:

```
{
  type: 'object',
  required: ['xxx','zzz'],
  allOf: [{
    type: 'object',
    required: ['xxx', 'yyy']
  }]
}
```

Properties/items can't be inherited as they affect evaluation checks,
which should be isolated from the parent.
@ChALkeR ChALkeR force-pushed the chalker/fix-discriminator-typecheck/1 branch from 8057cf2 to af30bc0 Compare January 31, 2024 17:37
@ChALkeR
Copy link
Contributor Author

ChALkeR commented Jan 31, 2024

Rebased

@mvayngrib
Copy link

This apparently now needs a rebase and re-reviews.

@ChALkeR maybe we want to disable that requirement?

@ChALkeR ChALkeR merged commit f28dd6f into master Jan 31, 2024
10 checks passed
@ChALkeR ChALkeR mentioned this pull request Feb 1, 2024
1 task
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