(typeName: string, schema: JSONSchema7, ctx: GoCodegenCtx)
| 2530 | } |
| 2531 | |
| 2532 | function goPrimitiveUnionVariants(typeName: string, schema: JSONSchema7, ctx: GoCodegenCtx): GoPrimitiveUnionVariant[] | undefined { |
| 2533 | const members = goNonNullUnionMembers(schema); |
| 2534 | if (members.length === 0) return undefined; |
| 2535 | |
| 2536 | const variants: GoPrimitiveUnionVariant[] = []; |
| 2537 | const seenTypeNames = new Set<string>(); |
| 2538 | for (const member of members) { |
| 2539 | const valueName = goPrimitiveUnionValueName(member, ctx); |
| 2540 | const goType = goPrimitiveUnionGoType(member, ctx); |
| 2541 | if (!valueName || !goType) return undefined; |
| 2542 | |
| 2543 | const variantTypeName = goPrimitiveUnionVariantTypeName(typeName, valueName); |
| 2544 | if (seenTypeNames.has(variantTypeName)) return undefined; |
| 2545 | seenTypeNames.add(variantTypeName); |
| 2546 | variants.push({ |
| 2547 | typeName: variantTypeName, |
| 2548 | goType, |
| 2549 | }); |
| 2550 | } |
| 2551 | |
| 2552 | return variants; |
| 2553 | } |
| 2554 | |
| 2555 | function emitGoPrimitiveUnionInterface(typeName: string, schema: JSONSchema7, ctx: GoCodegenCtx, variants?: GoPrimitiveUnionVariant[]): boolean { |
| 2556 | if (ctx.generatedNames.has(typeName)) return true; |
no test coverage detected
searching dependent graphs…