(schema: JSONSchema7, ctx: GoCodegenCtx)
| 2229 | } |
| 2230 | |
| 2231 | function goStringEnumValues(schema: JSONSchema7, ctx: GoCodegenCtx): string[] | undefined { |
| 2232 | const resolved = resolveSchema(schema, ctx.definitions) ?? schema; |
| 2233 | if (typeof resolved.const === "string") return [resolved.const]; |
| 2234 | if (isStringEnumDefinition(resolved)) return resolved.enum; |
| 2235 | |
| 2236 | const unionMembers = goNonNullUnionMembers(resolved); |
| 2237 | if (unionMembers.length > 0) { |
| 2238 | const values: string[] = []; |
| 2239 | for (const member of unionMembers) { |
| 2240 | const memberValues = goStringEnumValues(member, ctx); |
| 2241 | if (!memberValues) return undefined; |
| 2242 | values.push(...memberValues); |
| 2243 | } |
| 2244 | return [...new Set(values)]; |
| 2245 | } |
| 2246 | |
| 2247 | return undefined; |
| 2248 | } |
| 2249 | |
| 2250 | function goBooleanValues(schema: JSONSchema7, ctx: GoCodegenCtx): boolean[] | undefined { |
| 2251 | const resolved = resolveSchema(schema, ctx.definitions) ?? schema; |
no test coverage detected
searching dependent graphs…