Method Names postfixed with Numbers
When we use a
get
/apples/:id
and a get all
/apples/
the second one listed in the schema will turn into apples1 function in the generated code.
isnt the openapi spec to have the endpoints both named apples? but then we get silly apples1 function name? am i missing something?
thanks
I think it's because both are under the same Tag? I'm currently looking for a way to set an operationId on my spec to set the method name to something better.
EDIT: See https://github.com/ferdikoomen/openapi-typescript-codegen/issues/314
@donkey-donkey @andreujuanc can you try our fork if that works as you'd expect?
Can't at the moment. But just for the record, the current lib will use the operationId for naming, so that should be good enough if you have control over the spec.
EDIT: Gave it a star. Will check as soon as I can.
As @mrlubos pointed out, this might be resolved by https://github.com/ferdikoomen/openapi-typescript-codegen/pull/2043.
You'll want to set the new --useOperationId flag to false to try the alternative method name generator. It's available in the latest release, please let us know whether it worked if you try it
I think OP was asking "why the number suffix", and the answer is because I believe there is no operationId on their spec, and the paths are both on the same Tags. Ignoring the operationId would yield no change to the generated methods.
@andreujuanc the pull request also changes the replacement pattern so I'd expect a different result for their use case, but will need them to try it since I can't see their OpenAPI spec