MCPcopy Index your code
hub / github.com/github/copilot-sdk / isDurationProperty

Function isDurationProperty

scripts/codegen/csharp.ts:468–483  ·  view source on GitHub ↗

* Returns true when a TimeSpan-typed property needs a [JsonConverter] attribute. * * NOTE: The runtime schema generally uses `format: "duration"` on numeric (integer/number) * fields to mean "a duration value expressed in milliseconds". This differs from the JSON * Schema spec, where `format: "d

(schema: JSONSchema7)

Source from the content-addressed store, hash-verified

466 * 8601 strings. Seconds-suffixed fields stay numeric because their wire value is seconds.
467 */
468function isDurationProperty(schema: JSONSchema7): boolean {
469 const nullableInner = getNullableInner(schema);
470 if (nullableInner) {
471 return isDurationProperty(nullableInner);
472 }
473
474 if (schema.format === "duration") {
475 const t = schema.type;
476 if (t === "number" || t === "integer") return true;
477 if (Array.isArray(t)) {
478 const nonNull = (t as string[]).filter((x) => x !== "null");
479 if (nonNull.length === 1 && (nonNull[0] === "number" || nonNull[0] === "integer")) return true;
480 }
481 }
482 return false;
483}
484
485function isMillisecondsDurationProperty(propName: string | undefined, schema: JSONSchema7): boolean {
486 return isDurationProperty(schema) && !isSecondsDurationPropertyName(propName);

Callers 2

toCSharpPropertyNameFunction · 0.85

Calls 1

getNullableInnerFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…