Azure / autorest

OpenAPI (f.k.a Swagger) Specification code generator. Supports C#, PowerShell, Go, Java, Node.js, TypeScript, Python
MIT License
4.54k stars 728 forks source link

Module fails to build due to duplicate definitions #4985

Closed benwa closed 3 days ago

benwa commented 6 days ago

Before filling a bug

Describe the bug

I am attempting to build an AutoRest PowerShell module from PagerDuty's OpenAPI schema, however it fails stating that there is already a definition for 'Client'.

This is on Ubuntu 24.04, dotnet-sdk-8.0, PowerShell 7.4 snap.

readme.md

    # PS-PagerDuty

    A PowerShell module for PagerDuty generated by AutoRest

    > see https://aka.ms/autorest

    ## Configuration

    The following are the settings for using this API with AutoRest.

    ```yaml
    powershell: true
    clear-output-folder: true
    license-header: MICROSOFT_MIT_NO_VERSION
```yaml $(tag) == 'events-v2'
namespace: PagerDuty.EventsV2
override-client-name: PagerDuty.EventsV2
input-file: events-v2.json
output-folder: events-v2
```

```bash
ben@ubuntu:~$ autorest --tag=events-v2
AutoRest code generation utility [cli version: 3.7.1; node: v20.15.0]
(C) 2018 Microsoft Corporation.
https://aka.ms/autorest
info    |    Loading AutoRest core      '/home/ben/.autorest/@autorestcore@3.10.2/nodemodules/@autorest/core/dist' (3.10.2)
info    | 
The default version of @autorest/powershell has been bumped from 3.0+ to 4.0+.
 > If you still want to use 3.0+ version, please specify it with --use:@autorest/powershell@3.0.{x}, e.g 3.0.512.

info    |    Loading AutoRest extension '@autorest/powershell' (~4.0.0->4.0.698)
info    |    Loading AutoRest extension '@autorest/modelerfour' (~4.26.0->4.26.2)
warning | PreCheck/CheckDuplicateSchemas | Checking for duplicate schemas, this could take a (long) while.  Run with --verbose for more detail.
warning | UsingTemporaryFlag | modelerfour.treat-type-object-as-anything options is a temporary flag. It WILL be removed in the future.
warning | Modeler/MissingType | The enum schema 'Payload-severity' with an undefined type and enum values is ambiguous. This has been auto-corrected to 'type:string'
warning | Modeler/MissingType | The enum schema 'post-content-schema-event_action' with an undefined type and enum values is ambiguous. This has been auto-corrected to 'type:string'
info    | Autorest completed in 4.05s. 212 files generated.
ben@ubuntu:~$ pwsh -File ./events-v2/build-module.ps1 -run
Creating isolated process...
Cleaning build folders...
Compiling module...
/home/ben/events-v2/generated/cmdlets/NewV2Event_CreateExpanded.cs(74,23): error CS0102: The type 'NewV2Event_CreateExpanded' already contains a definition for 'Client' [/home/ben/events-v2/PagerDutyEventsV2.csproj]
Write-Error: /home/ben/events-v2/build-module.ps1:86
Line |
  86 |      Write-Error 'Compilation failed.'
     |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Compilation failed.

Expected behavior the PS module builds successfully

benwa commented 3 days ago

It was a conflict of the internal property Client. https://github.com/Azure/autorest.powershell/issues/1345