@@ -14839,31 +14839,52 @@ export class ObjectSerializer {
1483914839
1484014840 const instance = new typeMap[type]();
1484114841 const attributesMap = typeMap[type].getAttributeTypeMap();
14842- const attributesBaseNames = Object.keys(attributesMap).reduce(
14843- (o, key) => Object.assign(o, { [attributesMap[key].baseName]: "" }),
14844- {}
14845- );
14842+ const keepAllInAdditional =
14843+ (typeMap[type] as any)._keepTypedInAdditionalProperties === true;
14844+ // Single pass: build attributesBaseNames (for extra-key detection) and, when needed,
14845+ // baseNameToAttr (for per-field typed deserialization preserving int64 precision).
14846+ const attributesBaseNames: { [key: string]: string } = {};
14847+ const baseNameToAttr: { [key: string]: any } = {};
14848+ for (const attrName in attributesMap) {
14849+ const baseName = attributesMap[attrName].baseName;
14850+ attributesBaseNames[baseName] = "";
14851+ if (keepAllInAdditional && attrName !== "additionalProperties") {
14852+ baseNameToAttr[baseName] = attributesMap[attrName];
14853+ }
14854+ }
1484614855 const extraAttributes = Object.keys(data).filter(
14847- (key) => !Object.prototype.hasOwnProperty.call(attributesBaseNames, key)
14856+ (key) =>
14857+ keepAllInAdditional ||
14858+ !Object.prototype.hasOwnProperty.call(attributesBaseNames, key)
1484814859 );
1484914860
1485014861 if (extraAttributes.length > 0) {
1485114862 if ("additionalProperties" in attributesMap) {
14852- if (!instance.additionalProperties) {
14853- instance.additionalProperties = {};
14854- }
14855-
1485614863 const additionalProperties: { [key: string]: any } = {};
14857- for (const key of extraAttributes) {
14858- additionalProperties[key] = data[key];
14864+ if (keepAllInAdditional) {
14865+ for (const key of extraAttributes) {
14866+ const attrInfo = baseNameToAttr[key];
14867+ // Use per-field type/format for typed attrs to preserve int64 precision.
14868+ additionalProperties[key] = attrInfo
14869+ ? ObjectSerializer.deserialize(
14870+ data[key],
14871+ attrInfo.type,
14872+ attrInfo.format
14873+ )
14874+ : data[key];
14875+ }
14876+ instance.additionalProperties = additionalProperties;
14877+ } else {
14878+ for (const key of extraAttributes) {
14879+ additionalProperties[key] = data[key];
14880+ }
14881+ const attributeObj = attributesMap["additionalProperties"];
14882+ instance.additionalProperties = ObjectSerializer.deserialize(
14883+ additionalProperties,
14884+ attributeObj.type,
14885+ attributeObj.format
14886+ );
1485914887 }
14860-
14861- const attributeObj = attributesMap["additionalProperties"];
14862- instance.additionalProperties = ObjectSerializer.deserialize(
14863- additionalProperties,
14864- attributeObj.type,
14865- attributeObj.format
14866- );
1486714888 } else {
1486814889 throw new Error(
1486914890 `found extra attributes '${extraAttributes}' in ${type}`
0 commit comments