* Schemas marked `.asOpaqueJson()` on the runtime side carry * `x-opaque-json: true`. These are the only shapes that legitimately surface * as opaque JSON in the SDK (mapped to `JsonElement` in C#). Anything else * that lacks an idiomatic mapping (untyped fields, non-discriminated unions, * etc.
(context: string, schema: JSONSchema7)
| 295 | * The predicate itself lives in {@link "./utils".isOpaqueJson} for reuse. |
| 296 | */ |
| 297 | function failUnmappable(context: string, schema: JSONSchema7): never { |
| 298 | const summary = JSON.stringify(schema, (key, value) => (key === "description" ? undefined : value)).slice(0, 200); |
| 299 | throw new Error( |
| 300 | `C# codegen: cannot map schema to an idiomatic C# type (${context}). ` + |
| 301 | `On the runtime side, either tighten the Zod schema to a typed shape, or — if it is genuinely free-form JSON — ` + |
| 302 | `mark it \`.asOpaqueJson()\` so the schema emits \`x-opaque-json: true\` and the codegen maps it to JsonElement. ` + |
| 303 | `Offending schema (truncated): ${summary}`, |
| 304 | ); |
| 305 | } |
| 306 | |
| 307 | function requiresArgumentNullCheck(typeName: string, isRequired: boolean): boolean { |
| 308 | return isRequired && !typeName.endsWith("?") && !isNonNullableCSharpValueType(typeName); |
no outgoing calls
no test coverage detected
searching dependent graphs…