-
-
Notifications
You must be signed in to change notification settings - Fork 240
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
fix: absolute paths #839
fix: absolute paths #839
Conversation
0700df0
to
a797ff0
Compare
cc @nulltoken |
@P0lip Thanks for the ping! I'll come back to you tomorrow with some feedback. Cool with you? |
@P0lip Feedback!! Running the tip of this branch against #658 repro case generates the following: $ git log -1
commit 4ccc94c4678899ad15076c4c14f8c8c1d0deac13 (HEAD -> fix/path-result, upstream/fix/path-result)
Merge: ee8b7d9 c9017a5
Author: Jakub Rożek <jakub@stoplight.io>
Date: Wed Dec 11 19:26:44 2019 +0100
Merge branch 'develop' into fix/path-result
$ yarn cli lint --ruleset ./repro/ruleset.yaml ./repro/URIError.yaml
yarn run v1.19.2
$ node -r ts-node/register -r tsconfig-paths/register src/cli/index.ts lint --ruleset ./repro/ruleset.yaml ./rep
ro/URIError.yaml
Missing baseUrl in compilerOptions. tsconfig-paths will be skipped
Function 'oasOpSecurityDefined' could not be loaded: Not Found
Function 'oasOpParams' could not be loaded: Not Found
Function 'oasOp2xxResponse' could not be loaded: Not Found
Function 'oasOpFormDataConsumeCheck' could not be loaded: Not Found
Function 'oasOpIdUnique' could not be loaded: Not Found
Function 'oasTagDefined' could not be loaded: Not Found
Function 'refSiblings' could not be loaded: Not Found
Function 'oasPathParam' could not be loaded: Not Found
OpenAPI 3.x detected
c:/_work/spectral/repro/URIError.yaml
23:22 warning schema-strings-maxLength String typed properties MUST be further described using 'maxLength'.
Error: paths./test.get.responses.200.content.application/json.schema.maxLength is not truthy
https://[REDACTED]/static/schemas/common/v2/library.openapi.yaml
65:15 warning schema-strings-maxLength String typed properties MUST be further described using 'maxLength'.
Error: paths./test.get.responses.400.content.application/json.schema.properties.error.maxLength is not truthy
67:27 warning schema-strings-maxLength String typed properties MUST be further described using 'maxLength'.
Error: paths./test.get.responses.400.content.application/json.schema.properties.error_description.maxLength is n
ot truthy
69:21 warning schema-strings-maxLength String typed properties MUST be further described using 'maxLength'.
Error: paths./test.get.responses.400.content.application/json.schema.properties.status_code.maxLength is not tru
thy
✖ 4 problems (0 errors, 4 warnings, 0 infos, 0 hints)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. Which slightly puzzles me as the produced error in the referenced file
|
@nulltoken ah yeah, the paths included in error message generated by Ajv or custom functions are the whole different story yet certainly still something we need to address. |
@nulltoken |
@nulltoken dooone, but I'll need to cover other spots too. At the very moment it's only truthy function. |
'properties', | ||
'status_code', | ||
], | ||
path: ['components', 'schemas', 'Error', 'properties', 'status_code'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test shows that we're reporting far more issues than we should - especially now that errors are reported in context of source file (which is great).
This test should be, I think, 3 errors instead of 10 (!) errors. Could have a simple util that, given a IRuleResult
, returns a fingerprint
that is basically a unique id that can be used to compare if two results should be considered equal. Default fingerprint implementation could just hash(code + JSON.stringify(path) + source)
or something. Fingerprints could be used by another func to remove duplicates. from a result set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I took a stab at this here, should result in far less noise in results - #856
@P0lip Do you foresee to include this in the 5.0 release? |
@nulltoken yup! It's the last item blocking the release. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me, can follow up re path cleanup and better de-duping in the other two PRs. Nice work!
Fixes #608 and #685 (comment)
Checklist
Does this PR introduce a breaking change?
Additional context
From now on, Spectral will never try to generate paths that do not point to any value in the document.
Previously, we used to produce paths that did exist in the resolved document, but not necessarily in the actual unresolved document.
This is particularly crucial for tooling which mostly works with resolved documents, therefore need to operate on accurate paths. In the former specification, we simply threw a path pointing to a place in a resolved document.
https://github.com/stoplightio/spectral/pull/839/files#diff-62b31a98be4036e65207ec7971253e93 - this can be easily observed over here. The actual error was caused in the referenced file, which does not have any paths object with responses.