From 6b784dfb9762503e5ddbef9c88f885729ae9ee9a Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Fri, 24 Jul 2026 12:07:24 +0800 Subject: [PATCH 1/2] Sync typespec-java core: expose required-fields-as-ctor-args option (typespec#11380) Bump core-commit.json pin to ec09e28b3d2990734d1b54ebad85411adb148d12, which includes microsoft/typespec#11380 exposing the required-fields-as-ctor-args emitter option to tspconfig.yaml (default remains true). No test-suite changes between the previous pin and this commit. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: cd6f2e08-d6d3-42ae-affd-bc71e98086f7 --- ...uired-fields-as-ctor-args-2026-07-24-11-40-00.md | 13 +++++++++++++ packages/typespec-java/core-commit.json | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 .chronus/changes/typespec-java-expose-required-fields-as-ctor-args-2026-07-24-11-40-00.md diff --git a/.chronus/changes/typespec-java-expose-required-fields-as-ctor-args-2026-07-24-11-40-00.md b/.chronus/changes/typespec-java-expose-required-fields-as-ctor-args-2026-07-24-11-40-00.md new file mode 100644 index 0000000000..1dfe606a73 --- /dev/null +++ b/.chronus/changes/typespec-java-expose-required-fields-as-ctor-args-2026-07-24-11-40-00.md @@ -0,0 +1,13 @@ +--- +changeKind: fix +packages: + - "@azure-tools/typespec-java" +--- + +Expose the `required-fields-as-ctor-args` emitter option in `tspconfig.yaml`. It controls whether required model properties are generated as constructor arguments. The default remains `true`. + +```yaml +options: + "@azure-tools/typespec-java": + required-fields-as-ctor-args: false +``` diff --git a/packages/typespec-java/core-commit.json b/packages/typespec-java/core-commit.json index 06499eb9e7..3747d26591 100644 --- a/packages/typespec-java/core-commit.json +++ b/packages/typespec-java/core-commit.json @@ -1 +1 @@ -{ "sha": "43ff00415eb571c0c9e2d1274f621a61886e4a9b" } +{ "sha": "ec09e28b3d2990734d1b54ebad85411adb148d12" } From 73c75ab1f7557085bf613a11dcbe75ad11642651 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Fri, 24 Jul 2026 12:18:58 +0800 Subject: [PATCH 2/2] Add commented-out required-fields-as-ctor-args option to typespec-java options.ts Document the required-fields-as-ctor-args emitter option (exposed upstream in microsoft/typespec#11380) in the maintained Azure emitter options schema, but keep it commented out so users do not set it unless explicitly told to. It is a backward-compatibility option; the default (true) is unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: cd6f2e08-d6d3-42ae-affd-bc71e98086f7 --- packages/typespec-java/src/options.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/typespec-java/src/options.ts b/packages/typespec-java/src/options.ts index 0e9be9e473..c8650cd595 100644 --- a/packages/typespec-java/src/options.ts +++ b/packages/typespec-java/src/options.ts @@ -110,6 +110,13 @@ export const EmitterOptionsSchema: JSONSchemaType = { nullable: true, default: true, }, + // "required-fields-as-ctor-args": { + // type: "boolean", + // description: + // "When set to `true`, required properties of the model are generated as constructor arguments; otherwise, they are generated as setter methods. Default value is `true`. This option is for backward-compatibility.", + // nullable: true, + // default: true, + // }, // customization ...UnbrandedSdkEmitterOptions["generate-protocol-methods"],