Skip to content

TypeSpec conversion for resources/policy#38509

Merged
pshao25 merged 52 commits intoAzure:mainfrom
weidongxu-microsoft:tsp-convertion_resources-policy
Jan 6, 2026
Merged

TypeSpec conversion for resources/policy#38509
pshao25 merged 52 commits intoAzure:mainfrom
weidongxu-microsoft:tsp-convertion_resources-policy

Conversation

@weidongxu-microsoft
Copy link
Member

@weidongxu-microsoft weidongxu-microsoft commented Oct 30, 2025

Difference in Swagger

  • route /{policyAssignmentId} is not included <- it is OKed by service
    For backward compatible on SDK, they are added in "client.tsp" with @scope
  • x-ms-skip-url-encoding=true on $filter query parameter is not included
    1. This is not supported in TypeSpec
    2. Arguably, it was wrong to define them as true in Swagger. User of the API is unliked to escape it before calling the API.
    3. For any SDK that contains manual code, please check whether convenience code escaped it for user.
  • value of paged response changed to "required"
  • Some { "type: "object" } changed to {} (due to TypeSpec unknown)
  • PolicyAssignment, PolicyDefinition, PolicyDefinitionVersion, PolicySetDefinition, PolicySetDefinitionVersion now has base model ProxyResource

ARM (Control Plane) API Specification Update Pull Request

Tip

Overwhelmed by all this guidance? See the Getting help section at the bottom of this PR description.

PR review workflow diagram

Please understand this diagram before proceeding. It explains how to get your PR approved & merged.

spec_pr_review_workflow_diagram

Purpose of this PR

What's the purpose of this PR? Check the specific option that applies. This is mandatory!

  • New resource provider.
  • New API version for an existing resource provider. (If API spec is not defined in TypeSpec, the PR should have been created in adherence to OpenAPI specs PR creation guidance).
  • Update existing version for a new feature. (This is applicable only when you are revising a private preview API version.)
  • Update existing version to fix OpenAPI spec quality issues in S360.
  • Convert existing OpenAPI spec to TypeSpec spec (do not combine this with implementing changes for a new API version).
  • Other, please clarify:
    • edit this with your clarification

Due diligence checklist

To merge this PR, you must go through the following checklist and confirm you understood
and followed the instructions by checking all the boxes:

  • I confirm this PR is modifying Azure Resource Manager (ARM) related specifications, and not data plane related specifications.
  • I have reviewed following Resource Provider guidelines, including
    ARM resource provider contract and
    REST guidelines (estimated time: 4 hours).
    I understand this is required before I can proceed to the diagram Step 2, "ARM API changes review", for this PR.
  • A release plan has been created. If not, please create one as it will help guide you through the REST API and SDK creation process.

Additional information

Viewing API changes

For convenient view of the API changes made by this PR, refer to the URLs provided in the table
in the Generated ApiView comment added to this PR. You can use ApiView to show API versions diff.

Suppressing failures

If one or multiple validation error/warning suppression(s) is detected in your PR, please follow the
suppressions guide to get approval.

Getting help

  • First, please carefully read through this PR description, from top to bottom. Please fill out the Purpose of this PR and Due diligence checklist.
  • If you don't have permissions to remove or add labels to the PR, request write access per aka.ms/azsdk/access#request-access-to-rest-api-or-sdk-repositories
  • To understand what you must do next to merge this PR, see the Next Steps to Merge comment. It will appear within few minutes of submitting this PR and will continue to be up-to-date with current PR state.
  • For guidance on fixing this PR CI check failures, see the hyperlinks provided in given failure
    and https://aka.ms/ci-fix.
  • For help with ARM review (PR workflow diagram Step 2), see https://aka.ms/azsdk/pr-arm-review.
  • If the PR CI checks appear to be stuck in queued state, please add a comment with contents /azp run.
    This should result in a new comment denoting a PR validation pipeline has started and the checks should be updated after few minutes.
  • If the help provided by the previous points is not enough, post to https://aka.ms/azsdk/support/specreview-channel and link to this PR.
  • For guidance on SDK breaking change review, refer to https://aka.ms/ci-fix.

@github-actions
Copy link

github-actions bot commented Oct 30, 2025

Next Steps to Merge

✅ All automated merging requirements have been met! To get your PR merged, see aka.ms/azsdk/specreview/merge.

Comment generated by summarize-checks workflow run.

@github-actions github-actions bot added resource-manager TypeSpec Authored with TypeSpec labels Oct 30, 2025
@github-actions
Copy link

github-actions bot commented Oct 30, 2025

API Change Check

APIView identified API level changes in this PR and created the following API reviews

Language API Review for Package
TypeSpec Microsoft.Authorization
Java com.azure.resourcemanager:azure-resourcemanager-resources-policy
Go sdk/resourcemanager/resources/armpolicy
JavaScript @azure/arm-policy
Swagger Microsoft.Authorization-policy
Python azure-mgmt-resource-policy

@github-actions github-actions bot added the BreakingChangeReviewRequired <valid label in PR review process>add this label when breaking change review is required label Oct 30, 2025
* The parameter values for the assigned policy rule. The keys are the parameter names.
*/
#suppress "@azure-tools/typespec-azure-resource-manager/arm-no-record" "For backward compatibility"
parameters?: ParameterValues;
Copy link
Member

@jliusan jliusan Dec 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/Azure/azure-rest-api-specs-pr/blob/main/specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/policyAssignments.json#L775
https://github.com/Azure/azure-rest-api-specs-pr/blob/main/specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/policyAssignments.json#L881
image
It is not consistent with the definition in swagger, and this cause go breaking change like - Type of AssignmentProperties.Parametershas been changed frommap[string]*ParameterValuesValueto*ParameterValues``,and there are several similar parameters changes.
Is this designed?

Copy link
Member Author

@weidongxu-microsoft weidongxu-microsoft Jan 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume that

    "ParameterValues": {
      "type": "object",
      "additionalProperties": {
        "$ref": "#/definitions/ParameterValuesValue"
      },
      "description": "The parameter values for the policy rule. The keys are the parameter names."
    },

means ParameterValues is a dict of ParameterValuesValue.

Hence in TypeSpec

model ParameterValues is Record<ParameterValuesValue>;

then

  parameters?: ParameterValues;

@jliusan
Do you prefer we write it as

  parameters?: Record<ParameterValuesValue>;

(without the ParameterValues model)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the Swagger, I think the current way of writing be same (that is the reason why I wrote it this way, with a ParameterValues).

Original Swagger
https://github.com/Azure/azure-rest-api-specs/blob/main/specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2025-03-01/policyAssignments.json#L775-L778

The Swagger generated from TypeSpec

"parameters": {
"$ref": "#/definitions/ParameterValues",
"description": "The parameter values for the assigned policy rule. The keys are the parameter names."
},

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume that

    "ParameterValues": {
      "type": "object",
      "additionalProperties": {
        "$ref": "#/definitions/ParameterValuesValue"
      },
      "description": "The parameter values for the policy rule. The keys are the parameter names."
    },

means ParameterValues is a dict of ParameterValuesValue.

Hence in TypeSpec

model ParameterValues is Record<ParameterValuesValue>;

then

  parameters?: ParameterValues;

@jliusan Do you prefer we write it as

  parameters?: Record<ParameterValuesValue>;

(without the ParameterValues model)?

Yes, go prefers parameters?: Record<ParameterValuesValue>;

Copy link
Member Author

@weidongxu-microsoft weidongxu-microsoft Jan 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed in bc62110

SDK likely won't have break from the diff on Swagger (caused by this change). As least for Java from m4, there is no ParameterValues class generated from Swagger.

@jliusan
Copy link
Member

jliusan commented Jan 4, 2026

/azp run SDK Validation - Go

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).


@armResourceOperations
interface PolicyAssignments {
/**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Go has breaking change like these, and there are no ops named as these in tsp file but exist in swagger on main branch, are these funcs removed by designed ?

- Function `*AssignmentsClient.CreateByID` has been removed
- Function `*AssignmentsClient.DeleteByID` has been removed
- Function `*AssignmentsClient.GetByID` has been removed
- Function `*AssignmentsClient.UpdateByID` has been removed

Copy link
Member Author

@weidongxu-microsoft weidongxu-microsoft Jan 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are moved into client.tsp, because these ops are not the genuine "CRUD" on the resource model, but describing another equivalent route to it (e.g. route {endpoint}/{policyAssignmentId}). Also see PR description.

Chenjie seems fine to remove them from Go SDK.

If you'd like to have them, you can add "go" scope to these ops in client.tsp (currently it be @scope("java"))

Also note for #38509 (comment) on the get op

@pshao25 pshao25 added BreakingChange-Approved-Benign Changes are not breaking at the REST API level and have at most minor impact to generated SDKs. BreakingChange-JavaScript-Sdk-Approved labels Jan 6, 2026
@github-actions github-actions bot added WaitForARMFeedback <valid label in PR review process> add this label when ARM review is required and removed NotReadyForARMReview labels Jan 6, 2026
@pshao25 pshao25 added Approved-LintDiff NotReadyForARMReview Approved-Avocado PublishToCustomers Acknowledgement the changes will be published to Azure customers. and removed WaitForARMFeedback <valid label in PR review process> add this label when ARM review is required labels Jan 6, 2026
@github-actions github-actions bot added WaitForARMFeedback <valid label in PR review process> add this label when ARM review is required and removed NotReadyForARMReview labels Jan 6, 2026
@pshao25 pshao25 added ARMSignedOff <valid label in PR review process>add this label when ARM approve updates after review NotReadyForARMReview and removed WaitForARMFeedback <valid label in PR review process> add this label when ARM review is required labels Jan 6, 2026
@pshao25 pshao25 merged commit e9d8529 into Azure:main Jan 6, 2026
136 of 140 checks passed
@weidongxu-microsoft weidongxu-microsoft deleted the tsp-convertion_resources-policy branch January 6, 2026 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Approved-Avocado Approved-LintDiff Approved-Suppression ARMReview ARMSignedOff <valid label in PR review process>add this label when ARM approve updates after review BreakingChange-Approved-Benign Changes are not breaking at the REST API level and have at most minor impact to generated SDKs. BreakingChange-JavaScript-Sdk BreakingChange-JavaScript-Sdk-Approved BreakingChangeReviewRequired <valid label in PR review process>add this label when breaking change review is required PublishToCustomers Acknowledgement the changes will be published to Azure customers. resource-manager SuppressionReviewRequired TypeSpec Authored with TypeSpec

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants