Skip to content

Commit 1901c9c

Browse files
authored
Merge pull request #39 from ainetx/disable-examples-ref-validation
Disable GTS reference validation for /examples in schemas
2 parents ebd20db + 1eaba58 commit 1901c9c

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

packages/shared/src/registry.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,17 @@ export class JsonRegistry {
137137
// Check if all GTS references exist in the registry
138138
if (entity.gtsRefs && entity.gtsRefs.length > 0) {
139139
for (const ref of entity.gtsRefs) {
140+
// Skip reference validation for refs inside /examples field in schemas
141+
// Match 'examples' at root or after array indices (e.g., allOf[0].examples), but NOT after 'properties'
142+
// Valid: 'examples', 'examples[0]', 'allOf[0].examples', 'anyOf[1].examples[0]'
143+
// Invalid: 'properties.examples' (this is a regular schema property, not documentation examples)
144+
const isInExamples = /(?:^|(?:allOf|anyOf|oneOf)\[\d+\]\.)examples(?:\[|$|\.)/.test(ref.sourcePath) ||
145+
/^examples(?:\[|$|\.)/.test(ref.sourcePath)
146+
147+
if (isInExamples) {
148+
continue
149+
}
150+
140151
const refExists = this.jsonSchemas.has(ref.id) || this.jsonObjs.has(ref.id)
141152
if (!refExists) {
142153
this.absentGtsEntities.set(ref.id, createAbsentEntity(ref.id))

0 commit comments

Comments
 (0)