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 #915: Ignore examples with circular schemas #923

Closed
wants to merge 14 commits into from
6 changes: 6 additions & 0 deletions src/functions/schema-path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export interface ISchemaPathOptions {
field?: string;
// The oasVersion, either 2 or 3 for OpenAPI Spec versions, could also be 3.1 or a larger number if there's a need for it, otherwise JSON Schema
oasVersion?: Optional<number>;
// Whether to ignore circular schemas (true) or not (false)
ignoreCircular?: boolean;
}

export type SchemaPathRule = IRule<RuleFunction.SCHEMAPATH, ISchemaPathOptions>;
Expand All @@ -34,6 +36,10 @@ export const schemaPath: IFunction<ISchemaPathOptions> = (targetVal, opts, paths

const results: IFunctionResult[] = [];

if (opts.ignoreCircular && JSONPath({ path: '$..$ref', json: schemaObject }).length > 0) {
return results;
}

for (const relevantItem of relevantItems) {
const result = schema(
relevantItem.value,
Expand Down