Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

async controller methods with "Async" suffix should not generate "AsyncAsync" #1730

Closed
timmkrause opened this issue Nov 13, 2018 · 8 comments

Comments

@timmkrause
Copy link

A controller with

public async Task<ActionResult<Something>> GetSomethingAsync([Required] Guid foo)

becomes

System.Threading.Tasks.Task<Something> GetSomethingAsyncAsync(System.Guid foo);

For the generated code I'd also simply prefer GetSomethingAsync.

@timmkrause timmkrause changed the title async controller methods with Async suffix should not generate AsyncAsync async controller methods with "Async" suffix should not generate "AsyncAsync" Nov 13, 2018
@lukaskolafa
Copy link

I usually use operationId without Async suffix. Then I do not have this problem. In my opinion operationIds should have names tailored for the clients (and clients are not interested in some async implementation details)

@timmkrause
Copy link
Author

That way you are forcing me to use OperationIds. Maybe there is no benefit for me in using them or I do want to reflect as much as I can to my clients without constantly adapting OperationIds.

@lukaskolafa
Copy link

operationId has the benefit, that internal implementation details (name of controller method) is not faced to clients. xxxAsync suffix is for me technical restriction/pattern and API (operationIds) is business/client point of view. Separating the technical part from the client part seems being plausible. Of course it is some overhead for improved quality - depends on your scenario how much you want to invest into that.

@RicoSuter
Copy link
Owner

NSwag generates operation ids in the form controllerName_operationName where operationName is stripped off the Async suffix. Async should not be part of a spec as it is an implementation detail. How did you generate the spec? Can you post process it?

@timmkrause
Copy link
Author

Sorry guys, this was my bad. (If I remember correctly) I already had an OperationId in place which had the Async suffix in its name and the generation additionally added an Async suffix.

Please close if you're fine with this behavior (I am).

@RicoSuter
Copy link
Owner

I think Async should not be in the operation id as it is an implementation of the used language (leaky abstraction), ie all operations are async and this its not needed

@baskialdensys
Copy link

Is it possible to make Adding Async at the end of a method as Settings option ?

@RicoSuter
Copy link
Owner

@baskialdensys please open a new issue for that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants