OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.97k stars 6.59k forks source link

[BUG] csharp generichost generator generates duplicate api methods #19892

Open leorg99 opened 1 month ago

leorg99 commented 1 month ago

Bug Report Checklist

Description

The generated .NET code seems to generate duplicate API methods. For example, in GroupsApi.cs:

    public interface IGroupsApi : IApi
    {
        ...
        Task<IGetGroupsIdApiResponse> GetGroupsIdAsync(int id, System.Threading.CancellationToken cancellationToken = default);
        Task<IGetGroupsIdApiResponse?> GetGroupsIdOrDefaultAsync(int id, System.Threading.CancellationToken cancellationToken = default);
        Task<IGetGroupsId_0ApiResponse> GetGroupsId_0Async(int id, System.Threading.CancellationToken cancellationToken = default);
        Task<IGetGroupsId_0ApiResponse?> GetGroupsId_0OrDefaultAsync(int id, System.Threading.CancellationToken cancellationToken = default);
        ...

I don't see any differences between the duplicated API methods.

openapi-generator version

7.9.0

OpenAPI declaration file content or url
Generation Details

csharp.config

{
    "apiName": "FilesComApi",
    "library": "generichost",
    "netCoreProjectFile": true,
    "nullableReferenceTypes": true,
    "optionalAssemblyInfo": true,
    "packageName": "Files.Com.Core",
    "targetFramework": "net8.0",
    "sourceFolder": "src"
}
Steps to reproduce

Build

cd generated
dotnet new globaljson --sdk-version 8.0.400 --roll-forward feature
dotnet build
Related issues/PRs

19626

Suggest a fix
leorg99 commented 1 month ago

Thanks in advance! @devhl-labs @wing328

devhl-labs commented 1 month ago

You are seeing this because you have multiple group tags. You may not have seen it before because it was writing two files to identical file paths, other than casing. On Windows, that results in only one file being written. That bug was fixed, and now you have two duplicate methods. I am not sure why having tags should generate multiple methods, but it seems intended.