Skip to content

Remove use of implicit optionality#4388

Draft
timotheeguerin wants to merge 3 commits intoAzure:mainfrom
timotheeguerin:fix/remove-implicit-optionality
Draft

Remove use of implicit optionality#4388
timotheeguerin wants to merge 3 commits intoAzure:mainfrom
timotheeguerin:fix/remove-implicit-optionality

Conversation

@timotheeguerin
Copy link
Copy Markdown
Member

No description provided.

@microsoft-github-policy-service microsoft-github-policy-service Bot added lib:azure-core Issues for @azure-tools/typespec-azure-core library lib:azure-resource-manager Issues for @azure-tools/typespec-azure-core library lib:azure-http-specs For issues/prs related to the @azure-tools/typespec-azure-http-specs package labels May 6, 2026
@timotheeguerin timotheeguerin added the int:azure-specs Run integration tests against azure-rest-api-specs label May 6, 2026
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 6, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@azure-tools/azure-http-specs@4388
npm i https://pkg.pr.new/@azure-tools/typespec-azure-core@4388
npm i https://pkg.pr.new/@azure-tools/typespec-azure-resource-manager@4388

commit: d560338

@azure-sdk
Copy link
Copy Markdown
Collaborator

azure-sdk commented May 6, 2026

All changed packages have been documented.

  • @azure-tools/azure-http-specs
  • @azure-tools/typespec-azure-core
  • @azure-tools/typespec-azure-resource-manager
Show changes

@azure-tools/azure-http-specs - internal ✏️

Remove use of implicit optionality which was a noop in one operation

@azure-tools/typespec-azure-resource-manager - breaking ✏️

Removed implicitOptionality: true from the @patch decorator on the following operation templates:,> ,> - ArmTagsPatchAsync,> - ArmResourcePatchAsync,> - ArmTagsPatchSync,> - ArmResourcePatchSync,> - ResourceUpdateSync.update (in ResourceUpdateSync interface),> ,> Previously, these templates used @patch(#{ implicitOptionality: true }) which caused all properties in the PATCH request body to be implicitly treated as optional, regardless of how they were declared in the model. This behavior is now removed — properties will retain their declared optionality.,> ,> #### Migration,> ,> If you use these ARM operation templates, the PATCH body will no longer implicitly make all properties optional. In most cases, ARM resources already use ResourceUpdateModel<Resource, Properties> which produces the correct optional property envelope — if so, no changes are needed.,> ,> If you have a custom patch body that relied on implicit optionality, explicitly mark properties as optional:,> ,> Before (implicit optionality made all properties optional automatically):,> ,> tsp,> model MyResourceProperties {,> displayName: string;,> config: MyConfig;,> },> ,> ,> After (explicitly declare optional properties for update):,> ,> tsp,> model MyResourceUpdateProperties {,> displayName?: string;,> config?: MyConfig;,> },> ,> ,> Or continue using ResourceUpdateModel<Resource, Properties> which already handles this transformation for standard ARM resource patterns.

@azure-tools/typespec-azure-core - breaking ✏️

Removed implicitOptionality: true from the @patch decorator on the following operation templates:,> ,> - ResourceCreateOrUpdate,> - LongRunningResourceCreateOrUpdate,> - ResourceUpdate,> ,> Previously, these templates used @patch(#{ implicitOptionality: true }) which caused all properties in the PATCH request body to be implicitly treated as optional, regardless of how they were declared in the model. This behavior is now removed — properties will retain their declared optionality.,> ,> #### Migration,> ,> If your service relies on all properties being optional in the PATCH body, you need to explicitly mark them as optional in your model:,> ,> Before (implicit optionality made all properties optional automatically):,> ,> tsp,> model Widget {,> name: string;,> color: string;,> },> ,> ,> After (explicitly declare optional properties):,> ,> tsp,> model WidgetUpdate {,> name?: string;,> color?: string;,> },> ,> ,> Alternatively, you can use the ResourceUpdateModel template or OptionalProperties utility to derive an all-optional version of your model for PATCH operations. If you were already using ResourceUpdateModel<Resource> or manually defining optional properties in your update model, no changes are needed.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

⚡ Benchmark Results

Comparing [4787f3e] against baseline [cd75cba]

Metric Baseline Current Change
total 🔴 850.3ms 🔴 856.3ms +0.7%
loader 🟢 174.5ms 🟢 172.3ms -1.2%
resolver 🟢 18.3ms 🟢 20.0ms +9.5% 🔴
checker 🟡 204.4ms 🟡 207.9ms +1.7%
validation 🟢 41.7ms 🟢 42.6ms +2.1%
 ↳ validation/@azure-tools/typespec-azure-core 🟢 6.5ms 🟢 6.9ms +5.3% 🔴
 ↳ validation/@typespec/http 🟢 5.8ms 🟢 6.3ms +8.6% 🔴
 ↳ validation/@typespec/rest 🟢 0.5ms 🟢 0.6ms +16.4% 🔴
 ↳ validation/@typespec/versioning 🔴 26.9ms 🔴 27.3ms +1.5%
 ↳ validation/compiler 🟢 2.0ms 🟢 1.5ms -22.6% 🟢
linter 🟢 151.6ms 🟢 153.1ms +1.0%
 ↳ linter/@azure-tools/typespec-azure-core/auth-required 🟢 0.0ms 🟢 0.0ms -1.6%
 ↳ linter/@azure-tools/typespec-azure-core/bad-record-type 🟢 0.2ms 🟢 0.2ms -0.9%
 ↳ linter/@azure-tools/typespec-azure-core/byos 🟢 6.5ms 🟢 8.5ms +31.9% 🔴
 ↳ linter/@azure-tools/typespec-azure-core/casing-style 🟢 0.7ms 🟢 0.6ms -3.5%
 ↳ linter/@azure-tools/typespec-azure-core/composition-over-inheritance 🟢 0.1ms 🟢 0.1ms -6.9% 🟢
 ↳ linter/@azure-tools/typespec-azure-core/documentation-required 🟢 0.8ms 🟢 0.8ms +3.2%
 ↳ linter/@azure-tools/typespec-azure-core/friendly-name 🟢 0.7ms 🟢 0.7ms +0.5%
 ↳ linter/@azure-tools/typespec-azure-core/key-visibility-required 🟢 0.2ms 🟢 0.2ms +1.4%
 ↳ linter/@azure-tools/typespec-azure-core/known-encoding 🟢 0.3ms 🟢 0.2ms -9.9% 🟢
 ↳ linter/@azure-tools/typespec-azure-core/long-running-polling-operation-required 🟢 0.3ms 🟢 0.3ms -2.7%
 ↳ linter/@azure-tools/typespec-azure-core/no-case-mismatch 🟢 0.2ms 🟢 0.2ms +2.3%
 ↳ linter/@azure-tools/typespec-azure-core/no-closed-literal-union 🟢 0.3ms 🟢 0.3ms -3.5%
 ↳ linter/@azure-tools/typespec-azure-core/no-enum 🟢 0.0ms 🟢 0.0ms +2.4%
 ↳ linter/@azure-tools/typespec-azure-core/no-error-status-codes 🟢 0.1ms 🟢 0.1ms -4.6%
 ↳ linter/@azure-tools/typespec-azure-core/no-explicit-routes-resource-ops 🟢 0.1ms 🟢 0.1ms -2.5%
 ↳ linter/@azure-tools/typespec-azure-core/no-format 🟢 0.5ms 🟢 0.7ms +37.1% 🔴
 ↳ linter/@azure-tools/typespec-azure-core/no-generic-numeric 🟢 0.4ms 🟢 0.4ms +5.4% 🔴
 ↳ linter/@azure-tools/typespec-azure-core/no-header-explode 🔴 21.4ms 🔴 22.3ms +4.1%
 ↳ linter/@azure-tools/typespec-azure-core/no-legacy-usage 🟢 1.2ms 🟢 1.1ms -1.8%
 ↳ linter/@azure-tools/typespec-azure-core/no-multiple-discriminator 🟢 0.1ms 🟢 0.1ms -2.2%
 ↳ linter/@azure-tools/typespec-azure-core/no-nullable 🟢 0.2ms 🟢 0.2ms -0.2%
 ↳ linter/@azure-tools/typespec-azure-core/no-offsetdatetime 🟢 1.3ms 🟢 1.3ms +0.6%
 ↳ linter/@azure-tools/typespec-azure-core/no-openapi 🟢 1.9ms 🟢 1.9ms -2.3%
 ↳ linter/@azure-tools/typespec-azure-core/no-private-usage 🟢 1.9ms 🟢 1.9ms +0.9%
 ↳ linter/@azure-tools/typespec-azure-core/no-query-explode 🔴 22.1ms 🔴 21.8ms -1.3%
 ↳ linter/@azure-tools/typespec-azure-core/no-response-body 🔴 23.8ms 🔴 23.0ms -3.4%
 ↳ linter/@azure-tools/typespec-azure-core/no-rest-library-interfaces 🟢 0.0ms 🟢 0.0ms -2.6%
 ↳ linter/@azure-tools/typespec-azure-core/no-route-parameter-name-mismatch 🟢 6.3ms 🟢 6.6ms +5.2% 🔴
 ↳ linter/@azure-tools/typespec-azure-core/no-rpc-path-params 🟢 0.2ms 🟢 0.2ms -4.9%
 ↳ linter/@azure-tools/typespec-azure-core/no-string-discriminator 🟢 0.1ms 🟢 0.1ms -0.7%
 ↳ linter/@azure-tools/typespec-azure-core/no-unknown 🟢 0.2ms 🟢 0.2ms -2.3%
 ↳ linter/@azure-tools/typespec-azure-core/no-unnamed-union 🟢 0.3ms 🟢 0.3ms -1.9%
 ↳ linter/@azure-tools/typespec-azure-core/operation-missing-api-version 🟢 0.2ms 🟢 0.2ms -4.3%
 ↳ linter/@azure-tools/typespec-azure-core/request-body-problem 🟢 0.2ms 🟢 0.2ms -4.0%
 ↳ linter/@azure-tools/typespec-azure-core/require-versioned 🟢 0.0ms 🟢 0.0ms +6.2% 🔴
 ↳ linter/@azure-tools/typespec-azure-core/response-schema-problem 🔴 25.0ms 🔴 26.3ms +5.2% 🔴
 ↳ linter/@azure-tools/typespec-azure-core/rpc-operation-request-body 🟢 0.3ms 🟢 0.4ms +3.4%
 ↳ linter/@azure-tools/typespec-azure-core/spread-discriminated-model 🟢 0.3ms 🟢 0.3ms +0.0%
 ↳ linter/@azure-tools/typespec-azure-core/use-standard-names 🟢 5.4ms 🟢 6.8ms +25.0% 🔴
 ↳ linter/@azure-tools/typespec-azure-core/use-standard-operations 🟢 0.4ms 🟢 0.1ms -66.2% 🟢
 ↳ linter/@azure-tools/typespec-azure-resource-manager/arm-common-types-version 🟢 5.8ms 🟢 6.8ms +17.1% 🔴
 ↳ linter/@azure-tools/typespec-azure-resource-manager/arm-custom-resource-no-key 🟢 0.1ms 🟢 0.1ms -2.8%
 ↳ linter/@azure-tools/typespec-azure-resource-manager/arm-custom-resource-usage-discourage 🟢 0.1ms 🟢 0.1ms -5.0%
 ↳ linter/@azure-tools/typespec-azure-resource-manager/arm-delete-operation-response-codes 🟢 7.1ms 🟢 7.4ms +3.2%
 ↳ linter/@azure-tools/typespec-azure-resource-manager/arm-no-record 🟢 0.4ms 🟢 0.4ms -2.8%
 ↳ linter/@azure-tools/typespec-azure-resource-manager/arm-post-operation-response-codes 🟢 0.7ms 🟢 0.7ms +1.0%
 ↳ linter/@azure-tools/typespec-azure-resource-manager/arm-put-operation-response-codes 🟢 0.0ms 🟢 0.0ms +4.4%
 ↳ linter/@azure-tools/typespec-azure-resource-manager/arm-resource-action-no-segment 🟢 0.3ms 🟢 0.2ms -8.7% 🟢
 ↳ linter/@azure-tools/typespec-azure-resource-manager/arm-resource-duplicate-property 🟢 0.2ms 🟢 0.2ms +0.3%
 ↳ linter/@azure-tools/typespec-azure-resource-manager/arm-resource-interface-requires-decorator 🟢 0.0ms 🟢 0.0ms +8.5% 🔴
 ↳ linter/@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-action-verb 🟢 0.1ms 🟢 0.1ms -5.3% 🟢
 ↳ linter/@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property 🟢 0.1ms 🟢 0.1ms -3.6%
 ↳ linter/@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-version-format 🟢 0.1ms 🟢 0.1ms +7.7% 🔴
 ↳ linter/@azure-tools/typespec-azure-resource-manager/arm-resource-key-invalid-chars 🟢 0.3ms 🟢 0.3ms +2.6%
 ↳ linter/@azure-tools/typespec-azure-resource-manager/arm-resource-name-pattern 🟢 0.0ms 🟢 0.0ms +33.1% 🔴
 ↳ linter/@azure-tools/typespec-azure-resource-manager/arm-resource-operation 🟢 0.2ms 🟢 0.2ms -4.6%
 ↳ linter/@azure-tools/typespec-azure-resource-manager/arm-resource-operation-response 🟢 8.2ms 🟢 8.4ms +3.3%
 ↳ linter/@azure-tools/typespec-azure-resource-manager/arm-resource-patch 🟢 0.4ms 🟢 0.4ms -2.0%
 ↳ linter/@azure-tools/typespec-azure-resource-manager/arm-resource-path-segment-invalid-chars 🟢 0.3ms 🟢 0.2ms -2.2%
 ↳ linter/@azure-tools/typespec-azure-resource-manager/arm-resource-provisioning-state 🟢 0.1ms 🟢 0.1ms -2.7%
 ↳ linter/@azure-tools/typespec-azure-resource-manager/beyond-nesting-levels 🟢 0.1ms 🟢 0.1ms -8.2% 🟢
 ↳ linter/@azure-tools/typespec-azure-resource-manager/empty-updateable-properties 🟢 0.2ms 🟢 0.2ms -1.2%
 ↳ linter/@azure-tools/typespec-azure-resource-manager/improper-subscription-list-operation 🟢 0.0ms 🟢 0.0ms -5.3% 🟢
 ↳ linter/@azure-tools/typespec-azure-resource-manager/lro-location-header 🟡 18.9ms 🟡 18.9ms +0.0%
 ↳ linter/@azure-tools/typespec-azure-resource-manager/missing-operations-endpoint 🟢 0.0ms 🟢 0.0ms -1.5%
 ↳ linter/@azure-tools/typespec-azure-resource-manager/missing-x-ms-identifiers 🟢 0.3ms 🟢 0.3ms -5.9% 🟢
 ↳ linter/@azure-tools/typespec-azure-resource-manager/no-empty-model 🟢 0.2ms 🟢 0.2ms -6.4% 🟢
 ↳ linter/@azure-tools/typespec-azure-resource-manager/no-resource-delete-operation 🟢 0.2ms 🟢 0.2ms -4.8%
 ↳ linter/@azure-tools/typespec-azure-resource-manager/no-response-body 🔴 38.3ms 🔴 27.8ms -27.4% 🟢
 ↳ linter/@azure-tools/typespec-azure-resource-manager/patch-envelope 🟢 0.2ms 🟢 0.2ms +0.6%
 ↳ linter/@azure-tools/typespec-azure-resource-manager/resource-name 🟢 0.2ms 🟢 0.2ms +3.0%
 ↳ linter/@azure-tools/typespec-azure-resource-manager/secret-prop 🟢 2.6ms 🟢 2.5ms -4.8%
 ↳ linter/@azure-tools/typespec-azure-resource-manager/unsupported-type 🟢 0.4ms 🟢 0.4ms -0.1%
 ↳ linter/@azure-tools/typespec-client-generator-core/property-name-conflict 🟢 1.1ms 🟢 1.1ms +1.0%
 ↳ linter/@azure-tools/typespec-client-generator-core/require-client-suffix 🟢 0.2ms 🟢 0.2ms +2.0%
emit 🟡 259.9ms 🟡 260.5ms +0.2%
 ↳ emit/@azure-tools/typespec-autorest 🟢 163.8ms 🟢 165.0ms +0.7%
 ↳ emit/@typespec/openapi3 🟢 144.0ms 🟢 143.1ms -0.7%
 ↳ emit/@typespec/openapi3/compute 🟢 129.3ms 🟢 125.1ms -3.2%
 ↳ emit/@typespec/openapi3/write 🟢 14.6ms 🟢 17.9ms +22.1% 🔴

Averaged across 3 specs (azure-arm-resource-manager, azure-core-dataplane, azure-full).
Threshold: changes > ±5% are highlighted.

@azure-sdk
Copy link
Copy Markdown
Collaborator

azure-sdk commented May 6, 2026

You can try these changes here

🛝 Playground 🌐 Website

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

int:azure-specs Run integration tests against azure-rest-api-specs lib:azure-core Issues for @azure-tools/typespec-azure-core library lib:azure-http-specs For issues/prs related to the @azure-tools/typespec-azure-http-specs package lib:azure-resource-manager Issues for @azure-tools/typespec-azure-core library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants