API REST 格式是否正确?

API REST format is correct?

我对 API REST

的格式有疑问

我有不同的 API :

GET /api/payment/providers
GET /api/payment/recipients
GET /api/payment/rules
DELETE /api/payment/rules/{uuid}
PUT /api/payment/rules/{uuid}
POST /api/payment/rules

这个格式正确吗?

或者我应该有类似的东西:

GET /api/paymentProviders
GET /api/paymentRecipients
GET /api/paymentRules
DELETE /api/paymentRules/{uuid}
PUT /api/paymentRules/{uuid}
POST /api/paymentRules

听说 REST 必须遵守这种格式:

Resource list / specific resource / sub-resource list / specific sub-resource / etc...

但是,我的格式对不对?

谢谢!

TL;DR:您的资源标识符很好

I heard that REST must respect this format:

没有

您可以对资源标识符使用任何您喜欢的拼写约定。

RFC 3986 defines the production rules for URI, and HTTP Semantics 定义了使用 http/https URI 方案时要遵循的一组更严格的规则。

但是这些都没有对路径段的使用施加任何语义限制。

资源标识符类似于变量名——机器不关心你使用什么拼写,所以你可以选择任何你喜欢的拼写。最好的拼写是那些对您最关心的人来说最方便的拼写。