OpenAPITools / OpenAPITools/openapi-generator
[BUG] [dotnetcore] Implement QueryParameter deepObject style is missing for async function
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Run the documented generator command with modules/openapi-generator/src/test/resources/3_0/deepobject.yaml and inspect the generated TestWithHttpInfoAsync method in DefaultApi.cs. Compare its query-parameter handling with the expected output in the issue; done means async C# clients emit the deepObject fields correctly, with coverage for the reproduction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100