[csharp-nancyfx] Endpoints returning an Async Array calls non-existent Task.ToArray()
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 52/100
Research direction
Start with modules/openapi-generator/src/main/resources/csharp-nancyfx/api.mustache, especially the returnType and isListContainer logic. Run the provided OpenAPI generation command with asyncServer enabled, then build the generated NancyFX project. Done means the generated async array endpoint contains no invalid Task.ToArray() call and builds and returns values correctly.
Written by the indexing model from the issue text.
Description
Description
The Async API generated for csharp-nancyfx invokes a non-existent function: Task.ToArray(), causing compile time and runtime errors.
openapi-generator version
3.2.3
OpenAPI declaration file content or url
Cut down version of the default pet store
openapi: 3.0.0
info:
description: >-
...
version: 1.0.0
title: Swagger Petstore
termsOfService: 'http://swagger.io/terms/'
contact:
email: apiteam@swagger.io
license:
name: Apache 2.0
url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
paths:
/pets
get:
tags:
- pet
summary: Get all pets
description: >-
Get all pet names
operationId: getAllPets
responses:
'200':
description: successful operation
content:
application/json:
schema:
type: array
items:
type: string
Config file used for code generation:
{
"asyncServer": "true"
}
Command line used for generation
java -jar openapi-generator-cli.jar -l csharp-nancyfx -i -c -o generatedNancyFxServer
Steps to reproduce
Copy the yml and json into respective files.
Run command to generate the NancyFxServer project.
Open in VS or simply try to build it.
Related issues/PRs
None found
Suggest a fix/enhancement
In following line of code:
https://github.com/OpenAPITools/openapi-generator/blob/8fb3b707a1c4eb462b068bf2c2d20d570d4bb1d9/modules/openapi-generator/src/main/resources/csharp-nancyfx/api.mustache#L34
Current code:
{{#returnType}}{{#isListContainer}}.ToArray(){{/isListContainer}}{{/returnType}}
Fix:
If asyncServer is set, do not write ".ToArray()"
{{^asyncServer}}{{#returnType}}{{#isListContainer}}.ToArray(){{/isListContainer}}{{/returnType}}{{/asyncServer}}
I've manually removed this and confirmed that the endpoint returns values correctly without the ".ToArray()"
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 100
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.
More from OpenAPITools/openapi-generator
-
Issue: Bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
OpenAPITools/openapi-generator#24859 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
OpenAPITools/openapi-generator#24852 · 1 comment ·
-
[BUG][KOTLIN] Fails to compile after updating to 7.25.0 with useJackson3=false useSpringBoot4=true OpenIssue: Bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
OpenAPITools/openapi-generator#24842 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
OpenAPITools/openapi-generator#24830 ·
-
Issue: Bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
OpenAPITools/openapi-generator#24816 · 1 comment ·
All issues in OpenAPITools/openapi-generator
Similar issues
-
Bug Java Platform: Java
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
getsentry/sentry-java#6138 · 1 comment ·
-
bug needs triage p2
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
GoogleCloudPlatform/DataflowTemplates#4273 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
bug needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 76/100