Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide an alias for operations when operationIds are unavailable #19

Open
anttiviljami opened this issue Mar 26, 2020 · 2 comments
Open
Labels
enhancement New feature or request

Comments

@anttiviljami
Copy link
Member

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

@MV10
Copy link

MV10 commented Feb 19, 2021

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.

@ken-playerlync
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants