diff --git a/src/functions/schema-path.ts b/src/functions/schema-path.ts index 785c68977..60e1f0730 100644 --- a/src/functions/schema-path.ts +++ b/src/functions/schema-path.ts @@ -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; + // Whether to ignore circular schemas (true) or not (false) + ignoreCircular?: boolean; } export type SchemaPathRule = IRule; @@ -34,6 +36,10 @@ export const schemaPath: IFunction = (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,