OpenAPITools / OpenAPITools/openapi-generator

[REQ][csharp-netcore] Add option to skip generation of sync methods

Open
#13,879 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Is your feature request related to a problem? Please describe.

I'd like to prevent myself from accidentally making an API call synchronously. It's easy to forget calling the Async method variant without noticing.

Describe the solution you'd like

An option to turn off generation of synchronous methods would not only make it impossible to accidentally call APIs synchronously, but would also make the client as a whole leaner by reducing the amount of files that have to be generated. All modern C# projects I've worked on avoid making synchronous HTTP calls, for good reason, so I think it makes sense to have the ability to disable it.

Describe alternatives you've considered

Differentiation for sync and async methods could also be improved by having seperate classes generated for sync and async calls respectively, but that would just blow up project sizes even further.

For now, to stop myself from using async methods, I provide a custom implementation for ISynchronousClient throwing NotSupportedExceptions for any method.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the csharp-netcore generator and the path responsible for generating synchronous methods. Define the requested option's scope, then verify that enabled generation remains unchanged and disabled generation omits synchronous methods while retaining asynchronous methods.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.