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

Spectral should generate paths for unresolved documents #608

Closed
P0lip opened this issue Sep 29, 2019 · 1 comment · Fixed by #839
Closed

Spectral should generate paths for unresolved documents #608

P0lip opened this issue Sep 29, 2019 · 1 comment · Fixed by #839
Labels
t/bug Something isn't working

Comments

@P0lip
Copy link
Contributor

P0lip commented Sep 29, 2019

The case described in #572 (comment) got me me thinking.
Spectral strives to generate path pointing to an actual value
The caveat here is that we operate on a resolved document, so the produced path reflects the state of the resolved document, rather than the initial input.
In most cases this is not a big deal, since we still provide fairly accurate location of the error (we traverse the document up until the closest match is found), and the path itself is likely to be reasonable either, as it's the result of $ref resolving.

Now, if we take the ruleset provided in the comment and run it against the portion of document, the reported error has the following path: ["paths", "/agreements", "get", "responses", "200", "headers"] (note, the output path might be slightly vary in your case, as I modified the code a bit, and haven't pushed/released it yet, but should be quite similar). Looks reasonably, no?
Well, true, but the faulty part of the spec can be accessed under this path ["responses", "GetAgreementsOk", "headers"], so shall we report it?
I'd say so, but providing such a path might be slightly misleading for some.
That said, I'm not really sure whether or not to address that potential quirk.
Both approaches have their pros and cons.

@P0lip P0lip added the t/bug Something isn't working label Sep 29, 2019
@philsturgeon
Copy link
Contributor

When we are printing things out to the console we usually want to use the unresolved path, because we are showing the relevant file so we only want to help them navigate to the part of the file that is the problem.

It is rather rare we actually want to display the path within the fully resolved thing. Technically we need it for all sorts of things internally, but I'm not sure what use cases the user would want it?

@P0lip P0lip mentioned this issue Dec 7, 2019
4 tasks
@P0lip P0lip mentioned this issue Dec 17, 2019
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants