Open KiranReddy0808 opened 2 years ago
This is expected behavior, although I admit it's somewhat confusing. It's certainly one of these features I'd love to get changed, but it's very tricky since it's been working this way since the very first release of Spectral, so it'd be a notable breaking change. I'll keep this issue open to keep track of that behavior.
Thanks @P0lip for the answer!
Describe the bug Given a path to value which is not an object (string, number) from given in rule. When a field is defined for the rule. There is no error being triggered saying the field is not defined.
To Reproduce
Expected behavior An error should be expected that there is no field named "title" under path info.apiname. There is no error because getLintTargets(targetValue, field) returns the original targetValue and path as empty array (which is not of type void 0 for defined function to pickup) when typeof targetValue is not object.
Rules: https://github.com/KiranReddy0808/basic-oas-spec/blob/main/.spectral.yaml API: https://github.com/KiranReddy0808/basic-oas-spec/blob/main/api-two.yaml
GitHub Action Run: https://github.com/KiranReddy0808/basic-oas-spec/actions/runs/1967689613
Environment (remove any that are not applicable):
Additional context As extra fields are allowed in OAS. Incorrect definition of those fields will go through. I'm not sure if it's expected behaviour. So please close this ticket if it's already discussed or is correct!
Thanks!