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

fix: do not generate non-existing paths #459

Merged
merged 6 commits into from
Aug 20, 2019
Merged

Conversation

P0lip
Copy link
Contributor

@P0lip P0lip commented Aug 18, 2019

Fixes #91

Checklist

  • Tests added / updated
  • Docs added / updated

Does this PR introduce a breaking change?

  • Yes
  • No

@@ -156,7 +156,7 @@ describe('valid-example', () => {
expect.objectContaining({
code: 'valid-example',
message: '"self" property type should be array',
path: ['definitions', 'halRoot', '_links', 'self'],
path: ['definitions', 'halRoot', 'example', '_links', 'self'],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is quite tricky. I still need to fix it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a bit of a different issue, fixed in 0e3844f
yet I believe the new error message we generate is actually worse than the former one, or am I wrong?

@P0lip P0lip self-assigned this Aug 18, 2019
@P0lip P0lip added the t/bug Something isn't working label Aug 18, 2019
@P0lip P0lip added this to the September '19 milestone Aug 18, 2019
@P0lip P0lip force-pushed the fix/non-existing-json-paths branch from 0e3844f to 20acd8e Compare August 19, 2019 13:42
@@ -169,7 +169,7 @@ describe('valid-example', () => {
expect(results).toEqual([
expect.objectContaining({
code: 'valid-example',
message: `"ip_address" property format should match format "${format}"`,
message: `"example" property format should match format "${format}"`, // hm, ip_address is likely to be more meaningful no?
Copy link
Contributor Author

@P0lip P0lip Aug 19, 2019

Choose a reason for hiding this comment

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

@philsturgeon thoughts?

Once we sort this one out, it will be ready to review.

Copy link
Contributor

Choose a reason for hiding this comment

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

Depends? This feels like a limitation of trying to shove everything into a simple string message. We are talking about the example, but it sure could be useful to let them know its the ip_address example that is wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, exactly.
I'd expect to receive something like "ip_address" example property format should match format "${format}". Will do it this way.

@P0lip P0lip marked this pull request as ready for review August 20, 2019 07:37
@P0lip P0lip requested review from philsturgeon and marbemac August 20, 2019 07:38
@P0lip P0lip merged commit 89a4332 into develop Aug 20, 2019
@P0lip P0lip deleted the fix/non-existing-json-paths branch August 20, 2019 11:57
philsturgeon pushed a commit that referenced this pull request Aug 22, 2019
* fix: do not generate non-existing paths

* fix: include example path in valid-example

* feat: nicer messages for valid-example rule

* test: borrow mocking from feat/custom-functions branch

* build: add build to karma
P0lip added a commit that referenced this pull request Aug 29, 2019
* fix: do not generate non-existing paths

* fix: include example path in valid-example

* feat: nicer messages for valid-example rule

* test: borrow mocking from feat/custom-functions branch

* build: add build to karma
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 this pull request may close these issues.

Spectral is generating paths that do not exist in the original document
2 participants