是否有 REST API 的命名约定指南? [英] Are there any naming convention guidelines for REST APIs?

查看:35
本文介绍了是否有 REST API 的命名约定指南?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在创建 REST API 时,API 内的命名约定是否有任何指导方针或事实上的标准(例如:URL 端点路径组件、查询字符串参数)?骆驼帽是规范还是下划线?其他人?

When creating REST APIs, are there any guidelines or defacto standards for naming conventions within the API (eg: URL endpoint path components, querystring parameters)? Are camel caps the norm, or underscores? others?

例如:

api.service.com/helloWorld/userId/x

api.service.com/hello_world/user_id/x

注意:这不是 RESTful API 设计的问题,而是用于最终路径组件和/或使用的查询字符串参数的命名约定指南.

Note: This is not a question of RESTful API design, rather the naming convention guidelines to use for the eventual path components and/or query string parameters used.

如有任何指导方针,我们将不胜感激.

Any guidelines would be appreciated.

推荐答案

我认为你应该避免使用驼峰帽.规范是使用小写字母.我也会避免使用下划线并使用破折号

I think you should avoid camel caps. The norm is to use lower case letters. I would also avoid underscores and use dashes instead

所以你的 URL 应该是这样的(忽略你要求的设计问题:-))

So your URL should look like this (ignoring the design issues as you requested :-))

api.service.com/hello-world/user-id/x

这篇关于是否有 REST API 的命名约定指南?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆