(
representation: SchemaRepresentation.Representation,
path: Path,
includeTypeBrands: boolean = true
)
| 372 | } |
| 373 | |
| 374 | function recur( |
| 375 | representation: SchemaRepresentation.Representation, |
| 376 | path: Path, |
| 377 | includeTypeBrands: boolean = true |
| 378 | ): SchemaRepresentation.Code { |
| 379 | if (representation._tag === "Reference") { |
| 380 | if (!Object.hasOwn(document.references, representation.$ref)) { |
| 381 | throw errorWithPath(`Invalid reference ${representation.$ref}`, [...path, "$ref"]) |
| 382 | } |
| 383 | const identifier = ensureUniqueIdentifier(representation.$ref) |
| 384 | if ( |
| 385 | compilingRecursiveDefinition && explicitSuspendDepth === 0 && |
| 386 | Object.hasOwn(sorted.recursives, representation.$ref) |
| 387 | ) { |
| 388 | return makeCode(`Schema.suspend((): Schema.Codec<${identifier}> => ${identifier})`, identifier) |
| 389 | } |
| 390 | const Type = includeTypeBrands |
| 391 | ? identifier |
| 392 | : recur(document.references[representation.$ref], ["references", representation.$ref], false).Type |
| 393 | return makeCode(identifier, Type) |
| 394 | } |
| 395 | return applyNode(on(representation, path, includeTypeBrands), representation, path, includeTypeBrands) |
| 396 | } |
| 397 | |
| 398 | function on( |
| 399 | representation: Exclude<SchemaRepresentation.Representation, SchemaRepresentation.Reference>, |
no test coverage detected