feat(http-client-java): expose required-fields-as-ctor-args option to tspconfig#11380
Conversation
… tspconfig Expose the 'required-fields-as-ctor-args' emitter option in tspconfig.yaml for data-plane. It controls whether required model properties are generated as constructor arguments. The default remains true. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 042a4299-1ab4-46bf-8b66-7ce223d6272c
Validation performedBuilt the emitter + Java generator, packed via Spec used: model Widget {
@visibility(Lifecycle.Read)
id: string;
requiredName: string;
requiredCount: int32;
optionalDescription?: string;
}Default ( public Widget(String requiredName, int requiredCount) {
this.requiredName = requiredName;
this.requiredCount = requiredCount;
}Override ( public Widget() {
}
public Widget setRequiredName(String requiredName) { ... }
public Widget setRequiredCount(int requiredCount) { ... }This confirms the option flows from |
…commended to set' Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 042a4299-1ab4-46bf-8b66-7ce223d6272c
|
All changed packages have been documented.
Show changes
|
|
You can try these changes here
|
|
with the improved instruction https://github.com/microsoft/typespec/blob/main/.github/instructions/http-client-java.instructions.md#modify-the-code-generator-emitter--generator-e2e-loop |
…a 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
…typespec#11380) (#5043) Bumps the pinned core commit to include [microsoft/typespec#11380](microsoft/typespec#11380), which exposes the + ' equired-fields-as-ctor-args' + emitter option to + ' spconfig.yaml' + for data-plane (default remains + ' rue' + ). ## Changes - + 'core-commit.json' + pin: + '43ff0041' + -> + '�c09e28b' + (HEAD of core + 'main' + , the #11380 merge commit). - Ran + 'SyncTests.ps1' + against the new pin: no test-suite (src/tsp) changes between the previous pin and this commit — #11380 only touches emitter/generator source, which is copied at build time. - Added chronus + 'ix' + change (next version: 0.45.10). + 'Generate.ps1' + / + 'Copy-Sources.ps1' + need no changes: #11380 is a purely additive emitter option with no spec-generation impact. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: cd6f2e08-d6d3-42ae-affd-bc71e98086f7 --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: cd6f2e08-d6d3-42ae-affd-bc71e98086f7
Version bump for the typespec-java hotfix **0.45.10**, following the sync in #5043. ## Included changes (consumed from + '.chronus/changes' + ) - **fix**: Expose the + ' equired-fields-as-ctor-args' + emitter option in + ' spconfig.yaml' + (microsoft/typespec#11380). Default remains + ' rue' + . - **internal**: Make the + 'core-commit.json' + pin authoritative in + 'CoreCommit.ps1' + (#5016). ## Files - + 'packages/typespec-java/package.json' + -> 0.45.10 - + 'packages/typespec-java/CHANGELOG.md' + - + 'packages/typespec-java/emitter-tests/package.json' + -> 0.45.10 (version + + '.tgz' + dep) - Deleted the two consumed typespec-java change files Only + '@azure-tools/typespec-java' + is bumped. Non-java pending change files (tcgc, benchmark, playground, website) were intentionally left untouched. The + 'core' + submodule is unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: cd6f2e08-d6d3-42ae-affd-bc71e98086f7 --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: cd6f2e08-d6d3-42ae-affd-bc71e98086f7
Expose the
required-fields-as-ctor-argsemitter option totspconfig.yamlfor data-plane. Previously it was hard-coded totrueinTypeSpecPlugin. The default remainstrue; users can now opt out.Changes
emitter/src/code-model-builder.ts— addrequired-fields-as-ctor-argstoEmitterOptionsDevso the option flows from tspconfig into the JSON passed to the Java generator.generator/.../model/EmitterOptions.java— add field, getter, and JSON parsing.generator/.../TypeSpecPlugin.java— override the setting only when the user sets it; the static default staystrue.