openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

[BUG] csharp generichost generator generates duplicate api methods

Open leorg99 opened this issue 4 months ago • 2 comments

Bug Report Checklist

  • [X] Have you provided a full/minimal spec to reproduce the issue?
  • [ ] Have you validated the input using an OpenAPI validator (example)?
  • [ ] Have you tested with the latest master to confirm the issue still exists?
  • [ ] Have you searched for related issues/PRs?
  • [ ] What's the actual output vs expected output?
  • [ ] [Optional] Sponsorship to speed up the bug fix or feature request (example)
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
  • Create csharp.config file
  • Execute the following:
nvm install latest
nvm use latest
npm install -g npm@latest
npm install @openapitools/openapi-generator-cli -D
curl -o filescom-v1.json https://app.files.com/api/rest/v1/swagger_doc.json
npx @openapitools/openapi-generator-cli generate -i .\filescom-v1.json -o .\generated -g csharp -c csharp.config

Build

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

#19626

Suggest a fix

leorg99 avatar Oct 16 '24 19:10 leorg99