(schema: JSONSchema7, ctx: GoCodegenCtx)
| 2248 | } |
| 2249 | |
| 2250 | function goBooleanValues(schema: JSONSchema7, ctx: GoCodegenCtx): boolean[] | undefined { |
| 2251 | const resolved = resolveSchema(schema, ctx.definitions) ?? schema; |
| 2252 | if (typeof resolved.const === "boolean") return [resolved.const]; |
| 2253 | if (Array.isArray(resolved.enum) && resolved.enum.every((value) => typeof value === "boolean")) { |
| 2254 | return resolved.enum as boolean[]; |
| 2255 | } |
| 2256 | if (resolved.type === "boolean") return [true, false]; |
| 2257 | |
| 2258 | const unionMembers = goNonNullUnionMembers(resolved); |
| 2259 | if (unionMembers.length > 0) { |
| 2260 | const values: boolean[] = []; |
| 2261 | for (const member of unionMembers) { |
| 2262 | const memberValues = goBooleanValues(member, ctx); |
| 2263 | if (!memberValues) return undefined; |
| 2264 | values.push(...memberValues); |
| 2265 | } |
| 2266 | return [...new Set(values)]; |
| 2267 | } |
| 2268 | |
| 2269 | return undefined; |
| 2270 | } |
| 2271 | |
| 2272 | function goBooleanDiscriminatorValues(schema: JSONSchema7, ctx: GoCodegenCtx): boolean[] | undefined { |
| 2273 | const resolved = resolveSchema(schema, ctx.definitions) ?? schema; |
no test coverage detected
searching dependent graphs…