【发布时间】:2017-05-23 12:13:18
【问题描述】:
在我的项目中,我们需要为 Web Api 遵循一些编码标准。 有什么方法可以在 Resharper 中配置这些指令?我正在使用 Resharper Ultimate 版本。我们也可以这样配置 resharper,如果不遵循这些指令,它会抛出错误并显示建议。
该指南包含以下常见说明:
Use Camel case in Payload
Use camel case for the data elements in the payload. Eg:firstName,lastName
Use lowercase in Endpoints
Use only lower case when defining the endpoints.
Eg: GET \api\v1\customers\{CustomerID}\rewards
Use hyphen for compound words in Endpoints
Use hyphen for compound words in Endpoints.
Eg: GET \api\v1\customers\{CustomerId}\order-history
Use Nouns not verbs
Noun based endpoint should be used rather than verb based endpoint for CRUD operations.
Eg: GET \api\v1\\customers, GET \api\v1\customers\{CustomerID}
GET \api\v1\GetAllCustomers
Use verb followed by noun in case of certain functions.
Eg: PUT \api\v1\customers\{CustomerID}\send-email
【问题讨论】:
-
感谢大家的快速回复。但我需要更多的定制。例如如果有人将端点定义为大写字母 [Route("Seller/Search/{Page}/{PageSize}")] 那么它应该抛出错误并建议使用 [Route("seller/search/{page}/{ pageSize}")]