(
className: string,
schema: JSONSchema7,
knownTypes: Map<string, string>,
nestedClasses: Map<string, string>,
enumOutput: string[]
)
| 1102 | } |
| 1103 | |
| 1104 | function generateNestedClass( |
| 1105 | className: string, |
| 1106 | schema: JSONSchema7, |
| 1107 | knownTypes: Map<string, string>, |
| 1108 | nestedClasses: Map<string, string>, |
| 1109 | enumOutput: string[] |
| 1110 | ): string { |
| 1111 | const required = new Set(schema.required || []); |
| 1112 | const lines: string[] = []; |
| 1113 | lines.push(...xmlDocCommentWithFallback(schema.description, `Nested data type for <c>${className}</c>.`, "")); |
| 1114 | if (isSchemaExperimental(schema)) pushExperimentalAttribute(lines); |
| 1115 | if (isSchemaDeprecated(schema)) pushObsoleteAttributes(lines); |
| 1116 | lines.push(`${isSchemaInternal(schema) ? "internal" : "public"} sealed partial class ${className}`, `{`); |
| 1117 | |
| 1118 | for (const [propName, propSchema] of Object.entries(schema.properties || {}).sort(([a], [b]) => a.localeCompare(b))) { |
| 1119 | if (typeof propSchema !== "object") continue; |
| 1120 | const prop = propSchema as JSONSchema7; |
| 1121 | const isReq = required.has(propName); |
| 1122 | const csharpName = toCSharpPropertyName(propName, prop); |
| 1123 | const csharpType = resolveSessionPropertyType(prop, className, csharpName, isReq, knownTypes, nestedClasses, enumOutput); |
| 1124 | |
| 1125 | lines.push(...xmlDocPropertyComment(prop.description, propName, " ")); |
| 1126 | lines.push(...emitDataAnnotations(prop, " ", csharpType)); |
| 1127 | if (isSchemaDeprecated(prop)) pushObsoleteAttributes(lines, " "); |
| 1128 | if (isSchemaExperimental(prop)) pushExperimentalAttribute(lines, " "); |
| 1129 | if (isMillisecondsDurationProperty(propName, prop)) lines.push(` [JsonConverter(typeof(MillisecondsTimeSpanConverter))]`); |
| 1130 | if (!isReq) lines.push(` [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]`); |
| 1131 | const propVisibility = pushCSharpInternalAttribute(lines, prop); |
| 1132 | lines.push(` [JsonPropertyName("${propName}")]`); |
| 1133 | const reqMod = isReq && !csharpType.endsWith("?") ? "required " : ""; |
| 1134 | lines.push(` ${propVisibility} ${reqMod}${csharpType} ${csharpName} { get; set; }`, ""); |
| 1135 | } |
| 1136 | if (lines[lines.length - 1] === "") lines.pop(); |
| 1137 | lines.push(`}`); |
| 1138 | return lines.join("\n"); |
| 1139 | } |
| 1140 | |
| 1141 | function resolveSessionPropertyType( |
| 1142 | propSchema: JSONSchema7, |
no test coverage detected
searching dependent graphs…