(
schema: JSONSchema7,
ctx: GoCodegenCtx,
discriminatorProp: string,
path: string[] = []
)
| 1394 | } |
| 1395 | |
| 1396 | function goCollectRequiredJSONMatchTerms( |
| 1397 | schema: JSONSchema7, |
| 1398 | ctx: GoCodegenCtx, |
| 1399 | discriminatorProp: string, |
| 1400 | path: string[] = [] |
| 1401 | ): GoJSONMatchTerm[] { |
| 1402 | const objectSchema = goObjectSchemaForMatch(schema, ctx); |
| 1403 | if (!objectSchema) return []; |
| 1404 | |
| 1405 | const properties = objectSchema.properties || {}; |
| 1406 | const terms: GoJSONMatchTerm[] = []; |
| 1407 | for (const propName of [...new Set(objectSchema.required || [])].sort()) { |
| 1408 | if (path.length === 0 && propName === discriminatorProp) continue; |
| 1409 | const propSchema = properties[propName]; |
| 1410 | if (typeof propSchema !== "object") continue; |
| 1411 | |
| 1412 | const propPath = [...path, propName]; |
| 1413 | const prop = propSchema as JSONSchema7; |
| 1414 | terms.push({ kind: "propertyExists", path: propPath }); |
| 1415 | |
| 1416 | const stringValues = goStringEnumValues(prop, ctx); |
| 1417 | if (stringValues) { |
| 1418 | terms.push({ kind: "stringValue", path: propPath, values: [...new Set(stringValues)].sort() }); |
| 1419 | } |
| 1420 | |
| 1421 | terms.push(...goCollectRequiredJSONMatchTerms(prop, ctx, discriminatorProp, propPath)); |
| 1422 | } |
| 1423 | |
| 1424 | return dedupeGoJSONMatchTerms(terms); |
| 1425 | } |
| 1426 | |
| 1427 | function removeRedundantGoJSONExistsTerms(terms: GoJSONMatchTerm[]): GoJSONMatchTerm[] { |
| 1428 | const stringPaths = new Set(terms |
no test coverage detected
searching dependent graphs…