Open anttiviljami opened 4 years ago
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.
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.
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
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