(schema: JSONSchema7, ctx: GoCodegenCtx)
| 2605 | } |
| 2606 | |
| 2607 | function goSchemaJSONKind(schema: JSONSchema7, ctx: GoCodegenCtx): string | undefined { |
| 2608 | const resolved = resolveGoUnionMember(schema, ctx.definitions); |
| 2609 | if (resolved.const !== undefined) { |
| 2610 | return goSchemaJSONKind(schemaForConstValue(resolved.const), ctx); |
| 2611 | } |
| 2612 | |
| 2613 | if (Array.isArray(resolved.type)) { |
| 2614 | const nonNullTypes = resolved.type.filter((type) => type !== "null"); |
| 2615 | if (nonNullTypes.length === 1) { |
| 2616 | return goSchemaJSONKind({ ...resolved, type: nonNullTypes[0] } as JSONSchema7, ctx); |
| 2617 | } |
| 2618 | return undefined; |
| 2619 | } |
| 2620 | |
| 2621 | if (goObjectUnionMemberSchema(schema, ctx)) return "object"; |
| 2622 | |
| 2623 | switch (resolved.type) { |
| 2624 | case "array": return "array"; |
| 2625 | case "boolean": return "boolean"; |
| 2626 | case "integer": |
| 2627 | case "number": return "number"; |
| 2628 | case "object": return "object"; |
| 2629 | case "string": return "string"; |
| 2630 | default: return undefined; |
| 2631 | } |
| 2632 | } |
| 2633 | |
| 2634 | function goUntaggedUnionVariant(typeName: string, member: JSONSchema7, ctx: GoCodegenCtx): GoUntaggedUnionVariant | undefined { |
| 2635 | const jsonKind = goSchemaJSONKind(member, ctx); |
no test coverage detected
searching dependent graphs…