go-kratos / kratos

Your ultimate Go microservices framework for the cloud-native era.
https://go-kratos.dev
MIT License
23.38k stars 4.01k forks source link

[Question] How to define 4xx, 5xx response codes in openapi spec generate from proto definitions #3404

Open akoserwal opened 3 months ago

akoserwal commented 3 months ago

I see a way to definite error codes, but it doesn't update the open API spec generation with HTTP error codes https://go-kratos.dev/en/docs/component/errors

kvii commented 2 months ago

If I were you, I would prefer to add a comment to the rpc api, like below:

// GetUser return a user. It will return an error with reason "USER_NOT_FOUND" when user is not found.
rpc GetUser (GetUserRequest) returns (GetUserReply)