Skip to content

Commit

Permalink
Disabled reference-components-regex for now
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil Sturgeon committed Apr 3, 2018
1 parent 464506b commit 29ecc8f
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 17 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [Unreleased]
### Changed
- `properties` rule will now ignore extensions, so `foo: 'a', x-bar: 'b'` is only 1 property.
### Fixed
- Disabled `reference-components-regex` rule until resolver can allow it to work

## [0.5.3] - 2018-03-29
### Fixed
Expand Down
32 changes: 19 additions & 13 deletions lib/linter.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,19 +110,25 @@ const lint = (objectName, object, options = {}) => {
const target = object[property]

let components = [];
if (split) {
components = target.split(split);
}
else {
components.push(target);
}
const re = new RegExp(value);
for (let component of components) {
if (omit) component = component.split(omit).join('');
if (component) {
ensure(rule, () => {
should(re.test(component)).be.exactly(true, rule.description);
});
if (target) {
if (split) {
// console.log('====\ntarget', target);
// console.log('object', object);
components = target.split(split);
// console.log('just split: components', components);

}
else {
components.push(target);
}
const re = new RegExp(value);
for (let component of components) {
if (omit) component = component.split(omit).join('');
if (component) {
ensure(rule, () => {
should(re.test(component)).be.exactly(true, rule.description);
});
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion rules/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
{
"name": "reference-components-regex",
"object": "reference",
"enabled": true,
"enabled": false,
"description": "reference components should all match regex ^[a-zA-Z0-9\\.\\-_]+",
"pattern": { "property": "$ref", "omit": "#", "split": "/", "value": "^[a-zA-Z0-9\\.\\-_]+$" }
},
Expand Down
2 changes: 1 addition & 1 deletion test/linter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ describe('linter.js', () => {
});
});

context('when trying to figure this damn error out', () => {
xcontext('when trying to figure this damn error out', () => {
const rule = {
name: "reference-components-regex",
object: "reference",
Expand Down
2 changes: 1 addition & 1 deletion test/loader.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('loader.js', () => {
"openapi-tags-alphabetical",
"reference-no-other-properties",
"example-value-or-externalValue",
"reference-components-regex",
// "reference-components-regex",
"no-script-tags-in-markdown",
"info-contact",
"license-apimatic-bug",
Expand Down
2 changes: 1 addition & 1 deletion test/profiles/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
"input": {
"$ref": "parameters.yml#/roomId"
},
"expectedRuleErrors": ["reference-components-regex"]
"expectedRuleErrors": []
},
{
"input": {
Expand Down

0 comments on commit 29ecc8f

Please sign in to comment.