Skip to content

Commit

Permalink
revert: irrelevant changes
Browse files Browse the repository at this point in the history
  • Loading branch information
P0lip committed May 27, 2020
1 parent 2dc5e69 commit 2278e94
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/functions/enumeration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export interface IEnumRuleOptions {
export const enumeration: IFunction<IEnumRuleOptions> = (targetVal, opts) => {
if (targetVal === void 0) return;

const { values } = opts!; // todo: validate
const { values } = opts;

const results: IFunctionResult[] = [];

Expand Down
2 changes: 1 addition & 1 deletion src/functions/pattern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const pattern: IFunction<IRulePatternOptions> = (targetVal, opts) => {

const results: IFunctionResult[] = [];

const { match, notMatch } = opts!; // todo: avoid this and do validation.
const { match, notMatch } = opts;

if (match) {
if (test(targetVal, match) !== true) {
Expand Down
14 changes: 4 additions & 10 deletions src/functions/schema-path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,19 @@ export interface ISchemaPathOptions {
}

export const schemaPath: IFunction<ISchemaPathOptions> = (targetVal, opts, paths, otherValues) => {
if (!opts) {
// todo: nicer validation
throw new Error('No options provided');
}

// The subsection of the targetValue which contains the schema for us to validate the good bit against
const schemaObject = JSONPath({ path: opts!.schemaPath, json: targetVal });
if (!Array.isArray(schemaObject) || schemaObject.length === 0) return;

// The subsection of the targetVal which contains the good bit
const relevantItems = getLintTargets(targetVal, opts.field);

// The subsection of the targetValue which contains the schema for us to validate the good bit against
const schemaObject = JSONPath({ path: opts.schemaPath, json: targetVal })[0];

const results: IFunctionResult[] = [];

for (const relevantItem of relevantItems) {
const result = schema(
relevantItem.value,
{
schema: schemaObject[0],
schema: schemaObject,
oasVersion: opts.oasVersion,
allErrors: opts.allErrors,
},
Expand Down
1 change: 0 additions & 1 deletion src/rulesets/oas/__tests__/templates/_schema-example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export default (ruleName: string, path: string) => {

beforeEach(() => {
s = new Spectral();

s.registerFormat('oas3', () => true);
s.setRules({
[ruleName]: Object.assign(rules[ruleName], {
Expand Down
2 changes: 1 addition & 1 deletion src/rulesets/oas/functions/oasOpSecurityDefined.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const oasOpSecurityDefined: IFunction<{
}> = (targetVal, options) => {
const results: IFunctionResult[] = [];

const { schemesPath } = options!;
const { schemesPath } = options;

const { paths = {} } = targetVal;
const schemes = _get(targetVal, schemesPath) || {};
Expand Down

0 comments on commit 2278e94

Please sign in to comment.