Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[new rule]: Checking path parameter name consistency #388

Open
ArcturusZhang opened this issue Sep 21, 2022 · 2 comments
Open

[new rule]: Checking path parameter name consistency #388

ArcturusZhang opened this issue Sep 21, 2022 · 2 comments
Labels

Comments

@ArcturusZhang
Copy link
Member

Lint rule description

For instance we have a path:

/subscriptions/{subsId}/resourceGroups/{rgName}/providers/Microsoft.Compute/virtualMachines/{name}

and any sub-path whose parent is this path, should have exactly the same prefix as the above path, including the variable names.

/subscriptions/{subsId}/resourceGroups/{rgName}/providers/Microsoft.Compute/virtualMachines/{name}/start

this is acceptable, but this

/subscriptions/{subsId}/resourceGroups/{rgName}/providers/Microsoft.Compute/virtualMachines/{vmName}/powerOff

is not acceptable.

Related swagger example

The changes in this PR Azure/azure-rest-api-specs#20588 is aligning such a parameter name between two paths.

Category

SDK

Severity level

Error

Applies to

Management plane API spec, Data plane API spec

How to fix the violation

The swagger should rename the violated parameter name to keep them aligned with each other across different paths with parenting relationship

What't the impact if breaking the rule

This benefits the tools that validate parenting relationship between operations and resources, and will make the generated SDKs have aligned parameter names

@jianyexi
Copy link
Contributor

jianyexi commented Sep 21, 2022

So do we have suggestion on which name should be treated as the source of truth

@tombuildsstuff
Copy link

tombuildsstuff commented Sep 21, 2022

So do we have suggestion on which name should be treated as the source of truth

FWIW we're using the Resource itself (e.g. the VM) as the source of truth as other URIs are operations on this resource (e.g. /restart, or provisioning a nested resource under the parent resource) - so I'd suggest doing the same here such that given the URIs:

/subscriptions/{subsId}/resourceGroups/{rgName}/providers/Microsoft.Compute/virtualMachines/{name}
/subscriptions/{subsId}/resourceGroups/{rgName}/providers/Microsoft.Compute/virtualMachines/{vmName}/restart
/subscriptions/{subsId}/resourceGroups/{rgName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{extensionName}

The URI /subscriptions/{subsId}/resourceGroups/{rgName}/providers/Microsoft.Compute/virtualMachines/{name} (and the segment name) should be the source of truth, and raise an error about these two operations:

/subscriptions/{subsId}/resourceGroups/{rgName}/providers/Microsoft.Compute/virtualMachines/{vmName}/restart
/subscriptions/{subsId}/resourceGroups/{rgName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{extensionName}

using the segment name vmName rather than name?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants