openapi-client-axios icon indicating copy to clipboard operation
openapi-client-axios copied to clipboard

Provide an alias for operations when operationIds are unavailable

Open anttiviljami opened this issue 4 years ago • 2 comments

Sometimes operationIds aren't very helpful, or completely missing.

Let's provide useful aliases for those cases. Some examples:

GET /pets -> getPets GET /pets/{id} -> getPetsById POST /pets -> postPets DELETE /pets/{id} -> deletePetsById

anttiviljami avatar Mar 26 '20 17:03 anttiviljami

Previously I linked to this from an issue filed under your React package. Our API is .NET-based and we generate schemas using a very popular product called Swashbuckle. While researching whether Swashbuckle could automate this for us, I discovered that they mention this problem in their readme:

Auto-generating an ID that matches these requirements, while also providing a name that would be meaningful in client libraries is a non-trivial task and so, Swashbuckle omits the operationId by default. However, if neccessary, you can assign operationIds by decorating individual routes OR by providing a custom strategy.

https://github.com/domaindrivendev/Swashbuckle.AspNetCore/blob/master/README.md#assign-explicit-operationids

Because of the ongoing difficulty of generating meaningful IDs (even by hand) for a large API surface, we're backing away from the React package and returning to URI-based calls.

I thought it might be helpful to point out that even the big-name products don't feel they can automate this.

MV10 avatar Feb 19 '21 11:02 MV10

I worked around this by creating a script that will format my swagger-api.json to have operationIds... could be something you can add as a utility in your typegen tool

ken-playerlync avatar Mar 27 '23 06:03 ken-playerlync