Azure / autorest.powershell

AutoRest PowerShell Generator
MIT License
113 stars 86 forks source link

Parameter name is a duplicate #1356

Closed benwa closed 4 months ago

benwa commented 4 months ago

When attempting to build modules for MS Teams using the PagerDuty OpenAPI spec, I get an error of

The parameter name 'incidentId' is a duplicate

readme.md

    # PS-PagerDuty
    A PowerShell module for PagerDuty generated by AutoRest

    ## AutoRest Configuration
    > see https://aka.ms/autorest

    ```yaml
    powershell: true
    module-version: 0.1.0
    module-name: $(namespace)
    help-link-prefix: $(metadata.projectUri)/$(output-folder)/docs/
    metadata:
      authors: Bennett Blodinger
      description: A PowerShell module for PagerDuty generated by AutoRest
      licenseUri: $(metadata.projectUri)/blob/main/LICENSE
      projectUri: https://github.com/benwa/PS-PagerDuty
    license-header: MICROSOFT_MIT_NO_VERSION
    pwsh-license-header: $(license-header)
    clear-output-folder: true
    sanitize-names: true

    directive:
    - select: command
      where:
        variant: Create
      remove: true
```yaml $(tag) == 'ms-teams-integration'
namespace: PagerDuty.MSTeamsIntegration
input-file: ms-teams-integration.json
output-folder: ms-teams-integration
```


I'm sure this is something a directive can handle, but I'm lost on what to do.
dolauli commented 4 months ago

I think the root cause is because you define the parameter twice. Please remove either of them. https://github.com/PagerDuty/api-schema/blob/main/reference/integration-ms-teams-service/openapiv3.json#L32-L34 or https://github.com/PagerDuty/api-schema/blob/main/reference/integration-ms-teams-service/openapiv3.json#L66-L68

benwa commented 4 months ago

I really tried to resolve it with something like this, but it doesn't seem to be doing it; I still get the same result.

namespace: PagerDuty.MSTeamsIntegration
input-file: ms-teams-integration.json
output-folder: ms-teams-integration
directive:
- where: $.paths["/incidents/{incident_id}/meeting"].post.parameters
  transform: >
    return $.filter(x => x.$ref !== `#/components/parameters/incident_id`)
dolauli commented 4 months ago

Swagger is incorrect. You should change the swagger directly. You really want to delete some stuff through directive. You could try to remove https://github.com/PagerDuty/api-schema/blob/main/reference/integration-ms-teams-service/openapiv3.json#L31-L35 by following some examples in https://github.com/Azure/azure-powershell/tree/main/src/Functions/Functions.Autorest#readme

benwa commented 4 months ago

I don't work for PagerDuty, so the best I can do there is raise a ticket with them.

However, those samples pointed me that I needed to set the from: parameter in the directive to the json. Thank you for pointing me in the right direction!