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

1

5

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?

Diazonium answered 5/6, 2019 at 16:24 Comment(1)
There's SO topic discussing [how to set operationId in .Net Core ](#39413498)Garibold
M
7

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.

Mas answered 5/6, 2019 at 17:48 Comment(2)
But I am specifying it, but it just appears to not being honored? I'm digging through he mustache templates right now.Diazonium
Never mind, turns out that the one method I was looking at didn't have operationId. I can confirm that operationId does define the methodName if in the file. Thanks for replying @William Cheng. Awesome project.Diazonium

© 2022 - 2024 — McMap. All rights reserved.