Skip to content

Fix ObjectSerializer to preserve baseName-keyed fields during serialize - #1

Merged
brendandburns merged 1 commit into
masterfrom
copilot/update-objectserializer-ts
Aug 19, 2026
Merged

Fix ObjectSerializer to preserve baseName-keyed fields during serialize#1
brendandburns merged 1 commit into
masterfrom
copilot/update-objectserializer-ts

Conversation

Copilot AI commented Aug 19, 2026

Copy link
Copy Markdown

Ports the fix from kubernetes-client/javascript#3016: ObjectSerializer.serialize always read source values via data[attributeType.name] (the TS property name), silently dropping values when input data is keyed by the API baseName instead — e.g. raw/parsed data containing x-kubernetes-preserve-unknown-fields.

// Before: value is lost if `data` only has the baseName key
instance[attributeType.baseName] = ObjectSerializer.serialize(
    data[attributeType.name], attributeType.type, attributeType.format
);

// After: falls back to baseName when `name` isn't an own property
const value = Object.prototype.hasOwnProperty.call(data, attributeType.name)
    ? data[attributeType.name]
    : data[attributeType.baseName];
instance[attributeType.baseName] = ObjectSerializer.serialize(
    value, attributeType.type, attributeType.format
);

Templates

  • modules/openapi-generator/src/main/resources/typescript/model/ObjectSerializer.mustache — used by typescript, typescript-fetch, typescript-axios, typescript-rxjs, and related generators.
  • modules/openapi-generator/src/main/resources/typescript-node/models.mustache — used by the legacy typescript-node generator.

Generated samples/fixtures

  • Updated all 21 affected generated files under samples/ and the integration test fixture under modules/openapi-generator/src/test/resources/integrationtests/typescript/objectsWithEnums-expected to match the template change.
  • Regeneration was done by hand-applying the identical template diff to each output, since running ./bin/generate-samples.sh requires a Maven build (./mvnw ... clean package) and the sandbox lacked network access to fetch Maven/dependencies. The resulting diffs mirror what the updated templates would produce.

…alize

Co-authored-by: brendandburns <5751682+brendandburns@users.noreply.github.com>
Copilot AI requested a review from brendandburns August 19, 2026 16:36
@brendandburns
brendandburns marked this pull request as ready for review August 19, 2026 19:00
@brendandburns
brendandburns merged commit a521919 into master Aug 19, 2026
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants