RicoSuter / NSwag

The Swagger/OpenAPI toolchain for .NET, ASP.NET Core and TypeScript.
http://NSwag.org
MIT License
6.62k stars 1.23k forks source link

C# class is wrong #4762

Open M2xAy opened 5 months ago

M2xAy commented 5 months ago

Hi

I have following config: { "runtime": "Net70", "documentGenerator": { "fromDocument": { "json": "./openapi.yaml" } }, "codeGenerators": { "openApiToCSharpClient": { "UseHttpClientCreationMethod": true, "generateDtoTypes": true, "generateOptionalParameters": false, "clientBaseClass": null, "generateClientClasses": true, "OperationGenerationMode": "SingleClientFromOperationId", "generateClientInterfaces": true, "clientBaseInterface": null, "injectHttpClient": true, "disposeHttpClient": false, "generateDataAnnotations": true, "exposeJsonSerializerSettings": true, "JsonLibrary": "SystemTextJson ", "useBaseUrl": false, "namespace": "AAA.PlutoLibraryComponent.Modules.Pluto", "requiredPropertiesMustBeDefined": false, "ClassName": "PlutoLibrary", "output": "../Pluto/PlutoLibrary.cs", "contractsOutputFilePath": null, "generateImmutableArrayProperties": false, "generateImmutableDictionaryProperties": false } } }

when i import documentation in postman, the pageable and filter objects are in get parameter with &page=0&size=1&sort=string, but when i create c# code it creates additional parameters and filter and pageable object has no effect. can you help me?

` public virtual async System.Threading.Tasks.Task FindInspectionPageByFilterAsync(InspectionFilter filter, Pageable pageable, System.Threading.CancellationToken cancellationToken) { if (filter == null) throw new System.ArgumentNullException("filter");

        if (pageable == null)
            throw new System.ArgumentNullException("pageable");

        var urlBuilder_ = new System.Text.StringBuilder();
        urlBuilder_.Append("public/api/v1/inspection?");
        foreach (var item_ in filter.AdditionalProperties) { urlBuilder_.Append(System.Uri.EscapeDataString(item_.Key) + "=").Append(System.Uri.EscapeDataString(ConvertToString(item_.Value, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); }
        foreach (var item_ in pageable.AdditionalProperties) { urlBuilder_.Append(System.Uri.EscapeDataString(item_.Key) + "=").Append(System.Uri.EscapeDataString(ConvertToString(item_.Value, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); }
        urlBuilder_.Length--;

`