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

Adding support for loading custom rulesets off the filesystem. #196

Merged
merged 1 commit into from
Nov 15, 2018
Merged

Adding support for loading custom rulesets off the filesystem. #196

merged 1 commit into from
Nov 15, 2018

Conversation

erunion
Copy link
Contributor

@erunion erunion commented Nov 15, 2018

This adds support for being able to supply a custom ruleset on your filesystem to the lint command.

Examples!

$ cat standards.json 
{
  "require": "strict",
  "rules": []
}

$ ./node_modules/.bin/speccy lint --verbose --rules=./standards.json docs/3.4/openapi/api.yaml 
READ ./standards.json
READ /Users/ursenbachj/code/vimeo-api/design/node_modules/speccy/rules/strict.json
READ /Users/ursenbachj/code/vimeo-api/design/node_modules/speccy/rules/default.json
Found 18 rules in default: parameter-description,parameter-name-regex,operation-operationId,operation-summary-or-description,operation-tags,path-keys-no-trailing-slash,server-trailing-slash,openapi-tags,openapi-tags-alphabetical,reference-no-other-properties,pathItem-summary-or-description,example-value-or-externalValue,default-and-example-are-redundant,reference-components-regex,no-script-tags-in-markdown,info-contact,license-apimatic-bug,no-eval-in-descriptions
Found 5 rules in strict: contact-properties,license-url,server-not-example.com,tag-description,short-summary
Found 0 rules in ./standards.json: 
GET docs/3.4/openapi/api.yaml
Specification contains lint errors: 596

#/info/contact  R: contact-properties  D: contact object should have name, url and email
expected Object { url: 'https://developer.vimeo.com/help' } to have property name

More information: https://speccy.io/rules/#contact-properties

...

standards.json is loaded off my filesystem, which then requires the stock strict rule, which then also requires default.

Supplying a ruleset name, like strict, still works as well:

$ ./node_modules/.bin/speccy lint --verbose --rules=strict docs/3.4/openapi/api.yaml 
READ /Users/ursenbachj/code/vimeo-api/design/node_modules/speccy/rules/strict.json
READ /Users/ursenbachj/code/vimeo-api/design/node_modules/speccy/rules/default.json
Found 18 rules in default: parameter-description,parameter-name-regex,operation-operationId,operation-summary-or-description,operation-tags,path-keys-no-trailing-slash,server-trailing-slash,openapi-tags,openapi-tags-alphabetical,reference-no-other-properties,pathItem-summary-or-description,example-value-or-externalValue,default-and-example-are-redundant,reference-components-regex,no-script-tags-in-markdown,info-contact,license-apimatic-bug,no-eval-in-descriptions
Found 5 rules in strict: contact-properties,license-url,server-not-example.com,tag-description,short-summary
GET docs/3.4/openapi/api.yaml
Specification contains lint errors: 596

#/info/contact  R: contact-properties  D: contact object should have name, url and email
expected Object { url: 'https://developer.vimeo.com/help' } to have property name

More information: https://speccy.io/rules/#contact-properties

...

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.04%) to 87.824% when pulling 5cb7ce0 on erunion:local-custom-rulesets into 2008684 on wework:master.

@coveralls
Copy link

coveralls commented Nov 15, 2018

Coverage Status

Coverage decreased (-0.04%) to 87.824% when pulling 5cb7ce0 on erunion:local-custom-rulesets into 2008684 on wework:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.04%) to 87.824% when pulling 5cb7ce0 on erunion:local-custom-rulesets into 2008684 on wework:master.

@philsturgeon philsturgeon merged commit 005bd17 into wework:master Nov 15, 2018
@philsturgeon
Copy link
Contributor

Thank you! I had this change in a random branch somewhere but it was wrapped up with other changes, and yours has a nicer test. Thanks for getting this done!

@erunion erunion deleted the local-custom-rulesets branch November 15, 2018 14:32
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.

3 participants