Azure / Azure/autorest.powershell

Directives: Reference the command's subject when setting parameter name

Open
#925 6 comments 0 reactions 0 assignees View on GitHub
feature-request P2
Dominant language
C#
Stars
123
Forks
99
PR merge metrics
No merged PRs in 30d

Description

I'm trying to use a directive on all of my cmdlets that end up with the `Import` verb and that have an `Id` parameter to change the parameter name to be `[subject]Id`. I didn't think this was possible until I was looking through the directives that the Microsoft.Graph module SDK uses. They have a directive that looks like this:

```yaml
- where:
subject: ^(User|ServicePrincipal|Contact|Device)(Member|TransitiveMember)ByRef$
set:
alias: ${verb}-Mg${subject}
```

So I was hoping to be able to do something similar for parameter names:

```yaml
- where:
verb: Import
parameter-name: Id
set:
parameter-name: ${subject}Id
```

With this, as an example, if I had a cmdlet called `Import-RwRunner` I would expect the `Id` parameter to then become `RunnerId`. However, it literally becomes `${subject}Id`. Here's the parameter from the cmdlet.cs file:

```csharp
private string _${subject}Id;
```

And, obviously, this doesn't build.

Is this supported? Or am I doing it wrong?

If it's not supported, is there a way I can make this change without updating the OpenAPI doc?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.