REST API设计指导——译自Microsoft REST API Guidelines(二)
由于文章内容较长,只能拆开发布。翻译的不对之处,请多多指教。
另外:最近团队在做一些技术何架构的研究,视频教程只能争取周末多录制一点,同时预计在下周我们会展开一次直播活动,内容围绕容器技术这块。
所有章节我们翻译校对完成后,将会将最终定稿签入到我们的Github开源库托管,方便大家查阅和校正。同时,我们推荐将此规范作为团队的REST API设计指导和规范。
上篇内容:
REST API设计指导——译自Microsoft REST API Guidelines(一)
3 Introduction 介绍
Developers access most Microsoft Cloud Platform resources via HTTP interfaces.
开发者基本都通过 HTTP 接口访问微软云平台的资源。
Although each service typically provides language-specific frameworks to wrap their APIs, all of their operations eventually boil down to HTTP requests.
尽管每个服务通过特定语言的框架封装了它们的 API,但它们的所有操作最终都归结为 HTTP 请求。
Microsoft must support a wide range of clients and services and cannot rely on rich frameworks being available for every development environment.
微软必须支持多种类型的客户端和服务,且不能依赖于各个开发环境丰富的框架。
Thus a goal of these guidelines is to ensure Microsoft REST APIs can be easily and consistently consumed by any client with basic HTTP support.
因此,这些准则的一个目标是确保任何支持基本 HTTP 协议的客户端都可以简单且一致地使用 Microsoft REST API。
To provide the smoothest possible experience for developers, it's important to have these APIs follow consistent design guidelines, thus making using them easy and intuitive.
为了给开发人员提供最流畅的开发体验,让这些 API 遵循一致的设计准则非常重要,从而使它们用起来简单直观。
This document establishes the guidelines to be followed by Microsoft REST API developers for developing such APIs consistently.
本文档建立了 Microsoft REST API 开发人员应该遵循的指南, 以便统一一致地开发 API。
The benefits of consistency accrue in aggregate as well; consistency allows teams to leverage common code, patterns, documentation and design decisions.
一致性的好处在于可以不断地积累合理的规范;一致性使团队拥有统一的代码、模式、文档风格和设计策略。
These guidelines aim to achieve the following:
Define consistent practices and patterns for all API endpoints across Microsoft.
Adhere as closely as possible to accepted REST/HTTP best practices in the industry at-large.*
Make accessing Microsoft Services via REST interfaces easy for all application developers.
Allow service developers to leverage the prior work of other services to implement, test and document REST endpoints defined consistently.
Allow for partners (e.g., non-Microsoft entities) to use these guidelines for their own REST endpoint design.
这些准则旨在实现以下目标:
为 Microsoft 技术平台中的所有 API 端点定义一致的实现和体验。
尽可能地遵循行业普遍接受的 REST/HTTP 最佳实践。
使所有程序的开发人员都可以通过 REST 接口简单地友好地访问 Microsoft 服务。
允许Service服务开发人员利用其他Service服务的基础来开发一致的 REST API 节点。
允许合作伙伴 (如非微软团队) 使用这些准则来设计自己的 REST API。
*Note: The guidelines are designed to align with building services which comply with the REST architectural style, though they do not address or require building services that follow the REST constraints.
The term "REST" is used throughout this document to mean services that are in the spirit of REST rather than adhering to REST by the book.*
注:本指南旨在构建符合 REST 架构风格的服务,但不涉及或要求构建遵循 REST 约束的服务。
本文档中使用的“REST”术语代指具有 RESTful风格的服务,而不是仅仅遵循 REST。
3.1 Recommended reading 推荐阅读
Understanding the philosophy behind the REST Architectural Style is recommended for developing good HTTP-based services.
了解 REST 架构风格背后的一些理念,更有助于开发优秀的基于 HTTP 的服务。
If you are new to RESTful design, here are some good resources:
[REST on Wikipedia][rest-on-wikipedia] -- Overview of common definitions and core ideas behind REST.
[REST Dissertation][fielding] -- The chapter on REST in Roy Fielding's dissertation on Network Architecture, "Architectural Styles and the Design of Network-based Software Architectures"
[RFC 7231][rfc-7231] -- Defines the specification for HTTP/1.1 semantics, and is considered the authoritative resource.
[REST in Practice][rest-in-practice] -- Book on the fundamentals of REST.
如果您对 RESTful 设计不熟悉,请参阅以下优秀资源:
概述 REST 背后的常见定义和核心思想。
在 Roy Fielding 关于网络体系结构的论文中"架构风格与基于网络的软件体系结构设计" 一章。
HTTP/1.1 语义规范的权威资料。
关于 REST 的入门书籍。
译者注:上一篇说了,REST 指的是一组架构约束条件和原则。那么满足这些约束条件和原则的应用程序或设计就是 RESTful。
4 Interpreting the guidelines 解读指导
4.1 Application of the guidelines 应用指导
These guidelines are applicable to any REST API exposed publicly by Microsoft or any partner service.
这些准则适用于 Microsoft 或其合作伙伴公开发布的所有 REST API 服务。
Private or internal APIs SHOULD also try to follow these guidelines because internal services tend to eventually be exposed publicly.
私人或内部的 API 也大致可以遵循这些准则, 因为内部服务往往最终会公开。
Consistency is valuable to not only external customers but also internal service consumers, and these guidelines offer best practices useful for any service.
保证一致性不仅对外部客户有利, 而且对内部服务的使用者也很有价值, 这些准则为所有的服务提供了最佳实践。
There are legitimate reasons for exemption from these guidelines.
当然有许多合理理由可以不遵循这些准则。
Obviously a REST service that implements or must interoperate with some externally defined REST API must be compatible with that API and not necessarily these guidelines.
显然,实现或必须与某些外部定义的 REST API 互操作的 REST 服务必须与那些 API 兼容,而无法遵循这些准则。
Some services MAY also have special performance needs that require a different format, such as a binary protocol.
还有一些服务可能由于对性能的特殊的需求,必须使用其他格式,如采用二进制协议。
4.2 Guidelines for existing services and versioning of services
现有服务和服务版本指南
We do not recommend making a breaking change to a service that pre-dates these guidelines simply for compliance sake.
我们不建议为了遵循这些准则,而过早的对老服务进行重大更改。
The service SHOULD try to become compliant at the next version release when compatibility is being broken anyway.
无论如何,当兼容性被破坏时,该服务应该尝试在下一版本中变得合规。
When a service adds a new API, that API SHOULD be consistent with the other APIs of the same version.
当一个服务添加新的 API 时,该 API 应该与同一版本的其他 API 保持一致。
So if a service was written against version 1.0 of the guidelines, new APIs added incrementally to the service SHOULD also follow version 1.0. The service can then upgrade to align with the latest version of the guidelines at the service's next major release.
因此,如果服务是针对 1.0 版本的指南编写的,那么增量添加到服务的新 API 也应该遵循 1.0 版本指南。然后该服务在下一次主要版本更新时,再去遵循最新版指南。
4.3 Requirements language 要求的语言
The keywords "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.
本文档中的"MUST"(必须), "MUST NOT"(禁止), "REQUIRED"(需要), "SHALL"(将要), "SHALL NOT"(最好不要), "SHOULD"(应该), "SHOULD NOT"(不应该), "RECOMMENDED"(推荐), "MAY"(可能), 和 "OPTIONAL"(可选) 等关键字的详细解释见 RFC 2119。
4.4 License 许可证
This work is licensed under the Creative Commons Attribution 4.0 International License.
本文的产权使用Creative Commons Attribution 4.0 International License。
译者注:署名 4.0 国际,也就是允许在任何媒介以任何形式复制、发行本作品,允许修改、转换或以本作品为基础进行创作。允许任何用途,甚至商业目的。
To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
要查看此许可证的副本,请访问http://creativecommons.org/licenses/by/4.0/
或向Creative Commons发送一封信,PO Box 1866,Mountain View,CA 94042,USA。
REST API设计指导——译自Microsoft REST API Guidelines(二)的更多相关文章
- REST API设计指导——译自Microsoft REST API Guidelines(四)
前言 前面我们说了,如果API的设计更规范更合理,在很大程度上能够提高联调的效率,降低沟通成本.那么什么是好的API设计?这里我们不得不提到REST API. 关于REST API的书籍很多,但是完整 ...
- REST API设计指导——译自Microsoft REST API Guidelines(三)
前面我们说了,如果API的设计更规范更合理,在很大程度上能够提高联调的效率,降低沟通成本.那么什么是好的API设计?这里我们不得不提到REST API. 关于REST API的书籍很多,但是完整完善实 ...
- REST API设计指导——译自Microsoft REST API Guidelines(一)
前言 前面我们说了,有章可循,有据可依,有正确的产品流程和规范,我们的工作才不至于产生混乱,团队的工作才能更有成效.我们经常见到,程序开发可能只用了半个月,但是接口的联调却经常需要花费半个月甚至一个月 ...
- API设计指南(译)
API的设计在软件系统中的重要性不言而喻,在swift.org上看到一篇“API Design Guidelines”,虽然是就Swift而言,但对于其它语言也有不少可以借鉴的地方,在这里粗略翻译一二 ...
- Web API设计方法论--比较完整的web api 开发过程
为Web设计.实现和维护API不仅仅是一项挑战:对很多公司来说,这是一项势在必行的任务.本系列将带领读者走过一段旅程,从为API确定业务用例到设计方法论,解决实现难题,并从长远的角度看待在Web上维护 ...
- 关于REST API设计的文章整理
1. rest api uri设计的7个准则(1)uri末尾不需要出现斜杠/(2)在uri中使用斜杠/表达层级关系(3)在uri中可以使用连接符-提升可读性(4)在uri中不允许出现下划线字符_(5) ...
- API设计原则
译序 Qt的设计水准在业界很有口碑,一致.易于掌握和强大的API是Qt最著名的优点之一.此文既是Qt官网上的API设计指导准则,也是Qt在API设计上的实践总结.虽然Qt用的是C++,但其中设计原则和 ...
- 移动App的REST API设计实践
原文:http://www.jianshu.com/p/23cccb3a90b1 通讯协议 一些只是对服务器数据进行CRUD操作的App,通常采用HTTP协议,为了安全也可以采用HTTPS协议.IM软 ...
- Flink Program Guide (2) -- 综述 (DataStream API编程指导 -- For Java)
v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VM ...
随机推荐
- Javascript 标识符及同名标识符的优先级
一.定义 标识符(Identifier)就是一个名字,用来对变量.函数.属性.参数进行命名,或者用做某些循环语句中的跳转位置的标记. //变量 var Identifier = 123; //属性 ( ...
- Java Web 获取客户端真实IP
Java Web 获取客户端真实IP 发生的场景:服务器端接收客户端请求的时候,一般需要进行签名验证,客户端IP限定等情况,在进行客户端IP限定的时候,需要首先获取该真实的IP.一般分为两种情况: 方 ...
- springmvc的日期类型转换
springmvc的日期类型转换 # spring mvc绑定参数之类型转换有三种方式: ## 1.实体类中加日期格式化注解 @DateTimeFormat(pattern="yyyy- ...
- Android Studio 设置不同分辨率的图标Icon
右键你的项目 -->"NEW"-->"Image Asset" 'Asset Type' 勾选”Image“才可以选择”Path“,其他选项可以自己 ...
- HTML图片标签路径解析
img标签中src属性表示的是引用的图片路径,有两种路径类型: 1. 绝对路径 2. 相对路径. 绝对路径:使用图片在硬盘上的绝对位置来访问图片,通常是从根目录开始,向下一个目录一个目录的寻找. ...
- topic的leader显示为none的解决办法
1.查看kafka的topic详细信息 bin/kafka-topics.sh --zookeeper 127.0.0.1:2181 --topic test --describe 配置delete. ...
- powerdesigner 不能自动生成注释的解决方法(三步解决)
解决power designer 不能自动生成注释的解决办法只需要3步: 一.快捷键 Ctrl+Shift+X 打开脚本编辑器:(快捷键不能执行的话可以从这个路径执行:Tools --> Exc ...
- Linux入门总结——虚拟机安装配置以及vim简单操作
安装配置ubuntu 安装准备 vittualbox-5.2.22版本(win10) ubuntu-12.04 安装VirtualBox 1.双击VirtualBox-5.2.2-119230-Win ...
- NFS部署文件共享
本章解了如何配置网络文件系统(Network File System,NFS)服务来简化Linux系统之间的文件共享工作,以及通过部署NFS服务在多台Linux系统之间挂载并使用资源.在管理设备挂载信 ...
- 大数据BI框架知识点备注
将这段时间的一些基于大数据方案的BI知识点暂时做些规整,可能还存在较多问题,后续逐步完善修改. 数据模型: 1.星型模型和雪花模型,同样是将业务表拆分成事实表和纬度表:例如一个员工数据表,可以拆分为员 ...