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
  • #1097
Closed
Open
Issue created Sep 25, 2018 by Administrator@rootContributor

[csharp-nancyfx] Endpoints returning an Async Array calls non-existent Task.ToArray()

Created by: stevwan

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()"

Assignee
Assign to
Time tracking