Search code examples
openapiopenapi-generator

When using openapi-generator can you customize method name generation for C# client


Using openapi-generator to generate a C# API client using an openapi v3.0 specification. Is there a way to customize the methodNames of the API? I'd prefer to be able to specify them maybe by using operationId field?

Right now they are incorporating the path variables along with the HTTP VERB and the static path components. It'll work, but I'd like the names to be a bit different.

GetEncountersResponse ClientidEncountersDateGet (string clientid, string date, string startToken = null);

The other option is to just add new methods since the class is defined as partial?


Solution

  • Right now they are incorporating the path variables along with the HTTP VERB and the static path components. It'll work, but I'd like the names to be a bit different.

    Looks like the operationId (optional) is missing in the operation (endpoint) defined in the OpenAPI doc/spec and that's why the method name is auto-generated based on the path, HTTP verb, etc.

    You can define the operationId to have better control of the method name.