-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Description
Description
When generating the server as a library, the Task methods don't have the CancellationToken parameter.
This is because the template currently renders the CancellationToken only if the options operationResultTask and operationIsAsync are set to true. But operationIsAsync is always false in the case of a library output.
This fix intends to render the CancellationToken only under the operationResultTask option.
openapi-generator version
Latest. Not a regression as the CancellationToken generation has been introduced in Jan 2023 and has been working as described above since then.
OpenAPI declaration file content or url
openapi: 3.0.2
info:
version: '1.0'
title: Thing manager
servers:
- url: http://localhost:5010
paths:
/:
get:
summary: Hello
operationId: hello
tags:
- thing
responses:
'200':
description: Success
Command line used for generation
docker run --rm -v C:\Users\xxx\source\repos\OpenAPI_aspnetcore_CancellationTokenTest\repro:/src openapitools/openapi-generator-cli:latest generate -i /src/spec/combined_openapi.yaml -g aspnetcore -o /src/gen -c /src/generator/generator-config.yaml
Content of the generator-config.yaml:
additionalProperties:
aspnetCoreVersion: 6.0
buildTarget: library
enumValueSuffix: ""
operationResultTask: true
packageName: ThingManager.Generated
sourceFolder: ""
useSwashbuckle: false
useNewtonsoft: true
templateDir: . # relative to location of generator-config.yml
Steps to reproduce
No CancellationToken generator in the controller method
Related issues/PRs
Introduction of CancellationToken:
#14326
operationIsAsync explicitly hard coded to false in the library output case:
#2629