Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #14977
Closed
Open
Issue created Mar 16, 2023 by Reinhard-PTV@Reinhard-PTVContributor5 of 5 checklist items completed5/5 checklist items

[BUG] [dotnetcore] Implement QueryParameter deepObject style is missing for async function

Bug Report Checklist

  • 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?
Description

If I generate a client for c# containing a deep Object, the deep Object is missing in the async function call. Example:

java -jar openapi-generator-cli-6.4.0.jar generate -g csharp-netcore -i modules/openapi-generator/src/test/resources/3_0/deepobject.yaml

openapi-generator version

openapi-generator 6.4.0

OpenAPI declaration file content or url

modules/openapi-generator/src/test/resources/3_0/deepobject.yaml

Generation Details

Generate with java -jar openapi-generator-cli-6.4.0.jar generate -g csharp-netcore -i modules/openapi-generator/src/test/resources/3_0/deepobject.yaml

generates

public async System.Threading.Tasks.Task<Org.OpenAPITools.Client.ApiResponse<string>> TestWithHttpInfoAsync(Pet options = default(Pet), Options inputOptions = default(Options), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
        {

            Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions();

            string[] _contentTypes = new string[] {
            };

            // to determine the Accept header
            string[] _accepts = new string[] {
                "text/plain"
            };

            var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes);
            if (localVarContentType != null)
            {
                localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType);
            }

            var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts);
            if (localVarAccept != null)
            {
                localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept);
            }

            if (options != null)
            {
                localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "options", options));
            }
            if (inputOptions != null)
            {
                localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "inputOptions", inputOptions));
            }

            localVarRequestOptions.Operation = "DefaultApi.Test";
            localVarRequestOptions.OperationIndex = operationIndex;


            // make the HTTP request
            var localVarResponse = await this.AsynchronousClient.GetAsync<string>("/test", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false);

            if (this.ExceptionFactory != null)
            {
                Exception _exception = this.ExceptionFactory("Test", localVarResponse);
                if (_exception != null)
                {
                    throw _exception;
                }
            }

            return localVarResponse;
        }

but expected is:

        public async System.Threading.Tasks.Task<Org.OpenAPITools.Client.ApiResponse<string>> TestWithHttpInfoAsync(Pet options = default(Pet), Options inputOptions = default(Options), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
        {

            Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions();

            string[] _contentTypes = new string[] {
            };

            // to determine the Accept header
            string[] _accepts = new string[] {
                "text/plain"
            };

            var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes);
            if (localVarContentType != null)
            {
                localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType);
            }

            var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts);
            if (localVarAccept != null)
            {
                localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept);
            }

            if (options != null)
            {
                if (options.Id != null)
                {
                    localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "options[id]", options.Id));
                }
                if (options.Name != null)
                {
                    localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "options[name]", options.Name));
                }
                if (options.Category != null)
                {
                    localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "options[category]", options.Category));
                }
                if (options.PhotoUrls != null)
                {
                    localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "options[photoUrls]", options.PhotoUrls));
                }
                if (options.Tags != null)
                {
                    localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "options[tags]", options.Tags));
                }
                if (options.Status != null)
                {
                    localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "options[status]", options.Status));
                }
            }
            if (inputOptions != null)
            {
                if (inputOptions.A != null)
                {
                    localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "inputOptions[a]", inputOptions.A));
                }
                if (inputOptions.B != null)
                {
                    localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "inputOptions[b]", inputOptions.B));
                }
                if (inputOptions.C != null)
                {
                    localVarRequestOptions.QueryParameters.Add(Org.OpenAPITools.Client.ClientUtils.ParameterToMultiMap("", "inputOptions[c]", inputOptions.C));
                }
            }
Steps to reproduce

java -jar openapi-generator-cli-6.4.0.jar generate -g csharp-netcore -i modules/openapi-generator/src/test/resources/3_0/deepobject.yaml

See the TestWithHttpInfoAsync function in the generated DefaultApi.cs

Related issues/PRs
Suggest a fix

https://github.com/OpenAPITools/openapi-generator/pull/14979

Assignee
Assign to
Time tracking